Skip to content

Commit 552918b

Browse files
Rollup merge of #150544 - bjorn3:run_make_print_target_libdir, r=Urgau,jieyouxu
Use --print target-libdir in run-make tests This makes the tests more robust against sysroot layout changes and slightly simplifies them.
2 parents 8dc15d2 + 1a4e7f9 commit 552918b

4 files changed

Lines changed: 11 additions & 15 deletions

File tree

tests/run-make/apple-deployment-target/rmake.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ fn main() {
169169

170170
// Test that all binaries in rlibs produced by `rustc` have the same version.
171171
// Regression test for https://github.com/rust-lang/rust/issues/128419.
172-
let sysroot = rustc().print("sysroot").run().stdout_utf8();
173-
let target_sysroot = path(sysroot.trim()).join("lib/rustlib").join(target()).join("lib");
174-
let rlibs = shallow_find_files(&target_sysroot, |path| has_extension(path, "rlib"));
172+
let sysroot_libs_dir = rustc().print("target-libdir").target(target()).run().stdout_utf8();
173+
let rlibs = shallow_find_files(sysroot_libs_dir.trim(), |path| has_extension(path, "rlib"));
175174

176175
let output = cmd("otool").arg("-l").args(rlibs).run().stdout_utf8();
177176
let re = regex::Regex::new(r"(minos|version) ([0-9.]*)").unwrap();

tests/run-make/cdylib-dylib-linkage/rmake.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,23 @@ use run_make_support::{
1616
fn main() {
1717
rustc().arg("-Cprefer-dynamic").input("bar.rs").run();
1818
rustc().input("foo.rs").run();
19-
let sysroot = rustc().print("sysroot").run().stdout_utf8();
20-
let sysroot = sysroot.trim();
21-
let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib");
19+
let sysroot_libs_dir = rustc().print("target-libdir").target(target()).run().stdout_utf8();
20+
let sysroot_libs_dir = sysroot_libs_dir.trim();
2221
if is_windows_msvc() {
23-
let mut libs = shallow_find_files(&target_sysroot, |path| {
22+
let mut libs = shallow_find_files(sysroot_libs_dir, |path| {
2423
has_prefix(path, "libstd-") && has_suffix(path, ".dll.lib")
2524
});
2625
libs.push(path(msvc_import_dynamic_lib_name("foo")));
2726
libs.push(path(msvc_import_dynamic_lib_name("bar")));
2827
cc().input("foo.c").args(&libs).out_exe("foo").run();
2928
} else {
30-
let stdlibs = shallow_find_files(&target_sysroot, |path| {
29+
let stdlibs = shallow_find_files(sysroot_libs_dir, |path| {
3130
has_extension(path, dynamic_lib_extension()) && filename_contains(path, "std")
3231
});
3332
cc().input("foo.c")
3433
.args(&[dynamic_lib_name("foo"), dynamic_lib_name("bar")])
3534
.arg(stdlibs.get(0).unwrap())
36-
.library_search_path(&target_sysroot)
35+
.library_search_path(sysroot_libs_dir)
3736
.output(bin_name("foo"))
3837
.run();
3938
}

tests/run-make/libstd-no-protected/rmake.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ type SymbolTable<'data> = run_make_support::object::read::elf::SymbolTable<'data
1515

1616
fn main() {
1717
// Find libstd-...rlib
18-
let sysroot = rustc().print("sysroot").run().stdout_utf8();
19-
let sysroot = sysroot.trim();
20-
let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib");
21-
let mut libs = shallow_find_files(&target_sysroot, |path| {
18+
let sysroot_libs_dir = rustc().print("target-libdir").target(target()).run().stdout_utf8();
19+
let mut libs = shallow_find_files(sysroot_libs_dir.trim(), |path| {
2220
has_prefix(path, "libstd-") && has_suffix(path, ".rlib")
2321
});
2422
assert_eq!(libs.len(), 1);

tests/run-make/sysroot-crates-are-unstable/rmake.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ fn check_crate_is_unstable(cr: &Crate) {
4444
}
4545

4646
fn get_unstable_sysroot_crates() -> Vec<Crate> {
47-
let sysroot = PathBuf::from(rustc().print("sysroot").run().stdout_utf8().trim());
48-
let sysroot_libs_dir = sysroot.join("lib").join("rustlib").join(target()).join("lib");
47+
let sysroot_libs_dir =
48+
PathBuf::from(rustc().print("target-libdir").target(target()).run().stdout_utf8().trim());
4949
println!("Sysroot libs dir: {sysroot_libs_dir:?}");
5050

5151
// Generate a list of all library crates in the sysroot.

0 commit comments

Comments
 (0)