rules_apple
rules_apple copied to clipboard
Clashing Options in Apple Bitcode Bundle on macOS
Hi wonderful Bazel folks,
I'd noticed that if you try to build a macos_bundle with bitcode enabled (--apple_bitcode=embedded), the options clash with the following error: ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
Looks like the -bundle option is set in AppleBinary.java. Perhaps a good fix would be to not just set the option if --apple_bitcode is also enabled?
Thanks so much, Chris
Assigning to @allevato because he has recently been working in this area and probably knows what the best path is here.
The crux of the issue here is that -bundle
is set by Bazel (inside AppleBinary.java
, based on the binary_type
attribute) whereas the Bitcode flags are set via crosstool features, much deeper in the linking action setup, so the two things aren't aware of each other.
The right way to fix this would be to move the application of -bundle
into a new crosstool feature, have AppleBinary.java
enable that feature instead of setting the flag directly, and then have the crosstool feature algebra configured such that the Bitcode features aren't applied if the bundle feature is enabled.
@allevato So how should we prioritize this?
@cpsauer Do you need to build any other macOS targets with Bitcode enabled? We recently added a platform-specific filter to --apple_bitcode
so if not, you could use --apple_bitcode=embedded --apple_bitcode=macos=none
to turn on Bitcode for all platforms except macOS to workaround the issue.
FYI this is a very long standing bug, I remember this back in the 0.*
days
Thanks so much for replying back, all of you!
@allevato, I hadn't seen the new filter. That's a great workaround idea for the bug (I can also fall back to specifying flags for each target as needed.)
Obviously the prioritization up to you guys, not me. But if I were to allocate urgency across the bugs I've seen/filed, there are definitely ones that are more burningly problematic and hard to work around than this one. Nonetheless it seemed like it was definitely a bug that kills a valid use case, so I thought I should report it.