Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upLLVM upgrade #34743
Conversation
rust-highfive
assigned
pnkfelix
Jul 9, 2016
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (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. Due to 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 the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
|
Ah, forgot to mention that I am using a LLVM checkout of |
frewsxcv
reviewed
Jul 9, 2016
| @@ -267,7 +267,7 @@ LLVMRustAddLibraryInfo(LLVMPassManagerRef PMB, | |||
| // similar code in clang's BackendUtil.cpp file. | |||
| extern "C" void | |||
| LLVMRustRunFunctionPassManager(LLVMPassManagerRef PM, LLVMModuleRef M) { | |||
| FunctionPassManager *P = unwrap<FunctionPassManager>(PM); | |||
| llvm::legacy::FunctionPassManager *P = unwrap<llvm::legacy::FunctionPassManager>(PM); | |||
This comment has been minimized.
This comment has been minimized.
frewsxcv
Jul 9, 2016
Member
llvm::legacy::FunctionPassManager
Tangential comment to this pull request: Does anyone know what this got replaced with since it's presumably legacy now?
This comment has been minimized.
This comment has been minimized.
eefriedman
Jul 9, 2016
Contributor
LLVM pass manager infrastructure is currently getting rewritten to be more flexible. See https://github.com/llvm-mirror/llvm/blob/d1aa4ea020d932ffc6a3c3e4d1bbab659391c725/tools/opt/NewPMDriver.cpp#L50 for a usage example for the new API. That said, the rewrite isn't complete yet.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 10, 2016
Member
Looks like clang is also still using this, so we probably don't need to update just yet until they do at least.
frewsxcv
referenced this pull request
Jul 9, 2016
Closed
[MIR] Stage1 `libcore` crashes with SIGILL on ARM #34427
shepmaster
reviewed
Jul 9, 2016
| @@ -188,7 +188,7 @@ LLVMRustCreateTargetMachine(const char *triple, | |||
| } | |||
|
|
|||
| TargetOptions Options; | |||
| Options.PositionIndependentExecutable = PositionIndependentExecutable; | |||
| //Options.PositionIndependentExecutable = PositionIndependentExecutable; | |||
This comment has been minimized.
This comment has been minimized.
shepmaster
Jul 9, 2016
Member
I'm pretty sure this is a hack that only makes sense in my fork (there's no PIE for microcontrollers :-)).
Even if we wanted to remove this (doubtful), it should be removed and not commented-out. I believe that LLVM applies this flag at a more granular level now, so looking downward for another flag to apply it to seems reasonable.
This comment has been minimized.
This comment has been minimized.
badboy
Jul 9, 2016
Author
Member
Right, this is one of the things mentioned above. I left it in, so I remember to fix that.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 10, 2016
Member
This was deleted here which appears to be replaced by this which is a new setPIELevel function on the LLVM module itself.
The LLVM module isn't available at this time so we'll just have to arrange for it to be set later. Perhaps something like this though:
- Leave this block, but gated by
#if LLVM_VERSION_MINOR <= 8for compatibility with older versions. - Add
LLVMRustSetModulePIELevelas a function which is a noop on pre-LLVM-3.9 and afterwards calls thesetPIELevelfunction on the LLVM module.
This comment has been minimized.
This comment has been minimized.
badboy
Jul 11, 2016
Author
Member
Did you mean we have a LLVMRustSetModulePIELevel with the #ifdef for calling the setPIELevel method?
If so, at what point do we call it?
This comment has been minimized.
This comment has been minimized.
shepmaster
Jul 11, 2016
Member
If so, at what point do we call it?
I'd believe you want to call it every time an LLVM module is created.
shepmaster
reviewed
Jul 9, 2016
| @@ -168,7 +168,7 @@ pub fn finalize(cx: &CrateContext) { | |||
| } | |||
|
|
|||
| debug!("finalize"); | |||
| let _ = compile_unit_metadata(cx); | |||
| //let _ = compile_unit_metadata(cx); | |||
This comment has been minimized.
This comment has been minimized.
shepmaster
Jul 9, 2016
Member
Shouldn't commit commented-out code. This appears to be moved to the constructor, so I believe it's safe and correct to just remove this.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
shepmaster
Jul 11, 2016
Member
Although thinking of what @alexcrichton was saying, it might have to just be placed in an #if guard to maintain compatibility with earlier LLVM...
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 11, 2016
Member
Yeah we may want this for compatibility with older llvm versions, but I'm not sure if the fix here is backwards compatible (it may be?)
This comment has been minimized.
This comment has been minimized.
badboy
Jul 11, 2016
Author
Member
It will definitely need to change, as we changed the function.
However, the new version might even work with old LLVM, doesn't it?
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 11, 2016
Member
I think maybe yeah? I'm not actually sure what changed here, it looks like just a bit of shuffling around to me...
This comment has been minimized.
This comment has been minimized.
shepmaster
Jul 11, 2016
Member
It's indeed possible that the updated code (that creates the metadata early) will work with older LLVMs. Specifically, LLVM inverted the way the debug information graph is built. All the builders inside LLVM magically handle this, as long as there is something to add the debug information to. Creating the debug information as early as possible enables this.
shepmaster
reviewed
Jul 9, 2016
| @@ -359,7 +359,17 @@ LLVMRustAddAlwaysInlinePass(LLVMPassManagerBuilderRef PMB, bool AddLifetimes) { | |||
| extern "C" void | |||
| LLVMRustRunRestrictionPass(LLVMModuleRef M, char **symbols, size_t len) { | |||
| llvm::legacy::PassManager passes; | |||
| passes.add(llvm::createInternalizePass()); | |||
|
|
|||
| auto PreserveFunctions = [=](const GlobalValue &GV) { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
badboy
Jul 9, 2016
Author
Member
It was used in the old version, see 0763041#diff-2030f049f8df2454e3720ea9403bc14aL363.
I should have squashed that.
This comment has been minimized.
This comment has been minimized.
|
I'm no core contributor, but I don't see the value in commit X introducing less-than-great variable names and then commit X+1 improving them. I'd just squash those two together. |
This comment has been minimized.
This comment has been minimized.
|
@shepmaster yes, I should have squashed them beforehand. I can still do this. |
alexcrichton
reviewed
Jul 10, 2016
| let work_dir = &cx.sess().working_dir; | ||
| let compile_unit_name = match cx.sess().local_crate_source_file { | ||
| None => fallback_path(cx), | ||
| pub fn compile_unit_metadata(scc: &::context::SharedCrateContext, debug_context: &CrateDebugContext, sess: &::session::Session) -> DIDescriptor { |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 10, 2016
Member
Right now our line limit is 100 characters so I think this will trigger make tidy, could you also add imports instead of using absolute paths here?
alexcrichton
reviewed
Jul 10, 2016
| return false; | ||
| }; | ||
|
|
||
| passes.add(llvm::createInternalizePass(PreserveFunctions)); |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 10, 2016
Member
Can you wrap this in a #if to only execute this new part on LLVM version >= 9 and keep the old code around for 8 and below? That should help us keep compiling against older versions of LLVM.
Come to think of that, can you also ensure that the llvm::legacy:: above compiles on LLVM 3.7 and 3.8?
alexcrichton
reviewed
Jul 10, 2016
| @@ -1 +1 @@ | |||
| Subproject commit 80ad955b60b3ac02d0462a4a65fcea597d0ebfb1 | |||
| Subproject commit c90294dc24393d973ed18bbc8bc87b73cb67e484 | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 10, 2016
Member
This is currently the rust-llvm-2016-03-13 branch in the rust-lang/llvm repo, we'll want to make a new branch which points to this LLVM version and also has some of our custom patches, which includes.
I've done this at the rust-lang-2016-07-09 branch as well as including some of our own patches (mostly just related to compiling LLVM itself). Can you update this commit to that patch?
This comment has been minimized.
This comment has been minimized.
|
A failure on issue-28950 looks like it may be specific to your system or something like that, I doubt that the LLVM changes would cause it to fail. Are you sure that it succeeds before this PR on your local computer? |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Indeed, with a fresh checkout of rust-lang/rust I see the same error on issue-28950 |
This comment has been minimized.
This comment has been minimized.
|
This is supposed to fix #34119 ? |
This comment has been minimized.
This comment has been minimized.
|
@alexbool If it is fixed by something in LLVM upstream, then yes |
This comment has been minimized.
This comment has been minimized.
|
cc @kripken Here's Rust's LLVM upgrade. |
This comment has been minimized.
This comment has been minimized.
kripken
commented
Jul 11, 2016
|
@brson: cool, emscripten's merges of that same LLVM commit are in https://github.com/kripken/emscripten-fastcomp/tree/next-merge and https://github.com/kripken/emscripten-fastcomp-clang/tree/next-merge . The tracking issue is emscripten-core/emscripten#4430. Looks like only some SIMD issues block it, which probably wouldn't be a problem for rust, so it could be usable for testing already. |
This comment has been minimized.
This comment has been minimized.
|
I'd strongly encourage having links to the original LLVM issues / commits that are forcing these changes. These links should be in the commit message that modifies the relevant aspect of the code. That should make it much easier for people in the future to track down the why. |
This comment has been minimized.
This comment has been minimized.
I say this having been one of those people to track down such information in the past. |
This comment has been minimized.
This comment has been minimized.
|
@shepmaster to clarify, you mean the changes to LLVM bindings and why they're changing? (e.g. this) |
This comment has been minimized.
This comment has been minimized.
Yeah; sorry to be unclear. Having the commit message be something like
would make that commit Again, I stress that I hold no power to enforce these suggestions; I just would have found commits like this to be useful when I was digging into the existing code to make these kind of changes. |
This comment has been minimized.
This comment has been minimized.
|
Sounds like a good plan to me! |
This comment has been minimized.
This comment has been minimized.
|
I will rebase the commits and change accordingly (force-push incoming!) @shepmaster Thanks for mentioning this, it's indeed a good idea, especially in the long run |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton @eddyb Can this PR also be placed under the "Launch MIR into Orbit" milestone, since it's blocking #34119? |
alexcrichton
added this to the Launch MIR into Orbit milestone
Jul 13, 2016
This comment has been minimized.
This comment has been minimized.
|
@solson sure! |
badboy
force-pushed the
badboy:llvm-upgrade
branch
from
8e955d2
to
ffc5a86
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
I just force-pushed with the new commits
It seems something is not compiled correctly with |
This comment has been minimized.
This comment has been minimized.
|
@tmiasko That's interesting. Do you have a backtrace? We couldn't get anything, reproduction seemed to need the concurrent builds, or a specific builder, to trigger. |
This comment has been minimized.
This comment has been minimized.
|
@tmiasko did some digging and discovered that https://reviews.llvm.org/D22858 may be relevant (stack trace gathered). I've updated our LLVM submodule with this commit (rebased on the llvm/release_39 branch) and now it's rust-lang/llvm@d1cc489. @badboy wanna try updating to that and give it a go? Builds in dev are running, but we can do in parallel hopefully :) |
This comment has been minimized.
This comment has been minimized.
|
Done! Upgraded to d1cc489 |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Aug 1, 2016
This was referenced Aug 1, 2016
This comment has been minimized.
This comment has been minimized.
bors
merged commit 5d1d247
into
rust-lang:master
Aug 1, 2016
This was referenced Aug 1, 2016
This comment has been minimized.
This comment has been minimized.
|
Wuhu! |
This comment has been minimized.
This comment has been minimized.
|
Outstanding work everyone! |
This comment has been minimized.
This comment has been minimized.
|
Epic! |
This comment has been minimized.
This comment has been minimized.
|
Hurrah! Now it's time to rebase the AVR and Emscripten forks and really give it a workout ;-) |
This comment has been minimized.
This comment has been minimized.
|
@shepmaster: That's the next step and I'll try to work on it this week |
This comment has been minimized.
This comment has been minimized.
|
Heroes, every one of you! On with MIR! |
This comment has been minimized.
This comment has been minimized.
|
Looks like this missed the LLVM version check in configure, not sure why it didn't break bots:
|
This comment has been minimized.
This comment has been minimized.
|
I have a PR out for that - #35594. No idea about the bots. |
badboy commentedJul 9, 2016
•
edited
As discussed in https://internals.rust-lang.org/t/need-help-with-emscripten-port/3154/46 I'm trying to update the used LLVM checkout in Rust.
I basically took @shepmaster's code and applied it on top (though I did the commits manually, the original commits have better descriptions.
With these changes I was able to build rustc.
make checkthrows one last error onrun-pass/issue-28950.rs. Output: https://gist.github.com/badboy/bcdd3bbde260860b6159aa49070a9052I took the metadata changes as is and they seem to work, though it now uses the module in another step. I'm not sure if this is the best and correct way.
Things to do:
Makeunrelatedrun-pass/issue-28950.rspassPositionIndependentExecutablesetting is now usedllvm::legacystill the right way to do these things?cc @brson @alexcrichton