Closed shepmaster closed 7 years ago
Next time we do this upgrade we'll need emscripten to do it to. It would be good if we could pull in a working llvm wasm backend in the same upgrade, but that may not be ready before the end of the year.
For the record, I am also working with a fork of LLVM that is tracking upstream (not AVR-LLVM but similar in spirit) and am starting to work on this now. I'm looking through the AVR-Rust commits and I'd love to coordinate --- feel free to ping me on IRC (rkruppe
) or via mail!
Note that there is a regression reported against llvm 4.0 regarding the powi intrinsic on armhf targets:
https://llvm.org/bugs/show_bug.cgi?id=30543
I'm explicitly mentioning this here, because there were previously problems with it, see #37559 and related issues. Also cc rust-lang-nursery/compiler-builtins#116, an issue about the same problem in the compiler-rt rust port.
To clarify what I think the @TimNN is referring to (correct me if I'm wrong)
So it seems that if the LLVM change is not reverted (expected powisf2 to be aapcs) then we need to update our definition.
This is going to be a huge PITA for supporting multiple LLVM versions as well. We need to select the calling convention depending on the LLVM version as well...
and I'd love to coordinate
@rkruppe Any objections to doing that coordination here on GitHub, or on one of our forks?
I don't have strong preferences for the communication channel.
"AttrBuilder
API changes" above (the core of the change is in how attributes are represented).@shepmaster I would prefer to upstream LLVM 4.0 compatibility patches sooner rather than later. That includes my own work obviously, but I'm also looking at the commits I cherry-picked from AVR-Rust. In particular, https://github.com/avr-rust/rust/commit/3e1e4a49bb89526db16151a6cdf6950a140c6415 looks like a reasonable simplification even independent of LLVM 4.0 compatibility, and https://github.com/avr-rust/rust/commit/c32f9c15d4ce3b380e58fa088c914b505e8b966e looks like a nice little self-contained fix. Could you create PRs for those? (If you don't have the time but are otherwise fine with upstreaming, I'd be happy to manage that, giving proper credit of course.)
@rkruppe Absolutely! I wasn't really sure how much we could expect LLVM 4 to change as it goes towards stable / how much churn the Rust maintainers would want to put up with. I'll get those pulled out and submitted soon. I think I'm also starting to understand some of the silly error handling that the new LLVM does.
@shepmaster Awesome, thanks in advance!
BTW the PR reference for "llvm::AttrBuilder changed API" is wrong, it points at this issue instead of #37831
Does anyone have ETA? I'd like to know when I can use AVR. :)
I'd like to know when I can use AVR. :)
@Kixunil You should follow along at avr-rust/rust#22 for the AVR-specific issues. Upgrading to LLVM 4 will not magically yield AVR support.
@shepmaster Ok, thank you!
I've created #38294 for the createBasicType
API change.
I've also created #38295 for another debug info DIBuilder
API change.
After putting all of those patches on top of master, rustllvm
was successfully built. I got several undefined references, most likely due to my local LLVM setup.
I think the next step after all those patches land is to allow LLVM 4.0 in the configure/rustbuild scripts and then actually update the submodule.
We'll also need to fix that AAPCS bug first, I just noticed it
and then actually update the submodule.
Don't forget brson's comment:
Next time we do this upgrade we'll need emscripten to do it to.
I think that means that the Rust fork of LLVM is following the Emscripten fork of LLVM, thus Emscripten needs to upgrade to LLVM 4.0 / master before Rust can.
I've created #38294 for the createBasicType API change.
And I'm hoping to supersede it with #38317 😇
I just ran into https://github.com/llvm-mirror/llvm/commit/58be60c4830ea33097d9c1d65e08029e4d5c6aad which changed the alignment from u64 to u32. Will think about a proper fix later, unless someone beats me to it (but #38295 should merge first to avoid further conflicts).
which changed the alignment from u64 to u32.
And it says
In futher patches we shall have alignment field added to DIVariable family
So, that will be "exciting".
Is there much left blocking an upgrade?
@DemiMarie
This:
Next time we do this upgrade we'll need emscripten to do it to.
Has to be done too but I don't know if it's currently being worked on. @brson Any info on that ^?
@japaric No nobody is actively working on an emscripten upgrade.
Since even when that is done it will probably take a lot of work to land an LLVM upgrade, there's probably more we can do to prepare. Once we decide we want to do it, somebody can prepare a patch to throw at the bots. It seems likely stuff will not work and it will be a slog to fix it all, which will give us time.
We don't need emcc to generate wasm stds, just a fairly small patch on our LLVM branch that will hopefully port without much difficulty.
So if somebody feels motivated, it's not too soon to start going after it.
As to the emscripten upgrade, we should at least let @kripken know that we're starting to think seriously about doing the upgrade, and need emscripten to upgrade LLVM too.
It seems like that could be a big effort. Another alternative is to use the LLVM wasm backend, but I still have not heard that it is generally usable yet.
cc @alexcrichton
I can look into the effort needed to update emscripten's fastcomp LLVM version, but I need to know a commit to aim for. Sounds like the goal here is 4.0, which hasn't released yet, so I guess I have to wait on that?
So far as AVR is concerned, any commit within the last month will do. There will likely be a few more months until 4.0 is actually tagged (every ~6 months a new release is made). It is quite common for projects to track LLVM master, which I'm personally a fan of.
But is it common to release snapshots from LLVM master? When LLVM itself only releases every 6 months, it seems incongruous for Rust to pick arbitrary snapshots in its 6-week release cycle.
LLVM 4.0 will branch in a week and the final release will happen in late feburary (schedule says 21st for final tag, but this is flexible IIRC).
From the llvm-dev mailing list:
http://lists.llvm.org/pipermail/llvm-dev/2017-January/108949.html branch has happened
An update on the "powidf2 / powisf2 calling convention changed" situation:
The regression has been fixed on llvm master (https://llvm.org/bugs/show_bug.cgi?id=30543#c13) however from what I can tell the fixes are not yet in the 4.0 branch, although the fix may be backported (https://llvm.org/bugs/show_bug.cgi?id=30543#c15).
I've started working on updating emscripten
I've also created a new bug requesting that the powidf2
regression fix be merged into 4.0 here.
@kripken says the emcc LLVM upgrade is ready to go. @shepmaster or @rkruppe are we prepared to begin the Rust LLVM upgrade?
I think what needs to happen is to submit the Rust PR and start throwing it against the bots. Once it looks like that is close to landing then we'll have to coordinate both project's upgrades to minimize the breakage window where rustc and emcc have different backends. I'm not sure how best to do that - we might just try to upgrade as simultaneously as possible and accept up to a few days of breakage, or we might ask emscripten to stage their build such that they can swap their incoming branch right after we land to master.
@kripken needs to know the exact LLVM commit we're moving to as well, and that will become clear once the PR starts working through the queue.
The stars are aligning. Let's make this happen.
Thanks @dylanmckay for doing the fastcomp upgrade.
We are not fully compatible with LLVM 4.0. I have heard from at least one person (on IRC) that building against stock LLVM 4.0 (RC) does not work. I haven't personally inspected all failures, but there's at least two things still missing:
DIBuilder::createGlobalVariable
changed again I haven't digested the implications yet, but it might be a relatively simple change localized to the function in rustllvm
that currently calls createGlobalVariable
.The powidf2
fix has been merged into the 4.0 release (details).
I'm going to try and build Rust against stock LLVM 4.0 and figure out what needs modifying.
On top of what @rkruppe mentioned:
llvm::DIBuilder::createCompileUnit
now takes an llvm::DIFile*
instead of a Filename
and Directory
(D27762)I've got a half-baked patch to use the new signature for createCompileUnit
I'm not familiar enough with Rust internals to finish it off. I ran into a problem in fn compile_unit_metadata
as it is given a SharedCrateContext
but in order to use fn file_metadata
we need a CrateContext
. We need to call file_metadata
in order to build an instance of DIFile*
.
I've opened #39528 for the createGlobalVariable
change that @rkruppe mentioned.
I've also opened #39529 for the 32-bit alignment change.
I believe that createCompileUnit
is the only thing we need to update aside from these two PRs in order to get the compiler to successfully be built with LLVM 4.0.
So to summarize where we are with LLVM 4 (correct me if I'm wrong):
LLVM 4.0 will be released in about 1 week (2/21).
There are no known issues with supporting LLVM 4.0, but there are probably issues that will be discovered once we try to use it in nightlies.
Travis runs on in-tree LLVM + LLVM 3.7 (so PRs haven't actually been tested on LLVM 4.0 yet).
We support LLVM back to ~3.6(?)~ 3.7 and will continue to support it until either: a. It's so old that it can be removed without bothering package maintainers b. We need at least version X in order to fix an important bug c. The API is so different from version Y that it's a huge pain to support
Someone will open a PR to update the submodule shortly after release but it will take a month to land due to:
a. Waiting for emscripten (incoming
-> master
)
b. Bugs in upstream
c. Missed LLVM API changes
d. Making bors happy
e. All of the above
Thanks for the summary @mattico! The only correction I'd make is that in your point (4) you can s/3.6/3.7/, but otherwise it's accurate :)
If you'd like to start preparing a PR to update to LLVM 4.0 I don't think we need to block waiting for LLVM itself to release 4.0. Currently only one Travis builder runs on each PR but we could temporarily allow more builders running on an LLVM 4.0 PR to start weeding out bugs before it hits @bors.
I gave it a go but I don't think my git-fu (or patience) is strong enough to handle a big merge like this.
What I can do is try to run rustc with upstream LLVM and file/fix issues as I find them. There is at least one issue remaining as of #39747 (details to come).
Whoever ends up doing the LLVM upgrade, please also upgrade the compiler-rt submodule so that the sanitizer related LLVM passes don't diverge from what the sanitizer runtimes expect.
If you'd like to start preparing a PR to update to LLVM 4.0 I don't think we need to block waiting for LLVM itself to release 4.0.
@alexcrichton In fact, if you upgrade before the release, they usually mention your project in the release notes. :)
@shepmaster @dylanmckay So whats the next issue(s) to subscribe to in the race-to-AVR? :)
As @shepmaster says on reddit, we can integrate the latest Rust master into the avr-rust compiler. After that, we can spend some time getting libcore
compiling for AVR.
Once that is working, we could then start looking into upstreaming the AVR target to Rust.
So whats the next issue(s) to subscribe to in the race-to-AVR?
AVR-specific issues can be raised / tracked in https://github.com/avr-rust/rust
For example, there are two that I'm aware of right now:
The AVR-Rust post continues to track AVR-LLVM, which is tracking upstream LLVM. That means we are running into changes from the future LLVM 4.0. I figured we could open up this issue now to track the changes required to stay compatible.
This is the current list of upgrade hazards. Note that some of the text may be nonsensical as I don't truly grok all the internals of LLVM so some changes are wild stabs in the dark. It's also possible that some failed fix for earlier problems actually caused later problems:
AlwaysInliner
pass changed header and constructor name (#37861)createBasicType
changed API (#38317)powidf2
/powisf2
calling convention changed (LLVM 31685)llvm::AttrBuilder
changed API (#37831)DIBuilder::createNameSpace
changed API (#38000)LLVMRustPrintPasses
prefersStringRef
overchar *
(#38027)OptimizationDiagnostic
string type changes (#37982)llvm::StringRef
is not guaranteed to be null terminated (#38048)getPassName
changed return types (#38195)DIBuilder::createGlobalVariable
API changed again (#39528)llvm::DIBuilder::createCompileUnit
now takes anllvm::DIFile*
instead of aFilename
andDirectory
(#39747)repr(packed)
tests (#40373)core::panicking::panic
(#40508)A WIP PR that performs the upgrade! #40123
Some issues whose resolution is believed to be blocked on LLVM 4.0: