use serde::Deserialize;
+use crate::builder::crate_description;
use crate::builder::Cargo;
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::cache::{Interned, INTERNER};
}
}
-/// Return a `-p=x -p=y` string suitable for passing to a cargo invocation.
-fn build_crates_in_set(run: &RunConfig<'_>) -> Interned<Vec<String>> {
- let mut crates = Vec::new();
- for krate in &run.paths {
- let path = krate.assert_single_path();
- let crate_name = run.builder.crate_paths[&path.path];
- crates.push(format!("-p={crate_name}"));
- }
- INTERNER.intern_list(crates)
-}
-
impl Step for Std {
type Output = ();
const DEFAULT: bool = true;
// Build all crates anyway, as if they hadn't passed the other args.
let has_library =
run.paths.iter().any(|set| set.assert_single_path().path.ends_with("library"));
- let crates = if has_library { Default::default() } else { build_crates_in_set(&run) };
+ let crates = if has_library { Default::default() } else { run.cargo_crates_in_set() };
run.builder.ensure(Std {
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
target: run.target,
std_cargo(builder, target, compiler.stage, &mut cargo);
builder.info(&format!(
- "Building stage{} std artifacts ({} -> {})",
- compiler.stage, &compiler.host, target
+ "Building stage{} std artifacts ({} -> {}){}",
+ compiler.stage,
+ &compiler.host,
+ target,
+ crate_description(self.crates),
));
run_cargo(
builder,
""
};
+ let mut features = String::new();
+
+ // Cranelift doesn't support `asm`.
+ if stage != 0 && builder.config.default_codegen_backend().unwrap_or_default() == "cranelift" {
+ features += " compiler-builtins-no-asm";
+ }
+
if builder.no_std(target) == Some(true) {
- let mut features = "compiler-builtins-mem".to_string();
+ features += " compiler-builtins-mem";
if !target.starts_with("bpf") {
features.push_str(compiler_builtins_c_feature);
}
.arg("--features")
.arg(features);
} else {
- let mut features = builder.std_features(target);
+ features += &builder.std_features(target);
features.push_str(compiler_builtins_c_feature);
cargo
}
fn make_run(run: RunConfig<'_>) {
- let crates = build_crates_in_set(&run);
+ let crates = run.cargo_crates_in_set();
run.builder.ensure(Rustc {
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
target: run.target,
));
}
- // cfg(bootstrap): remove if condition once the bootstrap compiler supports dylib LTO
+ // We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
+ // and may just be a time sink.
if compiler.stage != 0 {
match builder.config.rust_lto {
RustcLto::Thin | RustcLto::Fat => {
}
builder.info(&format!(
- "Building stage{} compiler artifacts ({} -> {})",
- compiler.stage, &compiler.host, target
+ "Building stage{} compiler artifacts ({} -> {}){}",
+ compiler.stage,
+ &compiler.host,
+ target,
+ crate_description(self.crates),
));
run_cargo(
builder,
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
.env("CFG_VERSION", builder.rust_version());
- if let Some(backend) = builder.config.rust_codegen_backends.get(0) {
+ if let Some(backend) = builder.config.default_codegen_backend() {
cargo.env("CFG_DEFAULT_CODEGEN_BACKEND", backend);
}
if builder.is_rust_llvm(target) {
cargo.env("LLVM_RUSTLLVM", "1");
}
- let llvm_config = builder.ensure(native::Llvm { target });
+ let native::LlvmResult { llvm_config, .. } = builder.ensure(native::Llvm { target });
cargo.env("LLVM_CONFIG", &llvm_config);
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
cargo.env("CFG_LLVM_ROOT", s);
}
if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
- let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
+ let native::LlvmResult { llvm_config, .. } =
+ builder.ensure(native::Llvm { target: target_compiler.host });
if !builder.config.dry_run() {
- let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
+ let llvm_bin_dir = output(Command::new(llvm_config).arg("--bindir"));
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
// Since we've already built the LLVM tools, install them to the sysroot.