Coder Social home page Coder Social logo

Comments (26)

bkase avatar bkase commented on May 24, 2024 1

Great -- it works! Thanks!

from rules_apple.

sergiocampama avatar sergiocampama commented on May 24, 2024

macOS command line applications are not fully supported at this time. Can you try using the following flags?

--apple_crosstool_transition
--experimental_objc_crosstool=all

Also, because you're building it with Swift, the binary by itself will not work, as it needs to find the swift dylibs when running the command line binary. You may be able to get around this issue by using linkopts or copying the dylibs to the expected locations. We should be able to have a better story for this use case in the future.

from rules_apple.

rahul-malik avatar rahul-malik commented on May 24, 2024

I believe passing -static-stdlib as a linker option should force the dylibs to be bundled with the executable.

This would be great to have supported as we're building many small tools as Swift CLI applications

from rules_apple.

bkase avatar bkase commented on May 24, 2024

@sergiocampama thanks for the advice. I did actually try those flags as well.
Here is that error again:

bazel build '//tools/nail'  --apple_crosstool_transition   --experimental_objc_crosstool=all

Unhandled exception thrown during build; message: Unrecoverable error while evaluating node 'CONFIGURED_TARGET:@bazel_tools//tools/objc:dummy_lib 12cfa70c0d8f30f02088acb09a2168d3 (117387724 1986241952)' (requested by nodes 'CONFIGURED_TARGET://tools/nail:nail 12cfa70c0d8f30f02088acb09a2168d3 (2050766030 1986241952)')
INFO: Elapsed time: 1.599s
java.lang.RuntimeException: Unrecoverable error while evaluating node 'CONFIGURED_TARGET:@bazel_tools//tools/objc:dummy_lib 12cfa70c0d8f30f02088acb09a2168d3 (117387724 1986241952)' (requested by nodes 'CONFIGURED_TARGET://tools/nail:nail 12cfa70c0d8f30f02088acb09a2168d3 (2050766030 1986241952)')
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:472)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:497)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: objc_library rule @bazel_tools//tools/objc:dummy_lib : These artifacts do not have a generating action:
bazel-out/ios_x86_64-fastbuild/genfiles/external/bazel_tools/tools/objc/dummy_lib.modulemaps/module.modulemap
No origin, run with --experimental_extended_sanity_checks
These actions were checked:
com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction FileWrite
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib-archive.objlist
com.google.devtools.build.lib.rules.cpp.CppCompileAction ObjcCompile
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/_objs/dummy_lib/external/bazel_tools/tools/objc/objc_dummy.o
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/_objs/dummy_lib/external/bazel_tools/tools/objc/objc_dummy.d
com.google.devtools.build.lib.rules.cpp.CppLinkAction CppLink
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/libdummy_lib.a
com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction FileWrite
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/libdummy_lib.so-2.params
com.google.devtools.build.lib.rules.cpp.CppLinkAction CppLink
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/libdummy_lib.so
com.google.devtools.build.lib.rules.cpp.CppLinkAction CppLink
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib_fully_linked.a
com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction FileWrite
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib.xcodeproj-control
com.google.devtools.build.lib.analysis.actions.SpawnAction GenerateXcodeproj
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib.xcodeproj/project.pbxproj

	at com.google.devtools.build.lib.analysis.CachingAnalysisEnvironment.verifyGeneratedArtifactHaveActions(CachingAnalysisEnvironment.java:150)
	at com.google.devtools.build.lib.analysis.CachingAnalysisEnvironment.disable(CachingAnalysisEnvironment.java:113)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1144)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:261)
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:398)
	... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node 'CONFIGURED_TARGET:@bazel_tools//tools/objc:dummy_lib 12cfa70c0d8f30f02088acb09a2168d3 (117387724 1986241952)' (requested by nodes 'CONFIGURED_TARGET://tools/nail:nail 12cfa70c0d8f30f02088acb09a2168d3 (2050766030 1986241952)')
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:472)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:497)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: objc_library rule @bazel_tools//tools/objc:dummy_lib : These artifacts do not have a generating action:
bazel-out/ios_x86_64-fastbuild/genfiles/external/bazel_tools/tools/objc/dummy_lib.modulemaps/module.modulemap
No origin, run with --experimental_extended_sanity_checks
These actions were checked:
com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction FileWrite
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib-archive.objlist
com.google.devtools.build.lib.rules.cpp.CppCompileAction ObjcCompile
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/_objs/dummy_lib/external/bazel_tools/tools/objc/objc_dummy.o
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/_objs/dummy_lib/external/bazel_tools/tools/objc/objc_dummy.d
com.google.devtools.build.lib.rules.cpp.CppLinkAction CppLink
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/libdummy_lib.a
com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction FileWrite
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/libdummy_lib.so-2.params
com.google.devtools.build.lib.rules.cpp.CppLinkAction CppLink
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/libdummy_lib.so
com.google.devtools.build.lib.rules.cpp.CppLinkAction CppLink
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib_fully_linked.a
com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction FileWrite
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib.xcodeproj-control
com.google.devtools.build.lib.analysis.actions.SpawnAction GenerateXcodeproj
    bazel-out/ios_x86_64-fastbuild/bin/external/bazel_tools/tools/objc/dummy_lib.xcodeproj/project.pbxproj

	at com.google.devtools.build.lib.analysis.CachingAnalysisEnvironment.verifyGeneratedArtifactHaveActions(CachingAnalysisEnvironment.java:150)
	at com.google.devtools.build.lib.analysis.CachingAnalysisEnvironment.disable(CachingAnalysisEnvironment.java:113)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1144)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:261)
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:398)
	... 4 more

This error happens way before the linking phase of the binary so I think this error is unrelated.

from rules_apple.

sergiocampama avatar sergiocampama commented on May 24, 2024

have you tried using a newer version? like 0.5.0 release?

from rules_apple.

bkase avatar bkase commented on May 24, 2024

Ah @sergiocampama that did work -- but I get a new error:

𝝺 bazel build '//tools/nail:nail' --apple_crosstool_transition   --experimental_objc_crosstool=all
INFO: Found 1 target...
ERROR: /Users/bkase/code/ios/tools/nail/BUILD:12:1: Linking of rule '//tools/nail:nail' failed: Process exited with status 1 [sandboxed].
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/Developer/Library/Frameworks'
ld: warning: -undefined dynamic_lookup is deprecated on iOS
ld: warning: URGENT: building for iOS simulator, but linking in object file (bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a(Path.swift.o)) built for OSX. Note: This will be an error in the future.
ld: warning: URGENT: building for iOS simulator, but linking in object file (bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a(Shell.swift.o)) built for OSX. Note: This will be an error in the future.
ld: warning: URGENT: building for iOS simulator, but linking in object file (bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a(main.swift.o)) built for OSX. Note: This will be an error in the future.
ld: framework not found ApplicationServices for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Use --strategy=ObjcLink=standalone to disable sandboxing for the failing actions.
Target //tools/nail:nail failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.189s, Critical Path: 0.08s

From looking at the implementation of swift_library, I would think that setting apple_binary platform to macos should cause the swift library to build for macos and not ios, but it doesn't seem like that's happening.

Any ideas why this could be happening?

I tested this on the latest commit of this repo: fb541a360ee42ed1d29fdf047819210182efa472

from rules_apple.

sergiocampama avatar sergiocampama commented on May 24, 2024

Yeah, it appears to be linking for macOS but using the iOS simulator x86_64 architecture... Can you rerun that command with -s to show the actual link command executed?

@dmishe do you have any insights?

from rules_apple.

bkase avatar bkase commented on May 24, 2024

Ahh looks like only the link-step is incorrect:

____Loading package: tools/nail
____Loading package: @bazel_tools//tools/jdk
____Loading package: @local_config_cc//
____Loading package: @local_config_xcode//
____Loading complete.  Analyzing...
____Loading package: @bazel_tools//third_party/java/jdk/langtools
____Found 1 target...
____Building...
>>>>>>>>> # @bazel_tools//tools/objc:xcrunwrapper [action 'Creating runfiles tree bazel-out/host/bin/external/bazel_tools/tools/objc/xcrunwrapper.runfiles [for host]']
(cd /private/var/tmp/_bazel_bkase/38ce3467f03292646d64ab210624b84b/execroot/ios && \
  exec env - \
    PATH='/Users/bkase/code/ios2/Scripts/bazel/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/Users/bkase/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.cargo/bin:~/go_appengine:~/.cabal/bin:/usr/local/opt/ruby/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/local/share/npm/bin:/usr/texbin:/Users/bkase/android-sdk/tools:/Users/bkase/android-sdk/platform-tools:/Users/bkase/android-ndk-r9b:/Users/bkase/google-cloud-sdk/bin:~/bin:/Users/bkase/.local/bin:/Library/TeX/texbin' \
    TMPDIR=/var/folders/gs/1j8b8w7d5qb4yrv58p5l3pnh0000gn/T/ \
  /private/var/tmp/_bazel_bkase/38ce3467f03292646d64ab210624b84b/execroot/ios/_bin/build-runfiles bazel-out/host/bin/external/bazel_tools/tools/objc/xcrunwrapper.runfiles_manifest bazel-out/host/bin/external/bazel_tools/tools/objc/xcrunwrapper.runfiles)
>>>>>>>>> # //tools/nail:_nail [action 'Compiling Swift module _nail (3 files)']
(cd /private/var/tmp/_bazel_bkase/38ce3467f03292646d64ab210624b84b/execroot/ios && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.12 \
    XCODE_VERSION_OVERRIDE=8.3.2 \
  bazel-out/host/bin/external/bazel_tools/tools/objc/xcrunwrapper swiftc -emit-object -module-name Nail -target x86_64-apple-macosx10.10 -sdk __BAZEL_XCODE_SDKROOT__ -module-cache-path bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/_objc_module_cache -Onone -DDEBUG -enable-testing -Xfrontend -serialize-debugging-options tools/nail/Sources/Path.swift tools/nail/Sources/Shell.swift tools/nail/Sources/main.swift -Ibazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -iquote -Xcc . -Xcc -O0 -Xcc '-DDEBUG=1' -whole-module-optimization -swift-version 3 -Ibazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs -emit-module-path bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.swiftmodule -emit-objc-header-path bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail-Swift.h -output-file-map bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail.output_file_map.json -num-threads 12)
>>>>>>>>> # //tools/nail:_nail [action 'Archiving Swift objects _nail']
(cd /private/var/tmp/_bazel_bkase/38ce3467f03292646d64ab210624b84b/execroot/ios && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.12 \
    XCODE_VERSION_OVERRIDE=8.3.2 \
  bazel-out/host/bin/external/bazel_tools/tools/objc/xcrunwrapper libtool -static -o bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Path.swift.o bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Shell.swift.o bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/main.swift.o)
>>>>>>>>> # //tools/nail:nail [action 'Linking tools/nail/nail_bin']
(cd /private/var/tmp/_bazel_bkase/38ce3467f03292646d64ab210624b84b/execroot/ios && \
  exec env - \
    APPLE_SDK_PLATFORM=iPhoneSimulator \
    APPLE_SDK_VERSION_OVERRIDE=10.3 \
    PATH='/Users/bkase/code/ios2/Scripts/bazel/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/Users/bkase/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.cargo/bin:~/go_appengine:~/.cabal/bin:/usr/local/opt/ruby/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/local/share/npm/bin:/usr/texbin:/Users/bkase/android-sdk/tools:/Users/bkase/android-sdk/platform-tools:/Users/bkase/android-ndk-r9b:/Users/bkase/google-cloud-sdk/bin:~/bin:/Users/bkase/.local/bin:/Library/TeX/texbin' \
    TMPDIR=/var/folders/gs/1j8b8w7d5qb4yrv58p5l3pnh0000gn/T/ \
    XCODE_VERSION_OVERRIDE=8.3.2 \
  external/local_config_cc/wrapped_clang -Wl,-S -F__BAZEL_XCODE_SDKROOT__/Developer/Library/Frameworks '-isysroot __BAZEL_XCODE_SDKROOT__' -undefined dynamic_lookup -headerpad_max_install_names -no-canonical-prefixes -target x86_64-apple-ios '-mios-simulator-version-min=10.10' '-framework Foundation' '-framework UIKit' -arch x86_64 -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -rpath -Xlinker @executable_path/Frameworks -fobjc-link-runtime -ObjC '-filelist bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/bin/tools/nail/nail-linker.objlist' '-o bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/bin/tools/nail/nail_bin' -L__BAZEL_XCODE_DEVELOPER_DIR__/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx '-Xlinker -add_ast_path -Xlinker bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.swiftmodule')
ERROR: /Users/bkase/code/ios/tools/nail/BUILD:12:1: Linking of rule '//tools/nail:nail' failed: Process exited with status 1 [sandboxed].
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/Developer/Library/Frameworks'
ld: warning: -undefined dynamic_lookup is deprecated on iOS
ld: warning: URGENT: building for iOS simulator, but linking in object file (bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a(Path.swift.o)) built for OSX. Note: This will be an error in the future.
ld: warning: URGENT: building for iOS simulator, but linking in object file (bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a(Shell.swift.o)) built for OSX. Note: This will be an error in the future.
ld: warning: URGENT: building for iOS simulator, but linking in object file (bazel-out/macos-x86_64-min10.10-applebin_macos-ios_x86_64-fastbuild/genfiles/tools/nail/_nail/_objs/Nail.a(main.swift.o)) built for OSX. Note: This will be an error in the future.
ld: framework not found ApplicationServices for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Use --strategy=ObjcLink=standalone to disable sandboxing for the failing actions.
Target //tools/nail:nail failed to build
Use --verbose_failures to see the command lines of failed build steps.
____Elapsed time: 5.433s, Critical Path: 3.35s

from rules_apple.

