rustbuild: Refactor stage arguments away

The facet of a stage is rarely relevant when running a tool or building
something, it's all a question of what stage the *compiler* is built in. We've
already got a nice handy `Compiler` structure to carry this information, so
let's use it!

This refactors the signature of the `Build::cargo` function two ways:

1. The `stage` argument is removed, this was just duplicated with the `compiler`
   argument's stage field.
2. The `target` argument is now required. This was a bug where if the `--target`
   flag isn't passed then the snapshot stage0 compiler is always used, so we
   won't pick up any changes.

Much of the other changes in this commit are just propagating these decisions
outwards. For example many of the `Step` variants no longer have a stage
argument as they're baked into the compiler.
This commit is contained in:
Alex Crichton 2016-03-11 17:30:16 -08:00
parent 4a917e050d
commit 8cd1c17d90
6 changed files with 109 additions and 135 deletions

View File

@ -23,15 +23,13 @@ use build::{Build, Compiler, Mode};
/// This will build the standard library for a particular stage of the build /// This will build the standard library for a particular stage of the build
/// using the `compiler` targeting the `target` architecture. The artifacts /// using the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory. /// created will also be linked into the sysroot directory.
pub fn std<'a>(build: &'a Build, stage: u32, target: &str, pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
compiler: &Compiler<'a>) { println!("Building stage{} std artifacts ({} -> {})", compiler.stage,
let host = compiler.host; compiler.host, target);
println!("Building stage{} std artifacts ({} -> {})", stage,
host, target);
// Move compiler-rt into place as it'll be required by the compiler when // Move compiler-rt into place as it'll be required by the compiler when
// building the standard library to link the dylib of libstd // building the standard library to link the dylib of libstd
let libdir = build.sysroot_libdir(stage, &host, target); let libdir = build.sysroot_libdir(compiler, target);
let _ = fs::remove_dir_all(&libdir); let _ = fs::remove_dir_all(&libdir);
t!(fs::create_dir_all(&libdir)); t!(fs::create_dir_all(&libdir));
t!(fs::hard_link(&build.compiler_rt_built.borrow()[target], t!(fs::hard_link(&build.compiler_rt_built.borrow()[target],
@ -39,10 +37,9 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
build_startup_objects(build, target, &libdir); build_startup_objects(build, target, &libdir);
let out_dir = build.cargo_out(stage, &host, Mode::Libstd, target); let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler)); build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
let mut cargo = build.cargo(stage, compiler, Mode::Libstd, Some(target), let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
"build");
cargo.arg("--features").arg(build.std_features()) cargo.arg("--features").arg(build.std_features())
.arg("--manifest-path") .arg("--manifest-path")
.arg(build.src.join("src/rustc/std_shim/Cargo.toml")); .arg(build.src.join("src/rustc/std_shim/Cargo.toml"));
@ -59,7 +56,7 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
} }
build.run(&mut cargo); build.run(&mut cargo);
std_link(build, stage, target, compiler, host); std_link(build, target, compiler, compiler.host);
} }
/// Link all libstd rlibs/dylibs into the sysroot location. /// Link all libstd rlibs/dylibs into the sysroot location.
@ -67,12 +64,12 @@ pub fn std<'a>(build: &'a Build, stage: u32, target: &str,
/// Links those artifacts generated in the given `stage` for `target` produced /// Links those artifacts generated in the given `stage` for `target` produced
/// by `compiler` into `host`'s sysroot. /// by `compiler` into `host`'s sysroot.
pub fn std_link(build: &Build, pub fn std_link(build: &Build,
stage: u32,
target: &str, target: &str,
compiler: &Compiler, compiler: &Compiler,
host: &str) { host: &str) {
let libdir = build.sysroot_libdir(stage, host, target); let target_compiler = Compiler::new(compiler.stage, host);
let out_dir = build.cargo_out(stage, compiler.host, Mode::Libstd, target); let libdir = build.sysroot_libdir(&target_compiler, target);
let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
// If we're linking one compiler host's output into another, then we weren't // If we're linking one compiler host's output into another, then we weren't
// called from the `std` method above. In that case we clean out what's // called from the `std` method above. In that case we clean out what's
@ -85,7 +82,8 @@ pub fn std_link(build: &Build,
} }
add_to_sysroot(&out_dir, &libdir); add_to_sysroot(&out_dir, &libdir);
if target.contains("musl") && (target.contains("x86_64") || target.contains("i686")) { if target.contains("musl") &&
(target.contains("x86_64") || target.contains("i686")) {
copy_third_party_objects(build, target, &libdir); copy_third_party_objects(build, target, &libdir);
} }
} }
@ -130,17 +128,14 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
/// This will build the compiler for a particular stage of the build using /// This will build the compiler for a particular stage of the build using
/// the `compiler` targeting the `target` architecture. The artifacts /// the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory. /// created will also be linked into the sysroot directory.
pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str, pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
compiler: &Compiler<'a>) { println!("Building stage{} compiler artifacts ({} -> {})",
let host = compiler.host; compiler.stage, compiler.host, target);
println!("Building stage{} compiler artifacts ({} -> {})", stage,
host, target);
let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target); let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target)); build.clear_if_dirty(&out_dir, &libstd_shim(build, compiler, target));
let mut cargo = build.cargo(stage, compiler, Mode::Librustc, Some(target), let mut cargo = build.cargo(compiler, Mode::Librustc, target, "build");
"build");
cargo.arg("--features").arg(build.rustc_features()) cargo.arg("--features").arg(build.rustc_features())
.arg("--manifest-path") .arg("--manifest-path")
.arg(build.src.join("src/rustc/Cargo.toml")); .arg(build.src.join("src/rustc/Cargo.toml"));
@ -184,7 +179,7 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
} }
build.run(&mut cargo); build.run(&mut cargo);
rustc_link(build, stage, target, compiler, compiler.host); rustc_link(build, target, compiler, compiler.host);
} }
/// Link all librustc rlibs/dylibs into the sysroot location. /// Link all librustc rlibs/dylibs into the sysroot location.
@ -192,19 +187,19 @@ pub fn rustc<'a>(build: &'a Build, stage: u32, target: &str,
/// Links those artifacts generated in the given `stage` for `target` produced /// Links those artifacts generated in the given `stage` for `target` produced
/// by `compiler` into `host`'s sysroot. /// by `compiler` into `host`'s sysroot.
pub fn rustc_link(build: &Build, pub fn rustc_link(build: &Build,
stage: u32,
target: &str, target: &str,
compiler: &Compiler, compiler: &Compiler,
host: &str) { host: &str) {
let libdir = build.sysroot_libdir(stage, host, target); let target_compiler = Compiler::new(compiler.stage, host);
let out_dir = build.cargo_out(stage, compiler.host, Mode::Librustc, target); let libdir = build.sysroot_libdir(&target_compiler, target);
let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
add_to_sysroot(&out_dir, &libdir); add_to_sysroot(&out_dir, &libdir);
} }
/// Cargo's output path for the standard library in a given stage, compiled /// Cargo's output path for the standard library in a given stage, compiled
/// by a particular compiler for the specified target. /// by a particular compiler for the specified target.
fn libstd_shim(build: &Build, stage: u32, host: &str, target: &str) -> PathBuf { fn libstd_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
build.cargo_out(stage, host, Mode::Libstd, target).join("libstd_shim.rlib") build.cargo_out(compiler, Mode::Libstd, target).join("libstd_shim.rlib")
} }
fn compiler_file(compiler: &Path, file: &str) -> String { fn compiler_file(compiler: &Path, file: &str) -> String {
@ -219,16 +214,21 @@ fn compiler_file(compiler: &Path, file: &str) -> String {
/// compiler. /// compiler.
pub fn assemble_rustc(build: &Build, stage: u32, host: &str) { pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
assert!(stage > 0, "the stage0 compiler isn't assembled, it's downloaded"); assert!(stage > 0, "the stage0 compiler isn't assembled, it's downloaded");
// The compiler that we're assembling
let target_compiler = Compiler::new(stage, host);
// The compiler that compiled the compiler we're assembling
let build_compiler = Compiler::new(stage - 1, &build.config.build);
// Clear out old files // Clear out old files
let sysroot = build.sysroot(stage, host); let sysroot = build.sysroot(&target_compiler);
let _ = fs::remove_dir_all(&sysroot); let _ = fs::remove_dir_all(&sysroot);
t!(fs::create_dir_all(&sysroot)); t!(fs::create_dir_all(&sysroot));
// Link in all dylibs to the libdir // Link in all dylibs to the libdir
let sysroot_libdir = sysroot.join(libdir(host)); let sysroot_libdir = sysroot.join(libdir(host));
t!(fs::create_dir_all(&sysroot_libdir)); t!(fs::create_dir_all(&sysroot_libdir));
let src_libdir = build.sysroot_libdir(stage - 1, &build.config.build, host); let src_libdir = build.sysroot_libdir(&build_compiler, host);
for f in t!(fs::read_dir(&src_libdir)).map(|f| t!(f)) { for f in t!(fs::read_dir(&src_libdir)).map(|f| t!(f)) {
let filename = f.file_name().into_string().unwrap(); let filename = f.file_name().into_string().unwrap();
if is_dylib(&filename) { if is_dylib(&filename) {
@ -236,8 +236,7 @@ pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
} }
} }
let out_dir = build.cargo_out(stage - 1, &build.config.build, let out_dir = build.cargo_out(&build_compiler, Mode::Librustc, host);
Mode::Librustc, host);
// Link the compiler binary itself into place // Link the compiler binary itself into place
let rustc = out_dir.join(exe("rustc", host)); let rustc = out_dir.join(exe("rustc", host));
@ -315,7 +314,7 @@ pub fn tool(build: &Build, stage: u32, host: &str, tool: &str) {
// let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target); // let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target);
// build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target)); // build.clear_if_dirty(&out_dir, &libstd_shim(build, stage, &host, target));
let mut cargo = build.cargo(stage, &compiler, Mode::Tool, None, "build"); let mut cargo = build.cargo(&compiler, Mode::Tool, host, "build");
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool))); .arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool)));
build.run(&mut cargo); build.run(&mut cargo);

