Allow runtime switching between trans backends#45684
Conversation
|
cc @alexcrichton @rust-lang/compiler I'm not sure a flag is the right thing to use here. |
|
Most of the driver is the same for each backend. We could pass different compiler callbacks to rustc_driver for each backend. |
|
This seems to add |
|
@bjorn3 We use "custom drivers" to refer to different binaries using |
There was a problem hiding this comment.
Now with less object unsafe associated types 🎊
|
What's the status of this PR @bjorn3 @alexcrichton @eddyb? I'm having a tough time telling :) |
|
I'm not sure what we should do here. Nominating for discussion in the next compiler meeting. |
src/librustc_trans/lib.rs
Outdated
There was a problem hiding this comment.
Now with less object unsafe associated types 🎊
Edit: now completely object safe
|
@bjorn3 Out of curiosity, do you have some specific motivation/need behind this PR, or is it intended as a general refactoring towards supporting multiple backends? |
|
Mainly refactoring, but when this is merged I want to try to add basic cranelift support. |
|
I'd suggest more coordination between you, @sunfishcode and me, and the compiler team in general. Just to avoid stepping on eachother's toes, as we are all interested in this goal :). |
eae208e to
fd38507
Compare
src/test/run-make/llvm-phase/test.rs
Outdated
There was a problem hiding this comment.
Removed as it requires the now removed after_llvm callback.
nikomatsakis
left a comment
There was a problem hiding this comment.
So, eddyb kicked this to me, but I actually don't know that I'm the right person to do a detailed review here. I mean I could, but I think that @eddyb and perhaps @michaelwoerister have stronger opinions about how this should be internally architected. @bjorn3 can you and @eddyb sync up at some point and talk it over?
src/librustc_driver/driver.rs
Outdated
There was a problem hiding this comment.
This seems like an important thing to get right before we land, no? Although I guess it's only a warning, not an error, but I wouldn't want to silently be accepting bad things.
|
☔ The latest upstream changes (presumably #45944) made this pull request unmergeable. Please resolve the merge conflicts. |
831a965 to
b3a986a
Compare
There was a problem hiding this comment.
You shouldn't need to do anything here, this is redundant.
There was a problem hiding this comment.
You mean i should remove this line?
|
Fixed ICE |
|
@bors r+ |
|
📌 Commit a4854e8 has been approved by |
Allow runtime switching between trans backends The driver callback after_llvm has been removed as it doesnt work with multiple backends. r? @eddyb
|
💔 Test failed - status-travis |
fb976fb to
a30232f
Compare
|
@bors r+ |
|
📌 Commit a30232f has been approved by |
|
⌛ Testing commit a30232f with merge 3153d4a27cf582356da0bb5a2190c7bebd150372... |
|
💔 Test failed - status-travis |
@bors retry |
Allow runtime switching between trans backends The driver callback after_llvm has been removed as it doesnt work with multiple backends. r? @eddyb
|
☀️ Test successful - status-appveyor, status-travis |
Tested on commit rust-lang/rust@9368a1e. 💔 rls on windows: test-pass → build-fail (cc @nrc). 💔 rls on linux: test-pass → build-fail (cc @nrc).
rustc: Load the `rustc_trans` crate at runtime Building on the work of #45684 this commit updates the compiler to unconditionally load the `rustc_trans` crate at runtime instead of linking to it at compile time. The end goal of this work is to implement #46819 where rustc will have multiple backends available to it to load. This commit starts off by removing the `extern crate rustc_trans` from the driver. This involved moving some miscellaneous functionality into the `TransCrate` trait and also required an implementation of how to locate and load the trans backend. This ended up being a little tricky because the sysroot isn't always the right location (for example `--sysroot` arguments) so some extra code was added as well to probe a directory relative to the current dll (the rustc_driver dll). Rustbuild has been updated accordingly as well to have a separate compilation invocation for the `rustc_trans` crate and assembly it accordingly into the sysroot. Finally, the distribution logic for the `rustc` package was also updated to slurp up the trans backends folder. A number of assorted fallout changes were included here as well to ensure tests pass and such, and they should all be commented inline.
The driver callback after_llvm has been removed as it doesnt work with multiple backends.
r? @eddyb