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

Bootstrap command refactoring: quality-of-life improvements (step 4) #127321

Merged
merged 3 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ macro_rules! clean_crate_tree {

// NOTE: doesn't use `run_cargo` because we don't want to save a stamp file,
// and doesn't use `stream_cargo` to avoid passing `--message-format` which `clean` doesn't accept.
builder.run(cargo);
cargo.run(builder);
}
}
)+ }
Expand Down
30 changes: 14 additions & 16 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::core::builder::crate_description;
use crate::core::builder::Cargo;
use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
use crate::utils::exec::BootstrapCommand;
use crate::utils::exec::command;
use crate::utils::helpers::{
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
};
Expand Down Expand Up @@ -773,20 +773,19 @@ impl Step for StartupObjects {
let src_file = &src_dir.join(file.to_string() + ".rs");
let dst_file = &dst_dir.join(file.to_string() + ".o");
if !up_to_date(src_file, dst_file) {
let mut cmd = BootstrapCommand::new(&builder.initial_rustc);
let mut cmd = command(&builder.initial_rustc);
cmd.env("RUSTC_BOOTSTRAP", "1");
if !builder.local_rebuild {
// a local_rebuild compiler already has stage1 features
cmd.arg("--cfg").arg("bootstrap");
}
builder.run(
cmd.arg("--target")
.arg(target.rustc_target_arg())
.arg("--emit=obj")
.arg("-o")
.arg(dst_file)
.arg(src_file),
);
cmd.arg("--target")
.arg(target.rustc_target_arg())
.arg("--emit=obj")
.arg("-o")
.arg(dst_file)
.arg(src_file)
.run(builder);
}

let target = sysroot_dir.join((*file).to_string() + ".o");
Expand Down Expand Up @@ -1488,10 +1487,10 @@ pub fn compiler_file(
if builder.config.dry_run() {
return PathBuf::new();
}
let mut cmd = BootstrapCommand::new(compiler);
let mut cmd = command(compiler);
cmd.args(builder.cflags(target, GitRepo::Rustc, c));
cmd.arg(format!("-print-file-name={file}"));
let out = builder.run(cmd.capture_stdout()).stdout();
let out = cmd.capture_stdout().run(builder).stdout();
PathBuf::from(out.trim())
}

Expand Down Expand Up @@ -1836,9 +1835,8 @@ impl Step for Assemble {
let llvm::LlvmResult { llvm_config, .. } =
builder.ensure(llvm::Llvm { target: target_compiler.host });
if !builder.config.dry_run() && builder.config.llvm_tools_enabled {
let llvm_bin_dir = builder
.run(BootstrapCommand::new(llvm_config).capture_stdout().arg("--bindir"))
.stdout();
let llvm_bin_dir =
command(llvm_config).capture_stdout().arg("--bindir").run(builder).stdout();
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());

// Since we've already built the LLVM tools, install them to the sysroot.
Expand Down Expand Up @@ -2163,7 +2161,7 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path)
}

let previous_mtime = FileTime::from_last_modification_time(&path.metadata().unwrap());
builder.run(BootstrapCommand::new("strip").capture().arg("--strip-debug").arg(path));
command("strip").capture().arg("--strip-debug").arg(path).run(builder);

// After running `strip`, we have to set the file modification time to what it was before,
// otherwise we risk Cargo invalidating its fingerprint and rebuilding the world next time
Expand Down
Loading
Loading