Skip to content

Support bitcode for Apple platforms - #7356

Closed
keith wants to merge 1 commit into
bazelbuild:masterfrom
keith:ks/ios-bitcode
Closed

keith wants to merge 1 commit into
bazelbuild:masterfrom
keith:ks/ios-bitcode

Conversation

@keith

@keith keith commented Feb 5, 2019 •

Copy link
Copy Markdown
Member

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

keith commented Feb 5, 2019

Copy link
Copy Markdown
Member Author

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

@rajivshah3

Copy link
Copy Markdown

Related: bazelbuild/rules_apple#163

Comment thread tools/osx/crosstool/CROSSTOOL.tpl Resolved
Comment thread tools/osx/crosstool/CROSSTOOL.tpl Resolved
@keith

keith commented Feb 5, 2019 •

Copy link
Copy Markdown
Member Author

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

It seems that I might have to regenerate that file

@keith

keith commented Feb 6, 2019

Copy link
Copy Markdown
Member Author

@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

scentini commented Feb 6, 2019

Copy link
Copy Markdown
Contributor

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

keith commented Feb 7, 2019

Copy link
Copy Markdown
Member Author

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

keith commented Feb 8, 2019

Copy link
Copy Markdown
Member Author

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

keith commented Feb 12, 2019

Copy link
Copy Markdown
Member Author

@trybka can you review the update?

@aragos aragos left a comment

Copy link
Copy Markdown
Contributor

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

keith commented Feb 13, 2019 via email

Copy link
Copy Markdown
Member Author

@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

keith commented Feb 13, 2019

Copy link
Copy Markdown
Member Author

Thanks!

@rajivshah3

Copy link
Copy Markdown

Thanks @keith !

@thii

thii commented Apr 13, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown

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

@keith

keith commented Apr 13, 2020

Copy link
Copy Markdown
Member Author

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

thii commented Apr 13, 2020

Copy link
Copy Markdown
Member

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

@keith

keith commented Apr 13, 2020 •

Copy link
Copy Markdown
Member Author

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