-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
rustc: Enable embedding LLVM bitcode for iOS #48896
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
cc @comex, @michaeleiselsc, y'all may want to double check me on this! |
Some helpful links thanks to @comex
|
i'm still not sure if we want to always have bitcode on, i think it may cause binary bloat for internal distributions, @comex do you know? |
db9d67e
to
d2855b0
Compare
Well, I don't know of anything that would normally strip it out. (In particular, I'm building this PR locally and will at least do a basic test of whether I can build a Rust static library and link it into an iOS app with bitcode enabled, without the linker complaining about missing bitcode objects. That wouldn't guarantee that the bitcode is actually reasonable: in particular, rustc currently defaults to building against LLVM 6, while the latest Xcode is based on LLVM 5, and I have no idea what Apple's servers are running. But it's a start. |
a few more questions:
|
@comex thanks for testing! @michaeleiselsc I'm not so sure myself, I'm relying on y'all for guidance on what you need from rustc :( |
I tried to test it but ran into some issues with the standard library build - in particular, #48906, which I just filed, combined with an odd bug where |
It feels like there are a lot of potential issues with always generating bitcode, so although I can take a look at them, I feel like we should provide an option not to emit bitcode. In fact, because bitcode in Xcode is off by default IIRC, perhaps we should make the default be not to generate bitcode and just provide this as an option |
☔ The latest upstream changes (presumably #48549) made this pull request unmergeable. Please resolve the merge conflicts. |
Okay, I figured out what's going on.
For now, as a workaround for the LLVM bug, I think the best approach is to avoid Also, I agree with @michaeleiselsc that there should be an option to control the behavior. |
d2855b0
to
b9120a9
Compare
Thanks for the investigation @comex! I've updated to fix those various rustbuild issues you pointed out and went ahead and disabled this by default for iOS. It can be enabled with |
b9120a9
to
d9f6aeb
Compare
Ping me when this is ready for review. |
* Pass `opt_level(2)` when calculating CFLAGS to get the right flags on iOS * Unconditionally pass `-O2` when compiling libbacktrace This should... Close rust-lang#48903 Close rust-lang#48906
d9f6aeb
to
b284fba
Compare
This commit updates rustc to embed bitcode in each object file generated by default when compiling for iOS. This was determined in rust-lang#35968 as a step towards better compatibility with the iOS toolchain, so let's give it a spin and see how it turns out! Note that this also updates the `cc` dependency which should propagate this change of embedding bitcode for C dependencies as well.
b284fba
to
0e0f74b
Compare
Ok @michaelwoerister I think this should be ready! @michaeleiselsc errors like #46447 may have been fixed by #46772, although maybe not as well |
".llvmbc\0" | ||
}; | ||
llvm::LLVMSetSection(llglobal, section.as_ptr() as *const _); | ||
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is what clang is doing?
@@ -86,6 +86,7 @@ fn main() { | |||
|
|||
fn build_libbacktrace(host: &str, target: &str) -> Result<(), ()> { | |||
let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", ".libs")?; | |||
let cflags = env::var("CFLAGS").unwrap_or_default() + " -fvisibility=hidden -O2"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to bitcode embedding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort of tangentially yeah, but it's otherwise fixing issues that @comex brought up when testing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I later saw that this is in a separate commit with proper commit message anyway. Thanks for the info!
Thanks, @alexcrichton! Looks good to me. @bors r+ |
📌 Commit 0e0f74b has been approved by |
…ster rustc: Enable embedding LLVM bitcode for iOS This commit updates rustc to embed bitcode in each object file generated by default when compiling for iOS. This was determined in #35968 as a step towards better compatibility with the iOS toolchain, so let's give it a spin and see how it turns out! Note that this also updates the `cc` dependency which should propagate this change of embedding bitcode for C dependencies as well.
☀️ Test successful - status-appveyor, status-travis |
This commit updates rustc to embed bitcode in each object file generated by
default when compiling for iOS. This was determined in #35968 as a step
towards better compatibility with the iOS toolchain, so let's give it a spin and
see how it turns out!
Note that this also updates the
cc
dependency which should propagate thischange of embedding bitcode for C dependencies as well.