-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Simplify LLVM bitcode linker in bootstrap #142357
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ use tracing::instrument; | |
|
||
pub use self::cargo::{Cargo, cargo_profile_var}; | ||
pub use crate::Compiler; | ||
use crate::core::build_steps::compile::Std; | ||
use crate::core::build_steps::{ | ||
check, clean, clippy, compile, dist, doc, gcc, install, llvm, run, setup, test, tool, vendor, | ||
}; | ||
|
@@ -1314,6 +1315,20 @@ impl<'a> Builder<'a> { | |
resolved_compiler | ||
} | ||
|
||
/// Return the lowest stage compiler that can compile code for the given `target`. | ||
pub fn compiler_for_target(&self, target: TargetSelection) -> Compiler { | ||
Comment on lines
+1318
to
+1319
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussion: maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's any requirement like this. It's really just "give me a compiler that can build code for target T". If stage0 could cross-compile for any target, we could use it for this always. We actually have a bunch of situations like this in bootstrap already, but it was always done sort of implicitly. Here I wanted to make it explicit. In other words, I think that this could be useful also for other things than just tools. But right now it's only for a single tool, ofc, so happy to rename if you want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm right. The reason I asked is that
is probably true, just that the "other things" must not use this method if they do "depend on staged compiler/std" (be it through For now, I think it's safer to name this as sth like |
||
// If we're not cross-compiling, we can always use the stage0 compiler | ||
if self.config.build == target { | ||
self.compiler(0, target) | ||
} else { | ||
// Otherwise, we have to build a stage 1 compiler that can compile code for `target`. | ||
jieyouxu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let compiler = self.compiler(1, self.config.build); | ||
// FIXME(kobzol): get rid of this nonsense and create something like `RustcWithStdForTarget` | ||
self.ensure(Std::new(compiler, target)); | ||
compiler | ||
} | ||
} | ||
|
||
pub fn sysroot(&self, compiler: Compiler) -> PathBuf { | ||
self.ensure(compile::Sysroot::new(compiler)) | ||
} | ||
|
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.
Suggestion (follow-up, not for this PR): maybe pull out a method to do the "path to sysroot target
self-contained
" logic.Uh oh!
There was an error while loading. Please reload this page.
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.
I actually had a commit for that, but it's super tricky (lol). Because:
Builder
for getting similar paths (invoked through theLibdir
step) actually delete the directory before returning it to you 🤦 I tried to use it here and it broke everything 😂 I need to clean all of this up eventually, and move the directory clearing to a single step, so that you can get a path to something without bootstrap falling over, lol.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.
Yeah, this is uhhh tricky. I'll open a issue about this follow-up (and that it's tricky).
Uh oh!
There was an error while loading. Please reload this page.
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.
#142361, not in scope for this PR (keeping this unresolved to make it easier to find).