-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use sess.opts.optimize instead of sess.opts.cg.opt_level for LTO optlevel #22530
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
@bors r+ dc3bc90 |
Fixes rust-lang#22525 I wasn't sure if I should reuse `write::get_llvm_opt_level` or not. It returns an `llvm::CodeGenOptLevel`, which is the Rust binding for `CodeGenOpt::Level`. `lto.rs` is passing an optlevel to LLVM's `PassManagerBuilder`, which takes an unsigned int. `PassManagerBuilder`'s optlevel uses essentially the same enumeration (i.e. 0-3 with 2 as default), but it's implicit.
I have a suspicion this breaks the android build. See http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/3689 (Not yet confirmed if it really is due to this PR) |
That seems plausible. The failing test AFAICT, it seems that the Android NDK does not have |
I think @alexcrichton mentioned something about a bunch of missing symbols being hacked around on Android. I guess you should discuss with him? Yeah, it seems like LTO on Android is partially broken. I guess we could land this and put up an issue for investigating this. Not sure. |
I'm currently building Rust for Android so I can take a closer look at it. |
I'm able to build it at stage1 with no errors. I'll need to try doing it for stage2, one moment. (Moving the test from run-pass to compile-fail means that you don't need an android device to test it) |
Stage2 passes too. Hmm. (I'm only testing compilation) |
I'm able to reproduce the pthread_atfork build error on my machine now. I On Sat, Feb 21, 2015 at 2:16 PM, Manish Goregaokar <[email protected]
|
Hm, I'd included your patch too, but I might have done it wrong. Suggestions on how to proceed? |
Here's the command-line I'm using to compile the test case:
It fails with this output:
|
@bors: r- Getting this out of the queue until we solve the failure :) |
Ah, okay, I was trying to compile it a bit differently (by copying the invocation provided by compiletest and tweaking). |
I think I've figured it out.
With To help debug this issue, pass
cross-reference output:
|
I think the fix is to move
|
The Android LTO problem was already reported as #18800. We need to break out pthread_atfork from librust_builtin. Prior to finding that issue, I split it out into a "rust_android_alloc_dummy" library, which works, but it's ugly. Can we merge this PR without first fixing the Android LTO problem? This PR isn't really breaking Android LTO, it's just making the existing brokenness more obvious. |
That sounds good to me, though I'd want @dotdash or @alexcrichton to confirm if that's what we want to do. |
@@ -167,7 +167,12 @@ pub fn run(sess: &session::Session, llmod: ModuleRef, | |||
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod); | |||
llvm::LLVMRustAddPass(pm, "verify\0".as_ptr() as *const _); | |||
|
|||
let opt = sess.opts.cg.opt_level.unwrap_or(0) as libc::c_uint; | |||
let opt = match sess.opts.optimize { | |||
config::No => 0, |
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.
It looks like -Clto
without optimizations doesn't even perform dead code elimination, which makes LTO rather pointless, IMO.
Can we please make -Clto
imply -Copt-level=2
? (unless specified explicitly, of course)
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.
While perhaps not super useful, it does allow varying axes of configuration as well as perhaps a smoke test of some form. I would be ok, however, to have -Clto
switch the default optimization level as ell though.
Unfortunately this PR cannot land until all tests are passing, we won't merge in-progress patches which have known failing tests. |
@alexcrichton Apparently the Android LTO problem is basically that LTO is broken on Android -- this PR just uncovers another place where it's broken. I wouldn't call it an in-progress patch, it's more of a patch that disturbs a test in a broken area. |
That's not really the point at hand though. This test is currently running on android and passing. With this PR it looks like the test starts failing. We can't merge until that's dealt with one way or another. |
Alright. |
The old school way to address link errors like this was to list the offending input multiple times on the linker invocation. Can we do that here, get |
That makes sense. I suppose I was wondering if there were some way to disable the test for Android, because we already know that the Android-LTO combination is currently broken. |
FWIW, here's my fix for the Android-LTO issue. rprichard@9511c06. It just splits out |
It looks like it's possible to disable a test using a comment:
|
Yes adding |
Yeah, that's sort of what I meant when I said that we can merge this PR without having the test pass. Sorry if I wasn't clear :) |
⌛ Testing commit 9167c62 with merge 308b79f... |
💔 Test failed - auto-linux-32-nopt-t |
(Not a real failure, I'm trying to get eddy's UFCS patch to land first so I canceled the build. Sorry.) |
@bors: retry |
@bors: force |
@bors: retry |
@bors retry clean force |
Fixes #22525 I wasn't sure if I should reuse `write::get_llvm_opt_level` or not. It returns an `llvm::CodeGenOptLevel`, which is the Rust binding for `CodeGenOpt::Level`. `lto.rs` is passing an optlevel to LLVM's `PassManagerBuilder`, which takes an unsigned int. `PassManagerBuilder`'s optlevel uses essentially the same enumeration (i.e. 0-3 with 2 as default), but it's implicit.
Tests all passed but didn't get picked up by homu, merging manually. |
Fixes #22525
I wasn't sure if I should reuse
write::get_llvm_opt_level
or not. It returns anllvm::CodeGenOptLevel
, which is the Rust binding forCodeGenOpt::Level
.lto.rs
is passing an optlevel to LLVM'sPassManagerBuilder
, which takes an unsigned int.PassManagerBuilder
's optlevel uses essentially the same enumeration (i.e. 0-3 with 2 as default), but it's implicit.