Auto merge of #129687 - Urgau:rfc3127-sysroot-2, r=jieyouxu
Implement RFC3137 trim-paths sysroot changes - take 2 This PR is a continuation of https://github.com/rust-lang/rust/pull/118149. Nothing really changed, except for https://github.com/rust-lang/rust/pull/129408 which I was able to trigger locally. Original description: > Implement parts of #111540 > > Right now, backtraces into sysroot always shows /rustc/$hash in diagnostics, e.g. > > ``` > thread 'main' panicked at 'hello world', map-panic.rs:2:50 > stack backtrace: > 0: std::panicking::begin_panic > at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:616:12 > 1: map_panic::main::{{closure}} > at ./map-panic.rs:2:50 > 2: core::option::Option<T>::map > at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/option.rs:929:29 > 3: map_panic::main > at ./map-panic.rs:2:30 > 4: core::ops::function::FnOnce::call_once > at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5 > note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. > ``` > > [RFC 3127 said](https://rust-lang.github.io/rfcs/3127-trim-paths.html#changing-handling-of-sysroot-path-in-rustc) > > > We want to change this behaviour such that, when rust-src source files can be discovered, the virtual path is discarded and therefore the local path will be embedded, unless there is a --remap-path-prefix that causes this local path to be remapped in the usual way. > > This PR implements this behaviour. When `rust-src` is present at compile time, rustc replaces /rustc/$hash with a real path into local rust-src with best effort. To sanitise this, users must explicitly supply `--remap-path-prefix=<path to rust-src>=foo`. cc `@cbeuw` Fix #105907 Fix #85463 try-job: dist-x86_64-linux try-job: x86_64-msvc try-job: dist-x86_64-msvc try-job: armhf-gnu
This commit is contained in:
commit
1d9162bced
6 changed files with 126 additions and 50 deletions
|
|
@ -1115,6 +1115,7 @@ fn expand_variables(mut value: String, config: &Config) -> String {
|
|||
const CWD: &str = "{{cwd}}";
|
||||
const SRC_BASE: &str = "{{src-base}}";
|
||||
const BUILD_BASE: &str = "{{build-base}}";
|
||||
const RUST_SRC_BASE: &str = "{{rust-src-base}}";
|
||||
const SYSROOT_BASE: &str = "{{sysroot-base}}";
|
||||
const TARGET_LINKER: &str = "{{target-linker}}";
|
||||
const TARGET: &str = "{{target}}";
|
||||
|
|
@ -1144,6 +1145,13 @@ fn expand_variables(mut value: String, config: &Config) -> String {
|
|||
value = value.replace(TARGET, &config.target);
|
||||
}
|
||||
|
||||
if value.contains(RUST_SRC_BASE) {
|
||||
let src_base = config.sysroot_base.join("lib/rustlib/src/rust");
|
||||
src_base.try_exists().expect(&*format!("{} should exists", src_base.display()));
|
||||
let src_base = src_base.read_link().unwrap_or(src_base);
|
||||
value = value.replace(RUST_SRC_BASE, &src_base.to_string_lossy());
|
||||
}
|
||||
|
||||
value
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2294,13 +2294,19 @@ impl<'test> TestCx<'test> {
|
|||
}
|
||||
|
||||
let base_dir = Path::new("/rustc/FAKE_PREFIX");
|
||||
// Paths into the libstd/libcore
|
||||
// Fake paths into the libstd/libcore
|
||||
normalize_path(&base_dir.join("library"), "$SRC_DIR");
|
||||
// `ui-fulldeps` tests can show paths to the compiler source when testing macros from
|
||||
// `rustc_macros`
|
||||
// eg. /home/user/rust/compiler
|
||||
normalize_path(&base_dir.join("compiler"), "$COMPILER_DIR");
|
||||
|
||||
// Real paths into the libstd/libcore
|
||||
let rust_src_dir = &self.config.sysroot_base.join("lib/rustlib/src/rust");
|
||||
rust_src_dir.try_exists().expect(&*format!("{} should exists", rust_src_dir.display()));
|
||||
let rust_src_dir = rust_src_dir.read_link().unwrap_or(rust_src_dir.to_path_buf());
|
||||
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");
|
||||
|
||||
// Paths into the build directory
|
||||
let test_build_dir = &self.config.build_base;
|
||||
let parent_build_dir = test_build_dir.parent().unwrap().parent().unwrap().parent().unwrap();
|
||||
|
|
@ -2310,9 +2316,6 @@ impl<'test> TestCx<'test> {
|
|||
// eg. /home/user/rust/build
|
||||
normalize_path(parent_build_dir, "$BUILD_DIR");
|
||||
|
||||
// Paths into lib directory.
|
||||
normalize_path(&parent_build_dir.parent().unwrap().join("lib"), "$LIB_DIR");
|
||||
|
||||
if json {
|
||||
// escaped newlines in json strings should be readable
|
||||
// in the stderr files. There's no point int being correct,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue