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

Rustc shim is now a wrapper #110854

Closed
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
5 changes: 5 additions & 0 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ name = "sccache-plus-cl"
path = "bin/sccache-plus-cl.rs"
test = false

[[bin]]
name = "rustc-shim"
path = "bin/rustc-shim.rs"
test = false

[dependencies]
is-terminal = "0.4"
build_helper = { path = "../tools/build_helper" }
Expand Down
10 changes: 10 additions & 0 deletions src/bootstrap/bin/rustc-shim.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
if std::env::args().any(|v| v == "-vV") {
std::process::Command::new(std::env::var("RUSTC_REAL").unwrap())
.arg("-vV")
.status()
.unwrap();
} else {
todo!("rustc-shim")
}
}
9 changes: 7 additions & 2 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Shim which is passed to Cargo as "rustc" when running the bootstrap.
//! Shim which is passed to Cargo as "RUSTC_WRAPPER" when running the bootstrap.
//!
//! This shim will take care of some various tasks that our build process
//! requires that Cargo can't quite do through normal configuration:
Expand All @@ -24,7 +24,12 @@ use std::str::FromStr;
use std::time::Instant;

fn main() {
let args = env::args_os().skip(1).collect::<Vec<_>>();
let mut args = env::args_os().skip(1).collect::<Vec<_>>();

let _compiler = args.remove(0);

let args = args;

let arg = |name| args.windows(2).find(|args| args[0] == name).and_then(|args| args[1].to_str());

// Detect whether or not we're a build script depending on whether --target
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,8 @@ impl<'a> Builder<'a> {
// Clippy support is a hack and uses the default `cargo-clippy` in path.
// Don't override RUSTC so that the `cargo-clippy` in path will be run.
if cmd != "clippy" {
cargo.env("RUSTC", self.bootstrap_out.join("rustc"));
cargo.env("RUSTC", self.bootstrap_out.join("rustc-shim"));
cargo.env("RUSTC_WRAPPER", self.bootstrap_out.join("rustc"));
}

// Dealing with rpath here is a little special, so let's go into some
Expand Down
9 changes: 6 additions & 3 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ impl Step for Cargotest {
cmd.arg(&cargo)
.arg(&out_dir)
.args(builder.config.cmd.test_args())
.env("RUSTC", builder.rustc(compiler))
.env("RUSTC", builder.bootstrap_out.join("rustc-shim"))
.env("RUSTC_WRAPPER", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler)),
);
}
Expand Down Expand Up @@ -1094,7 +1095,8 @@ impl Step for RustdocGUI {
.arg(&out_dir)
.env("RUSTC_BOOTSTRAP", "1")
.env("RUSTDOC", builder.rustdoc(self.compiler))
.env("RUSTC", builder.rustc(self.compiler))
.env("RUSTC", builder.bootstrap_out.join("rustc-shim"))
.env("RUSTC_WRAPPER", builder.rustc(self.compiler))
.current_dir(path);
// FIXME: implement a `// compile-flags` command or similar
// instead of hard-coding this test
Expand Down Expand Up @@ -2796,7 +2798,8 @@ impl Step for RustInstaller {
cmd.current_dir(&tmpdir);
cmd.env("CARGO_TARGET_DIR", tmpdir.join("cargo-target"));
cmd.env("CARGO", &builder.initial_cargo);
cmd.env("RUSTC", &builder.initial_rustc);
cmd.env("RUSTC", &builder.bootstrap_out.join("rustc-shim"));
cmd.env("RUSTC_WRAPPER", &builder.initial_rustc);
cmd.env("TMP_DIR", &tmpdir);
try_run(builder, &mut cmd);
}
Expand Down