View File

@ -81,6 +81,7 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
} }
let mut cmd = Command::new(&rustdoc); let mut cmd = Command::new(&rustdoc);
build.add_rustc_lib_path(&compiler, &mut cmd);
cmd.arg("--html-after-content").arg(&footer) cmd.arg("--html-after-content").arg(&footer)
.arg("--html-before-content").arg(&version_info) .arg("--html-before-content").arg(&version_info)
.arg("--html-in-header").arg(&favicon) .arg("--html-in-header").arg(&favicon)
@ -107,14 +108,13 @@ pub fn standalone(build: &Build, stage: u32, host: &str, out: &Path) {
pub fn std(build: &Build, stage: u32, host: &str, out: &Path) { pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} std ({})", stage, host); println!("Documenting stage{} std ({})", stage, host);
let compiler = Compiler::new(stage, host); let compiler = Compiler::new(stage, host);
let out_dir = build.stage_out(stage, host, Mode::Libstd) let out_dir = build.stage_out(&compiler, Mode::Libstd)
.join(host).join("doc"); .join(host).join("doc");
let rustdoc = build.rustdoc(&compiler); let rustdoc = build.rustdoc(&compiler);
build.clear_if_dirty(&out_dir, &rustdoc); build.clear_if_dirty(&out_dir, &rustdoc);
let mut cargo = build.cargo(stage, &compiler, Mode::Libstd, Some(host), let mut cargo = build.cargo(&compiler, Mode::Libstd, host, "doc");
"doc");
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/std_shim/Cargo.toml")) .arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
.arg("--features").arg(build.std_features()); .arg("--features").arg(build.std_features());
@ -125,14 +125,13 @@ pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) { pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
println!("Documenting stage{} compiler ({})", stage, host); println!("Documenting stage{} compiler ({})", stage, host);
let compiler = Compiler::new(stage, host); let compiler = Compiler::new(stage, host);
let out_dir = build.stage_out(stage, host, Mode::Librustc) let out_dir = build.stage_out(&compiler, Mode::Librustc)
.join(host).join("doc"); .join(host).join("doc");
let rustdoc = build.rustdoc(&compiler); let rustdoc = build.rustdoc(&compiler);
if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) { if !up_to_date(&rustdoc, &out_dir.join("rustc/index.html")) {
t!(fs::remove_dir_all(&out_dir)); t!(fs::remove_dir_all(&out_dir));
} }
let mut cargo = build.cargo(stage, &compiler, Mode::Librustc, Some(host), let mut cargo = build.cargo(&compiler, Mode::Librustc, host, "doc");
"doc");
cargo.arg("--manifest-path") cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/Cargo.toml")) .arg(build.src.join("src/rustc/Cargo.toml"))
.arg("--features").arg(build.rustc_features()); .arg("--features").arg(build.rustc_features());

