From 95ba704b5cca927dad26b5dcfcf4e5133f79eaac Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Wed, 26 Apr 2023 16:59:22 +0000 Subject: [PATCH 1/3] Rustc shim is now a wrapper This is preparatory work to make clippy work in the repo. This changes the rustc shim in bootstrap to be RUSTC_WRAPPER, instead of RUSTC. --- src/bootstrap/bin/rustc.rs | 7 ++++++- src/bootstrap/builder.rs | 2 +- src/bootstrap/test.rs | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index dd86634b47c83..3ffb48cd9b717 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -24,7 +24,12 @@ use std::str::FromStr; use std::time::Instant; fn main() { - let args = env::args_os().skip(1).collect::>(); + let mut args = env::args_os().skip(1).collect::>(); + + 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 diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0d2d512b4b2ae..94c917aed07cb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1581,7 +1581,7 @@ 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_WRAPPER", self.bootstrap_out.join("rustc")); } // Dealing with rpath here is a little special, so let's go into some diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 601351ea8e3c0..73ae1241b9eef 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -315,7 +315,7 @@ impl Step for Cargotest { cmd.arg(&cargo) .arg(&out_dir) .args(builder.config.cmd.test_args()) - .env("RUSTC", builder.rustc(compiler)) + .env("RUSTC_WRAPPER", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)), ); } @@ -1094,7 +1094,7 @@ 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_WRAPPER", builder.rustc(self.compiler)) .current_dir(path); // FIXME: implement a `// compile-flags` command or similar // instead of hard-coding this test @@ -2796,7 +2796,7 @@ 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_WRAPPER", &builder.initial_rustc); cmd.env("TMP_DIR", &tmpdir); try_run(builder, &mut cmd); } From 1458bdd5351022a26f8dd8e58d2ce7cb92f1e423 Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:27:28 +0000 Subject: [PATCH 2/3] Try to figure out why CI fails while local doesn't --- src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile index 1f28b93977800..40f7480e44690 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile @@ -50,7 +50,7 @@ ENV RUST_CONFIGURE_ARGS \ --set rust.thin-lto-import-instr-limit=10 # NOTE: intentionally uses all of `x.py`, `x`, and `x.ps1` to make sure they all work on Linux. -ENV SCRIPT ../x.py --stage 2 test --exclude src/tools/tidy && \ +ENV SCRIPT ../x.py --verbose --stage 2 test --exclude src/tools/tidy && \ # Run the `mir-opt` tests again but this time for a 32-bit target. # This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have # both 32-bit and 64-bit outputs updated by the PR author, before From 242f0ff5c7118c7ac75323ff9c7c89a21a799cd8 Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Wed, 26 Apr 2023 17:54:37 +0000 Subject: [PATCH 3/3] Try something else --- src/bootstrap/Cargo.toml | 5 +++++ src/bootstrap/bin/rustc-shim.rs | 10 ++++++++++ src/bootstrap/bin/rustc.rs | 2 +- src/bootstrap/builder.rs | 1 + src/bootstrap/test.rs | 3 +++ .../docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile | 2 +- 6 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/bootstrap/bin/rustc-shim.rs diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 7b9eaceb00f6a..9a189d4042731 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -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" } diff --git a/src/bootstrap/bin/rustc-shim.rs b/src/bootstrap/bin/rustc-shim.rs new file mode 100644 index 0000000000000..6108337ec0fd6 --- /dev/null +++ b/src/bootstrap/bin/rustc-shim.rs @@ -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") + } +} diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 3ffb48cd9b717..fcd2dd072aa58 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -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: diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 94c917aed07cb..256c105ad8edb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1581,6 +1581,7 @@ 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-shim")); cargo.env("RUSTC_WRAPPER", self.bootstrap_out.join("rustc")); } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 73ae1241b9eef..7afc435621a6b 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -315,6 +315,7 @@ impl Step for Cargotest { cmd.arg(&cargo) .arg(&out_dir) .args(builder.config.cmd.test_args()) + .env("RUSTC", builder.bootstrap_out.join("rustc-shim")) .env("RUSTC_WRAPPER", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)), ); @@ -1094,6 +1095,7 @@ impl Step for RustdocGUI { .arg(&out_dir) .env("RUSTC_BOOTSTRAP", "1") .env("RUSTDOC", builder.rustdoc(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 @@ -2796,6 +2798,7 @@ 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.bootstrap_out.join("rustc-shim")); cmd.env("RUSTC_WRAPPER", &builder.initial_rustc); cmd.env("TMP_DIR", &tmpdir); try_run(builder, &mut cmd); diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile index 40f7480e44690..1f28b93977800 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile @@ -50,7 +50,7 @@ ENV RUST_CONFIGURE_ARGS \ --set rust.thin-lto-import-instr-limit=10 # NOTE: intentionally uses all of `x.py`, `x`, and `x.ps1` to make sure they all work on Linux. -ENV SCRIPT ../x.py --verbose --stage 2 test --exclude src/tools/tidy && \ +ENV SCRIPT ../x.py --stage 2 test --exclude src/tools/tidy && \ # Run the `mir-opt` tests again but this time for a 32-bit target. # This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have # both 32-bit and 64-bit outputs updated by the PR author, before