bkase avatar bkase commented on May 24, 2024

Seems like it may be a bug in apple_binary in bazel, but I'll defer to the experts 🙂

from rules_apple.

c-parsons avatar c-parsons commented on May 24, 2024

I'm able to reproduce this issue -- debugging...

from rules_apple.

c-parsons avatar c-parsons commented on May 24, 2024

Got it. You'll need to add --experimental_enable_objc_cc_deps
I forgot about it because it's default-on now, but wasn't in bazel 0.5.0 rc8.

from rules_apple.

perezd avatar perezd commented on May 24, 2024

I'm having a similar problem, I am getting this when I run the lipobin that is generated:
dyld: Library not loaded: @rpath/libswiftCore.dylib

EDIT:
bazel version
Build label: 0.5.2-homebrew
Build target: bazel-out/darwin_x86_64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jun 27 20:24:06 2017 (1498595046)
Build timestamp: 1498595046
Build timestamp as int: 1498595046

rules_apple version = 0.9.29.

MORE EDIT:
Here's the otool -L output on my binary:

/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1349.63.0)
@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 802.0.53)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
@rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 802.0.53)
@rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 802.0.53)
@rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 802.0.53)
@rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 802.0.53)
@rpath/libswiftIOKit.dylib (compatibility version 1.0.0, current version 802.0.53)
@rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 802.0.53)
@rpath/libswiftSwiftOnoneSupport.dylib (compatibility version 1.0.0, current version 802.0.53)

Here's my build log:
https://gist.github.com/perezd/672ca9b7c6b909fff68a9087868e3a13

This bit is worrisome:
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/Developer/Library/Frameworks'

from rules_apple.

c-parsons avatar c-parsons commented on May 24, 2024

.. is that directory present on your machine?
(/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/Developer/Library/Frameworks)

from rules_apple.

allevato avatar allevato commented on May 24, 2024

AFAICT, the missing directory warning is a red herring—Bazel is adding a bad path to the link options for the binary, but it gets ignored. I have a bug filed internally somewhere for that.

Have you synced the latest from this repo? macos_command_line_application should be statically linking Swift, whereas the errors and otool output you're seeing indicate that it's trying to dynamically link.

from rules_apple.

perezd avatar perezd commented on May 24, 2024

from rules_apple.

allevato avatar allevato commented on May 24, 2024

We have a Swift command-line example in https://github.com/bazelbuild/rules_apple/tree/master/examples/macos/CommandLineSwift; try modeling your target after that, and let us know if you have any other questions!

from rules_apple.

perezd avatar perezd commented on May 24, 2024

So I managed to try tho get this working today and I now get this error:
https://gist.github.com/perezd/5c5e6b282bb890ef14bea22b5f3eb740

This is my build file:
https://gist.github.com/perezd/ad391bc236b15712fb451a29cd9827ec

for this repo archive:
https://github.com/apple/swift-protobuf

from rules_apple.

allevato avatar allevato commented on May 24, 2024

Are you still passing the necessary CROSSTOOL flags when you run blaze build? I'm surprised to see the legacy compilation path in that stack trace.

from rules_apple.

perezd avatar perezd commented on May 24, 2024

I wasn't passing anything to it, I am using the latest version of bazel. Should I be?

from rules_apple.

allevato avatar allevato commented on May 24, 2024

Yes, macOS support requires the experimental CROSSTOOL support to be manually enabled until it's made the default in Bazel. At the top of this page, it mentions the --experimental_objc_crosstool=all that you need to pass for the time being.

Given the macOS support being super-experimental, that may be enough to get it working in 0.5.2. If not, you'll need to build Bazel from source to get up and running.

from rules_apple.

perezd avatar perezd commented on May 24, 2024

Worked!! Any idea when I won't need this flag anymore?

from rules_apple.

rahul-malik avatar rahul-malik commented on May 24, 2024

@allevato - I'm working on a macos command line tool that I'd like to include in another project as an external dependency (through the WORKSPACE file). How can I specify that these flags are required for building my CLI tool so other projects that depend on it don't have to specify them?

from rules_apple.

sergiocampama avatar sergiocampama commented on May 24, 2024

Rahul, are these flags needed with the latest versions of bazel? AFAIK there's no way to automatically specify those flags across builds, other than documentation or bazelrc file sharing.

from rules_apple.

rahul-malik avatar rahul-malik commented on May 24, 2024

I haven’t tried to change them but I’ll update and retest

from rules_apple.

sergiocampama avatar sergiocampama commented on May 24, 2024

Is this still an issue?

from rules_apple.

rahul-malik avatar rahul-malik commented on May 24, 2024

@sergiocampama - this is no longer an issue, feel free to close

from rules_apple.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.