out: PathBuf,
rust_info: channel::GitInfo,
cargo_info: channel::GitInfo,
+ rls_info: channel::GitInfo,
local_rebuild: bool,
// Probed tools at runtime
cxx: HashMap<String, gcc::Tool>,
crates: HashMap<String, Crate>,
is_sudo: bool,
+ src_is_git: bool,
}
#[derive(Debug)]
///
/// These entries currently correspond to the various output directories of the
/// build system, with each mod generating output in a different directory.
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Mode {
/// This cargo is going to build the standard library, placing output in the
/// "stageN-std" directory.
};
let rust_info = channel::GitInfo::new(&src);
let cargo_info = channel::GitInfo::new(&src.join("cargo"));
+ let rls_info = channel::GitInfo::new(&src.join("rls"));
+ let src_is_git = src.join(".git").exists();
Build {
flags: flags,
rust_info: rust_info,
cargo_info: cargo_info,
+ rls_info: rls_info,
local_rebuild: local_rebuild,
cc: HashMap::new(),
cxx: HashMap::new(),
lldb_version: None,
lldb_python_dir: None,
is_sudo: is_sudo,
+ src_is_git: src_is_git,
}
}
OutOfSync,
}
- if !self.config.submodules {
- return
- }
- if fs::metadata(self.src.join(".git")).is_err() {
+ if !self.src_is_git || !self.config.submodules {
return
}
let git = || {
// For other crates, however, we know that we've already got a standard
// library up and running, so we can use the normal compiler to compile
// build scripts in that situation.
- if let Mode::Libstd = mode {
+ if mode == Mode::Libstd {
cargo.env("RUSTC_SNAPSHOT", &self.rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
} else {
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_libdir(compiler));
}
+ // There are two invariants we try must maintain:
+ // * stable crates cannot depend on unstable crates (general Rust rule),
+ // * crates that end up in the sysroot must be unstable (rustbuild rule).
+ //
+ // In order to do enforce the latter, we pass the env var
+ // `RUSTBUILD_UNSTABLE` down the line for any crates which will end up
+ // in the sysroot. We read this in bootstrap/bin/rustc.rs and if it is
+ // set, then we pass the `rustbuild` feature to rustc when building the
+ // the crate.
+ //
+ // In turn, crates that can be used here should recognise the `rustbuild`
+ // feature and opt-in to `rustc_private`.
+ //
+ // We can't always pass `rustbuild` because crates which are outside of
+ // the comipiler, libs, and tests are stable and we don't want to make
+ // their deps unstable (since this would break the first invariant
+ // above).
+ if mode != Mode::Tool {
+ cargo.env("RUSTBUILD_UNSTABLE", "1");
+ }
+
// Ignore incremental modes except for stage0, since we're
// not guaranteeing correctness acros builds if the compiler
// is changing under your feet.`
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
}
- if self.config.rust_save_analysis && compiler.is_final_stage(self) {
+ if self.config.extended && compiler.is_final_stage(self) {
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
}
self.package_vers(channel::CFG_RELEASE_NUM)
}
+ /// Returns the value of `package_vers` above for Cargo
+ fn cargo_package_vers(&self) -> String {
+ self.package_vers(&self.release_num("cargo"))
+ }
+
/// Returns the `version` string associated with this compiler for Rust
/// itself.
///
self.rust_info.version(self, channel::CFG_RELEASE_NUM)
}
- /// Returns the `a.b.c` version that Cargo is at.
- fn cargo_release_num(&self) -> String {
+ /// Returns the `a.b.c` version that the given package is at.
+ fn release_num(&self, package: &str) -> String {
let mut toml = String::new();
- t!(t!(File::open(self.src.join("cargo/Cargo.toml"))).read_to_string(&mut toml));
+ let toml_file_name = self.src.join(&format!("{}/Cargo.toml", package));
+ t!(t!(File::open(toml_file_name)).read_to_string(&mut toml));
for line in toml.lines() {
let prefix = "version = \"";
let suffix = "\"";
}
}
- panic!("failed to find version in cargo's Cargo.toml")
+ panic!("failed to find version in {}'s Cargo.toml", package)
}
/// Returns whether unstable features should be enabled for the compiler