View File

@ -152,19 +152,17 @@ impl Build {
CompilerRt { _dummy } => { CompilerRt { _dummy } => {
native::compiler_rt(self, target.target); native::compiler_rt(self, target.target);
} }
Libstd { stage, compiler } => { Libstd { compiler } => {
compile::std(self, stage, target.target, &compiler); compile::std(self, target.target, &compiler);
} }
Librustc { stage, compiler } => { Librustc { compiler } => {
compile::rustc(self, stage, target.target, &compiler); compile::rustc(self, target.target, &compiler);
} }
LibstdLink { stage, compiler, host } => { LibstdLink { compiler, host } => {
compile::std_link(self, stage, target.target, compile::std_link(self, target.target, &compiler, host);
&compiler, host);
} }
LibrustcLink { stage, compiler, host } => { LibrustcLink { compiler, host } => {
compile::rustc_link(self, stage, target.target, compile::rustc_link(self, target.target, &compiler, host);
&compiler, host);
} }
Rustc { stage: 0 } => { Rustc { stage: 0 } => {
// nothing to do... // nothing to do...
@ -261,58 +259,52 @@ impl Build {
/// This will create a `Command` that represents a pending execution of /// This will create a `Command` that represents a pending execution of
/// Cargo for the specified stage, whether or not the standard library is /// Cargo for the specified stage, whether or not the standard library is
/// being built, and using the specified compiler targeting `target`. /// being built, and using the specified compiler targeting `target`.
// FIXME: aren't stage/compiler duplicated?
fn cargo(&self, fn cargo(&self,
stage: u32,
compiler: &Compiler, compiler: &Compiler,
mode: Mode, mode: Mode,
target: Option<&str>, target: &str,
cmd: &str) -> Command { cmd: &str) -> Command {
let mut cargo = Command::new(&self.cargo); let mut cargo = Command::new(&self.cargo);
let host = compiler.host; let out_dir = self.stage_out(compiler, mode);
let out_dir = self.stage_out(stage, host, mode);
cargo.env("CARGO_TARGET_DIR", out_dir) cargo.env("CARGO_TARGET_DIR", out_dir)
.arg(cmd) .arg(cmd)
.arg("-j").arg(self.jobs().to_string()); .arg("-j").arg(self.jobs().to_string())
.arg("--target").arg(target);
// Customize the compiler we're running. Specify the compiler to cargo // Customize the compiler we're running. Specify the compiler to cargo
// as our shim and then pass it some various options used to configure // as our shim and then pass it some various options used to configure
// how the actual compiler itself is called. // how the actual compiler itself is called.
cargo.env("RUSTC", self.out.join("bootstrap/debug/rustc")) cargo.env("RUSTC", self.out.join("bootstrap/debug/rustc"))
.env("RUSTC_REAL", self.compiler_path(compiler)) .env("RUSTC_REAL", self.compiler_path(compiler))
.env("RUSTC_STAGE", self.stage_arg(stage, compiler).to_string()) .env("RUSTC_STAGE", compiler.stage.to_string())
.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()) .env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string())
.env("RUSTC_CODEGEN_UNITS", .env("RUSTC_CODEGEN_UNITS",
self.config.rust_codegen_units.to_string()) self.config.rust_codegen_units.to_string())
.env("RUSTC_DEBUG_ASSERTIONS", .env("RUSTC_DEBUG_ASSERTIONS",
self.config.rust_debug_assertions.to_string()) self.config.rust_debug_assertions.to_string())
.env("RUSTC_SNAPSHOT", &self.rustc) .env("RUSTC_SNAPSHOT", &self.rustc)
.env("RUSTC_SYSROOT", self.sysroot(stage, host)) .env("RUSTC_SYSROOT", self.sysroot(compiler))
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()) .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir())
.env("RUSTC_RPATH", self.config.rust_rpath.to_string()) .env("RUSTC_RPATH", self.config.rust_rpath.to_string())
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc")) .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
.env("RUSTDOC_REAL", self.rustdoc(compiler)); .env("RUSTDOC_REAL", self.rustdoc(compiler))
.env("RUSTC_FLAGS", self.rustc_flags(target).join(" "));
if let Some(target) = target { // Specify some various options for build scripts used throughout
cargo.env("RUSTC_FLAGS", self.rustc_flags(target).join(" ")); // the build.
cargo.arg("--target").arg(target); //
// FIXME: the guard against msvc shouldn't need to be here
// Specify some various options for build scripts used throughout if !target.contains("msvc") {
// the build. cargo.env(format!("CC_{}", target), self.cc(target))
// .env(format!("AR_{}", target), self.ar(target))
// FIXME: the guard against msvc shouldn't need to be here .env(format!("CFLAGS_{}", target), self.cflags(target));
if !target.contains("msvc") {
cargo.env(format!("CC_{}", target), self.cc(target))
.env(format!("AR_{}", target), self.ar(target))
.env(format!("CFLAGS_{}", target), self.cflags(target));
}
// Environment variables *required* needed throughout the build
//
// FIXME: should update code to not require this env vars
cargo.env("CFG_COMPILER_HOST_TRIPLE", target);
} }
// Environment variables *required* needed throughout the build
//
// FIXME: should update code to not require this env vars
cargo.env("CFG_COMPILER_HOST_TRIPLE", target);
if self.config.verbose || self.flags.verbose { if self.config.verbose || self.flags.verbose {
cargo.arg("-v"); cargo.arg("-v");
} }
@ -328,50 +320,37 @@ impl Build {
if compiler.is_snapshot(self) { if compiler.is_snapshot(self) {
self.rustc.clone() self.rustc.clone()
} else { } else {
self.sysroot(compiler.stage, compiler.host).join("bin") self.sysroot(compiler).join("bin").join(exe("rustc", compiler.host))
.join(exe("rustc", compiler.host))
} }
} }
/// Get the specified tool built by the specified compiler /// Get the specified tool built by the specified compiler
fn tool(&self, compiler: &Compiler, tool: &str) -> PathBuf { fn tool(&self, compiler: &Compiler, tool: &str) -> PathBuf {
self.stage_out(compiler.stage, compiler.host, Mode::Tool) self.cargo_out(compiler, Mode::Tool, compiler.host)
.join(self.cargo_dir())
.join(exe(tool, compiler.host)) .join(exe(tool, compiler.host))
} }
/// Get the `rustdoc` executable next to the specified compiler /// Get the `rustdoc` executable next to the specified compiler
fn rustdoc(&self, compiler: &Compiler) -> PathBuf { fn rustdoc(&self, compiler: &Compiler) -> PathBuf {
let root = if compiler.is_snapshot(self) { let mut rustdoc = self.compiler_path(compiler);
let mut rustdoc = self.rustc.clone(); rustdoc.pop();
rustdoc.pop(); rustdoc.push(exe("rustdoc", compiler.host));
rustdoc return rustdoc
} else {
let (stage, host) = (compiler.stage, compiler.host);
self.cargo_out(stage - 1, host, Mode::Librustc, host)
};
root.join(exe("rustdoc", compiler.host))
} }
/// Get a `Command` which is ready to run `tool` in `stage` built for /// Get a `Command` which is ready to run `tool` in `stage` built for
/// `host`. /// `host`.
#[allow(dead_code)] // this will be used soon
fn tool_cmd(&self, compiler: &Compiler, tool: &str) -> Command { fn tool_cmd(&self, compiler: &Compiler, tool: &str) -> Command {
let mut cmd = Command::new(self.tool(&compiler, tool)); let mut cmd = Command::new(self.tool(&compiler, tool));
let host = compiler.host; let host = compiler.host;
let stage = compiler.stage;
let paths = vec![ let paths = vec![
self.cargo_out(stage, host, Mode::Libstd, host).join("deps"), self.cargo_out(compiler, Mode::Libstd, host).join("deps"),
self.cargo_out(stage, host, Mode::Librustc, host).join("deps"), self.cargo_out(compiler, Mode::Librustc, host).join("deps"),
]; ];
add_lib_path(paths, &mut cmd); add_lib_path(paths, &mut cmd);
return cmd return cmd
} }
fn stage_arg(&self, stage: u32, compiler: &Compiler) -> u32 {
if stage == 0 && compiler.host != self.config.build {1} else {stage}
}
/// Get the space-separated set of activated features for the standard /// Get the space-separated set of activated features for the standard
/// library. /// library.
fn std_features(&self) -> String { fn std_features(&self) -> String {
@ -400,16 +379,16 @@ impl Build {
if self.config.rust_optimize {"release"} else {"debug"} if self.config.rust_optimize {"release"} else {"debug"}
} }
fn sysroot(&self, stage: u32, host: &str) -> PathBuf { fn sysroot(&self, compiler: &Compiler) -> PathBuf {
if stage == 0 { if compiler.stage == 0 {
self.stage_out(stage, host, Mode::Librustc) self.out.join(compiler.host).join("stage0-sysroot")
} else { } else {
self.out.join(host).join(format!("stage{}", stage)) self.out.join(compiler.host).join(format!("stage{}", compiler.stage))
} }
} }
fn sysroot_libdir(&self, stage: u32, host: &str, target: &str) -> PathBuf { fn sysroot_libdir(&self, compiler: &Compiler, target: &str) -> PathBuf {
self.sysroot(stage, host).join("lib").join("rustlib") self.sysroot(compiler).join("lib").join("rustlib")
.join(target).join("lib") .join(target).join("lib")
} }
@ -417,20 +396,23 @@ impl Build {
/// stage when running with a particular host compiler. /// stage when running with a particular host compiler.
/// ///
/// The mode indicates what the root directory is for. /// The mode indicates what the root directory is for.
fn stage_out(&self, stage: u32, host: &str, mode: Mode) -> PathBuf { fn stage_out(&self, compiler: &Compiler, mode: Mode) -> PathBuf {
let suffix = match mode { let suffix = match mode {
Mode::Libstd => "-std", Mode::Libstd => "-std",
_ => "-rustc", _ => "-rustc",
}; };
self.out.join(host).join(format!("stage{}{}", stage, suffix)) self.out.join(compiler.host)
.join(format!("stage{}{}", compiler.stage, suffix))
} }
/// Returns the root output directory for all Cargo output in a given stage, /// Returns the root output directory for all Cargo output in a given stage,
/// running a particular comipler, wehther or not we're building the /// running a particular comipler, wehther or not we're building the
/// standard library, and targeting the specified architecture. /// standard library, and targeting the specified architecture.
fn cargo_out(&self, stage: u32, host: &str, mode: Mode, fn cargo_out(&self,
compiler: &Compiler,
mode: Mode,
target: &str) -> PathBuf { target: &str) -> PathBuf {
self.stage_out(stage, host, mode).join(target).join(self.cargo_dir()) self.stage_out(compiler, mode).join(target).join(self.cargo_dir())
} }
/// Root output directory for LLVM compiled for `target` /// Root output directory for LLVM compiled for `target`
@ -456,8 +438,7 @@ impl Build {
if compiler.is_snapshot(self) { if compiler.is_snapshot(self) {
self.rustc_snapshot_libdir() self.rustc_snapshot_libdir()
} else { } else {
self.sysroot(compiler.stage, compiler.host) self.sysroot(compiler).join(libdir(compiler.host))
.join(libdir(compiler.host))
} }
} }

View File

@ -29,18 +29,16 @@ macro_rules! targets {
// and one for the compiler itself. These are parameterized over the // and one for the compiler itself. These are parameterized over the
// stage output they're going to be placed in along with the // stage output they're going to be placed in along with the
// compiler which is producing the copy of libstd or librustc // compiler which is producing the copy of libstd or librustc
(libstd, Libstd { stage: u32, compiler: Compiler<'a> }), (libstd, Libstd { compiler: Compiler<'a> }),
(librustc, Librustc { stage: u32, compiler: Compiler<'a> }), (librustc, Librustc { compiler: Compiler<'a> }),
// Links the standard library/librustc produced by the compiler // Links the standard library/librustc produced by the compiler
// provided into the host's directory also provided. // provided into the host's directory also provided.
(libstd_link, LibstdLink { (libstd_link, LibstdLink {
stage: u32,
compiler: Compiler<'a>, compiler: Compiler<'a>,
host: &'a str host: &'a str
}), }),
(librustc_link, LibrustcLink { (librustc_link, LibrustcLink {
stage: u32,
compiler: Compiler<'a>, compiler: Compiler<'a>,
host: &'a str host: &'a str
}), }),
@ -144,10 +142,9 @@ fn top_level(build: &Build) -> Vec<Step> {
} }
let host = t.target(host); let host = t.target(host);
if host.target == build.config.build { if host.target == build.config.build {
targets.push(host.librustc(stage, host.compiler(stage))); targets.push(host.librustc(host.compiler(stage)));
} else { } else {
targets.push(host.librustc_link(stage, t.compiler(stage), targets.push(host.librustc_link(t.compiler(stage), host.target));
host.target));
} }
for target in build.config.target.iter() { for target in build.config.target.iter() {
if !build.flags.target.contains(target) { if !build.flags.target.contains(target) {
@ -156,11 +153,10 @@ fn top_level(build: &Build) -> Vec<Step> {
if host.target == build.config.build { if host.target == build.config.build {
targets.push(host.target(target) targets.push(host.target(target)
.libstd(stage, host.compiler(stage))); .libstd(host.compiler(stage)));
} else { } else {
targets.push(host.target(target) targets.push(host.target(target)
.libstd_link(stage, t.compiler(stage), .libstd_link(t.compiler(stage), host.target));
host.target));
} }
} }
} }
@ -238,29 +234,29 @@ impl<'a> Step<'a> {
} }
Source::Rustc { stage } => { Source::Rustc { stage } => {
let compiler = Compiler::new(stage - 1, &build.config.build); let compiler = Compiler::new(stage - 1, &build.config.build);
vec![self.librustc(stage - 1, compiler)] vec![self.librustc(compiler)]
} }
Source::Librustc { stage, compiler } => { Source::Librustc { compiler } => {
vec![self.libstd(stage, compiler), self.llvm(())] vec![self.libstd(compiler), self.llvm(())]
} }
Source::Libstd { stage: _, compiler } => { Source::Libstd { compiler } => {
vec![self.compiler_rt(()), vec![self.compiler_rt(()),
self.rustc(compiler.stage).target(compiler.host)] self.rustc(compiler.stage).target(compiler.host)]
} }
Source::LibrustcLink { stage, compiler, host } => { Source::LibrustcLink { compiler, host } => {
vec![self.librustc(stage, compiler), vec![self.librustc(compiler),
self.libstd_link(stage, compiler, host)] self.libstd_link(compiler, host)]
} }
Source::LibstdLink { stage, compiler, host } => { Source::LibstdLink { compiler, host } => {
vec![self.libstd(stage, compiler), vec![self.libstd(compiler),
self.target(host).rustc(stage)] self.target(host).rustc(compiler.stage)]
} }
Source::CompilerRt { _dummy } => { Source::CompilerRt { _dummy } => {
vec![self.llvm(()).target(&build.config.build)] vec![self.llvm(()).target(&build.config.build)]
} }
Source::Llvm { _dummy } => Vec::new(), Source::Llvm { _dummy } => Vec::new(),
Source::DocStd { stage } => { Source::DocStd { stage } => {
vec![self.libstd(stage, self.compiler(stage))] vec![self.libstd(self.compiler(stage))]
} }
Source::DocBook { stage } | Source::DocBook { stage } |
Source::DocNomicon { stage } | Source::DocNomicon { stage } |
@ -290,11 +286,11 @@ impl<'a> Step<'a> {
} }
Source::ToolLinkchecker { stage } => { Source::ToolLinkchecker { stage } => {
vec![self.libstd(stage, self.compiler(stage))] vec![self.libstd(self.compiler(stage))]
} }
Source::ToolErrorIndex { stage } | Source::ToolErrorIndex { stage } |
Source::ToolRustbook { stage } => { Source::ToolRustbook { stage } => {
vec![self.librustc(stage, self.compiler(stage))] vec![self.librustc(self.compiler(stage))]
} }
} }
} }

View File

@ -1,2 +1,2 @@
rustc: 2016-02-17 rustc: 2016-02-17
cargo: 2016-01-21 cargo: 2016-03-11

1
src/rustc/Cargo.lock generated
View File

@ -349,7 +349,6 @@ name = "test"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"getopts 0.0.0", "getopts 0.0.0",
"serialize 0.0.0",
"term 0.0.0", "term 0.0.0",
] ]