Skip to content

Commit

Permalink
Resolve link once instead of canonicalize
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeuw committed Dec 16, 2023
1 parent b7eeb3c commit 0cba7c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashSet;
use std::env;
use std::fs::canonicalize;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
Expand Down Expand Up @@ -812,9 +811,12 @@ fn expand_variables(mut value: String, config: &Config) -> String {
}

if value.contains(RUST_SRC_BASE) {
let src = config.sysroot_base.join("lib/rustlib/src/rust");
let canonical = canonicalize(&src).unwrap();
value = value.replace(RUST_SRC_BASE, &canonical.to_string_lossy());
let src_base = config
.sysroot_base
.join("lib/rustlib/src/rust")
.read_link()
.expect("lib/rustlib/src/rust in target is a symlink to checkout root");
value = value.replace(RUST_SRC_BASE, &src_base.to_string_lossy());
}

value
Expand Down
8 changes: 6 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4222,8 +4222,12 @@ impl<'test> TestCx<'test> {
normalize_path(parent_build_dir, "$BUILD_DIR");

// Real paths into the libstd/libcore
let rust_src_dir =
&self.config.sysroot_base.join("lib/rustlib/src/rust").canonicalize().unwrap();
let rust_src_dir = &self
.config
.sysroot_base
.join("lib/rustlib/src/rust")
.read_link()
.expect("lib/rustlib/src/rust in target is a symlink to checkout root");
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");

if json {
Expand Down

0 comments on commit 0cba7c8

Please sign in to comment.