Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bitcode for Apple platforms #7356

Closed
wants to merge 1 commit into from

Conversation

keith
Copy link
Member

@keith keith commented Feb 5, 2019

This changes the osx crosstool to support bitcode for all apple
platforms.

The behavior of bitcode is:

  • For simulators, never pass any bitcode related linker, or compiler flags
  • For devices:
    • For embedded bitcode markers
      • Pass -fembed-bitcode-marker to the compile and link commands
    • For embedded bitcode
      • Pass -fembed-bitcode to the compile and link commands
      • Pass -bitcode_verify -bitcode_hide_symbols -bitcode_symbol_map to the link command
      • Pass a output file path, wrapped in BITCODE_TOUCH_SYMBOL_MAP which is a clang wrapper workaround

With any bitcode link commands, you cannot pass -headerpad_max_install_names or you get a warning. You can see the logic for that here. To make sure that debug and release builds are as close as possible, I've disabled this flag for all builds including the simulator if bitcode is requested.

Fixes #4982

@keith
Copy link
Member Author

keith commented Feb 5, 2019

@sergiocampama @thomasvl if you could take a look that would be great!

@rajivshah3
Copy link

Related: bazelbuild/rules_apple#163

tools/osx/crosstool/CROSSTOOL.tpl Outdated Show resolved Hide resolved
tools/osx/crosstool/CROSSTOOL.tpl Outdated Show resolved Hide resolved
@keith
Copy link
Member Author

keith commented Feb 5, 2019

It also looks like after pulling this commit broke my change 71bc38f

It seems that I might have to regenerate that file

@keith
Copy link
Member Author

keith commented Feb 6, 2019

@trybka do you know if I should be editing that new file instead? I ran the migrator but it results in a significantly different file // @scentini

@scentini
Copy link
Contributor

scentini commented Feb 6, 2019

Yes, you should be editing the new file instead, sorry for the confusion, I'll go ahead and erase the CROSSTOOL files and templates now.
Let me know if you need help with converting your features to Starlark code.

@keith keith changed the title Support bitcode for iOS device targets Support bitcode for Apple platforms Feb 7, 2019
This changes the osx crosstool to support bitcode for all apple
platforms.

The behavior of bitcode is:

- For simulators, never pass any bitcode related linker, or compiler
flags
- For devices:
  - For embedded bitcode markers
    - Pass `-fembed-bitcode-marker` to the compile and link commands
  - For embedded bitcode
    - Pass `-fembed-bitcode` to the compile commands
    - Pass `-fembed-bitcode` to the link command
    - Pass `-bitcode_verify` `-bitcode_hide_symbols` `-bitcode_symbol_map` to the link command
    - Pass a output file path, wrapped in BITCODE_TOUCH_SYMBOL_MAP which is a clang wrapper workaround

With any bitcode link commands, you cannot pass
`-headerpad_max_install_names` or you get a warning. You can see the
logic for that here: https://opensource.apple.com/source/ld64/ld64-253.9/src/ld/Options.cpp.auto.html
To make sure that debug and release builds are as close as possible,
I've disabled this flag for all builds including the simulator if
bitcode is requsted.
@keith
Copy link
Member Author

keith commented Feb 7, 2019

I've updated this PR, @trybka it would be awesome if you could take another look at the logic now, @scentini if you have a minute it would be great if you could verify I followed the best practices with the new format.

Thanks!

@keith
Copy link
Member Author

keith commented Feb 8, 2019

In the meantime here's an example of a rule that can be used to propagate these linker flags correctly for multi arch binaries ios-bazel-users/ios-bazel-users#14

@keith
Copy link
Member Author

keith commented Feb 12, 2019

@trybka can you review the update?

Copy link
Contributor

@aragos aragos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get this imported.

@keith
Copy link
Member Author

keith commented Feb 13, 2019 via email

@bazel-io bazel-io closed this in f8e38d1 Feb 13, 2019
@keith keith deleted the ks/ios-bitcode branch February 13, 2019 21:48
@keith
Copy link
Member Author

keith commented Feb 13, 2019

Thanks!

@rajivshah3
Copy link

Thanks @keith !

@thii
Copy link
Member

thii commented Apr 13, 2020

Can this feature be enabled/disabled with different cpus/platforms? We're not building with bitcode, but we have a watch app and building with bitcode is mandatory for watch apps.

@rajivshah3
Copy link

#10061 might help with that, but it's not implemented yet unfortunately

@keith
Copy link
Member Author

keith commented Apr 13, 2020

In your ios_application target you might be able to do some features = ["-something"] to exclude this, although all the libraries would still be built with bitcode in that case, which may not be what you want.

@thii
Copy link
Member

thii commented Apr 13, 2020

hmm... features = ["-bitcode_embedded"] doesn't seem to remove the bitcode linker flags. Any ideas?

@keith
Copy link
Member Author

keith commented Apr 13, 2020

huh yea that's what I would have tried, I wonder if those features aren't passed through to the binaries from ios_application targets since it's a macro?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--apple_bitcode flag ineffective on iOS targets
8 participants