Skip to content
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

Allow runtime switching between trans backends #45684

Merged
merged 17 commits into from
Jan 21, 2018

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Nov 1, 2017

The driver callback after_llvm has been removed as it doesnt work with multiple backends.

r? @eddyb

@eddyb
Copy link
Member

eddyb commented Nov 1, 2017

cc @alexcrichton @rust-lang/compiler I'm not sure a flag is the right thing to use here.
Long-term, do we expect/want to have -C backend=cranelift/llvm/etc. or different drivers?

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 1, 2017

Most of the driver is the same for each backend. We could pass different compiler callbacks to rustc_driver for each backend.

@alexcrichton
Copy link
Member

This seems to add -Z trans but never uses it? How can this be implemented unless we use trait objects?

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 1, 2017

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 1, 2017
@eddyb
Copy link
Member

eddyb commented Nov 1, 2017

@bjorn3 We use "custom drivers" to refer to different binaries using rustc_driver, not replacements for rustc_driver.

type OngoingCrateTranslation;
type TranslatedCrate;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now with less object unsafe associated types 🎊

@carols10cents
Copy link
Member

What's the status of this PR @bjorn3 @alexcrichton @eddyb? I'm having a tough time telling :)

@eddyb
Copy link
Member

eddyb commented Nov 6, 2017

I'm not sure what we should do here. Nominating for discussion in the next compiler meeting.

@@ -157,10 +157,6 @@ impl LlvmTransCrate {
}

impl rustc_trans_utils::trans_crate::TransCrate for LlvmTransCrate {
type MetadataLoader = metadata::LlvmMetadataLoader;
type OngoingCrateTranslation = back::write::OngoingCrateTranslation;
type TranslatedCrate = CrateTranslation;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now with less object unsafe associated types 🎊

Edit: now completely object safe

@eddyb
Copy link
Member

eddyb commented Nov 9, 2017

@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?

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 10, 2017

Mainly refactoring, but when this is merged I want to try to add basic cranelift support.

@eddyb
Copy link
Member

eddyb commented Nov 10, 2017

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 :).

@eddyb
Copy link
Member

eddyb commented Nov 12, 2017

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Nov 12, 2017
@@ -1,87 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as it requires the now removed after_llvm callback.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?


sess.abort_if_errors();
}
// FIXME: Check if the compilation options are supported for the selected backend.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bors
Copy link
Contributor

bors commented Nov 15, 2017

☔ The latest upstream changes (presumably #45944) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -226,7 +226,7 @@ impl TransCrate for MetadataOnlyTransCrate {
};
}
fn provide_extern(&self, providers: &mut Providers) {
self.provide_local(providers)
self.provide(providers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to do anything here, this is redundant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean i should remove this line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@nikomatsakis
Copy link
Contributor

r? @eddyb -- I'm kicking this back to @eddyb =)

@bjorn3
Copy link
Member Author

bjorn3 commented Jan 20, 2018

Fixed ICE

@eddyb
Copy link
Member

eddyb commented Jan 20, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Jan 20, 2018

📌 Commit a4854e8 has been approved by eddyb

@bors
Copy link
Contributor

bors commented Jan 20, 2018

⌛ Testing commit a4854e8 with merge 9aa40b0...

bors added a commit that referenced this pull request Jan 20, 2018
Allow runtime switching between trans backends

The driver callback after_llvm has been removed as it doesnt work with multiple backends.

r? @eddyb
@bors
Copy link
Contributor

bors commented Jan 20, 2018

💔 Test failed - status-travis

@eddyb
Copy link
Member

eddyb commented Jan 20, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Jan 20, 2018

📌 Commit a30232f has been approved by eddyb

@bors
Copy link
Contributor

bors commented Jan 20, 2018

⌛ Testing commit a30232f with merge 3153d4a27cf582356da0bb5a2190c7bebd150372...

@bors
Copy link
Contributor

bors commented Jan 20, 2018

💔 Test failed - status-travis

@shepmaster
Copy link
Member

The job exceeded the maximum time limit for jobs, and has been terminated.

@bors retry

@bors
Copy link
Contributor

bors commented Jan 21, 2018

⌛ Testing commit a30232f with merge 9368a1e...

bors added a commit that referenced this pull request Jan 21, 2018
Allow runtime switching between trans backends

The driver callback after_llvm has been removed as it doesnt work with multiple backends.

r? @eddyb
@bors
Copy link
Contributor

bors commented Jan 21, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 9368a1e to master...

@bors bors merged commit a30232f into rust-lang:master Jan 21, 2018
kennytm-githubbot added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jan 21, 2018
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).
@bjorn3 bjorn3 deleted the runtime_choose_trans2 branch January 21, 2018 13:00
bors added a commit that referenced this pull request Jan 28, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.