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: show diagnostics relative to rustc src dir #132390

Merged
merged 3 commits into from
Dec 1, 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
3 changes: 2 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,8 @@ def build_bootstrap_cmd(self, env):
raise Exception("no cargo executable found at `{}`".format(
self.cargo()))
args = [self.cargo(), "build", "--manifest-path",
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml"),
"-Zroot-dir="+self.rust_root]
args.extend("--verbose" for _ in range(self.verbose))
if self.use_locked_deps:
args.append("--locked")
Expand Down
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ impl Step for Cargo {
// those features won't be able to land.
cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1");
cargo.env("PATH", path_for_cargo(builder, compiler));
// Cargo's test suite requires configurations from its own `.cargo/config.toml`.
// Change to the directory so Cargo can read from it.
cargo.current_dir(builder.src.join(Self::CRATE_PATH));
// Cargo's test suite uses `CARGO_RUSTC_CURRENT_DIR` to determine the path that `file!` is
// relative to. Cargo no longer sets this env var, so we have to do that. This has to be the
// same value as `-Zroot-dir`.
cargo.env("CARGO_RUSTC_CURRENT_DIR", builder.src.display().to_string());

#[cfg(feature = "build-metrics")]
builder.metrics.begin_test_suite(
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@ impl Builder<'_> {

cargo.arg("-j").arg(self.jobs().to_string());

// Make cargo emit diagnostics relative to the rustc src dir.
cargo.arg(format!("-Zroot-dir={}", self.src.display()));

// FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
// Force cargo to output binaries with disambiguating hashes in the name
let mut metadata = if compiler.stage == 0 {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/extern/extern-types-field-offset.run.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at core/src/panicking.rs:$LINE:$COL:
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
attempted to compute the size or alignment of extern type `Opaque`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
2 changes: 1 addition & 1 deletion tests/ui/extern/extern-types-size_of_val.align.run.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at core/src/panicking.rs:$LINE:$COL:
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
attempted to compute the size or alignment of extern type `A`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
2 changes: 1 addition & 1 deletion tests/ui/extern/extern-types-size_of_val.size.run.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thread 'main' panicked at core/src/panicking.rs:$LINE:$COL:
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
attempted to compute the size or alignment of extern type `A`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
2 changes: 1 addition & 1 deletion tests/ui/panics/panic-in-cleanup.run.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at $DIR/panic-in-cleanup.rs:16:9:
BOOM
stack backtrace:
thread 'main' panicked at core/src/panicking.rs:$LINE:$COL:
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.
2 changes: 1 addition & 1 deletion tests/ui/panics/panic-in-ffi.run.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ thread 'main' panicked at $DIR/panic-in-ffi.rs:21:5:
Test
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Noisy Drop
thread 'main' panicked at core/src/panicking.rs:$LINE:$COL:
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
panic in a function that cannot unwind
stack backtrace:
thread caused non-unwinding panic. aborting.
2 changes: 1 addition & 1 deletion tests/ui/process/println-with-broken-pipe.run.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
thread 'main' panicked at std/src/io/stdio.rs:LL:CC:
thread 'main' panicked at library/std/src/io/stdio.rs:LL:CC:
failed printing to stdout: Broken pipe (os error 32)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Loading