Skip to content

Commit e0c1673

Browse files
committed
Auto merge of rust-lang#126095 - Oneirical:final-testination, r=<try>
Migrate `link-args-order`, `ls-metadata` and `lto-readonly-lib` `run-make` tests to `rmake` Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Guaranteed to fail CI until rust-lang#125736 gets merged. Will require addition of `fs_wrapper::set_permissions` in the associated module. try-job: x86_64-msvc
2 parents 3186d17 + c243f12 commit e0c1673

File tree

8 files changed

+76
-34
lines changed

8 files changed

+76
-34
lines changed

src/tools/run-make-support/src/rustc.rs

+12
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ impl Rustc {
230230
self
231231
}
232232

233+
/// Add multiple extra arguments to the linker invocation, via `-Clink-args`.
234+
pub fn link_args(&mut self, link_args: &str) -> &mut Self {
235+
self.cmd.arg(format!("-Clink-args={link_args}"));
236+
self
237+
}
238+
233239
/// Specify a stdin input
234240
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
235241
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());
@@ -248,4 +254,10 @@ impl Rustc {
248254
self.cmd.arg(format!("-Clinker={linker}"));
249255
self
250256
}
257+
258+
/// Specify the linker flavor
259+
pub fn linker_flavor(&mut self, linker_flavor: &str) -> &mut Self {
260+
self.cmd.arg(format!("-Clinker-flavor={linker_flavor}"));
261+
self
262+
}
251263
}

src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ run-make/libtest-json/Makefile
9898
run-make/libtest-junit/Makefile
9999
run-make/libtest-padding/Makefile
100100
run-make/libtest-thread-limit/Makefile
101-
run-make/link-args-order/Makefile
102101
run-make/link-cfg/Makefile
103102
run-make/link-framework/Makefile
104103
run-make/link-path-order/Makefile
@@ -107,12 +106,10 @@ run-make/llvm-ident/Makefile
107106
run-make/long-linker-command-lines-cmd-exe/Makefile
108107
run-make/long-linker-command-lines/Makefile
109108
run-make/longjmp-across-rust/Makefile
110-
run-make/ls-metadata/Makefile
111109
run-make/lto-dylib-dep/Makefile
112110
run-make/lto-empty/Makefile
113111
run-make/lto-linkage-used-attr/Makefile
114112
run-make/lto-no-link-whole-rlib/Makefile
115-
run-make/lto-readonly-lib/Makefile
116113
run-make/lto-smoke-c/Makefile
117114
run-make/macos-deployment-target/Makefile
118115
run-make/macos-fat-archive/Makefile

tests/run-make/link-args-order/Makefile

-10
This file was deleted.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Passing linker arguments to the compiler used to be lost or reordered in a messy way
2+
// as they were passed further to the linker. This was fixed in #70665, and this test
3+
// checks that linker arguments remain intact and in the order they were originally passed in.
4+
// See https://github.com/rust-lang/rust/pull/70665
5+
6+
use run_make_support::{is_windows, rustc};
7+
8+
fn main() {
9+
let link_flavor = if is_windows() { "lld-link" } else { "ld" };
10+
rustc()
11+
.input("empty.rs")
12+
.linker_flavor(link_flavor)
13+
.link_arg("a")
14+
.link_args("b c")
15+
.link_args("d e")
16+
.link_arg("f")
17+
.run_fail()
18+
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
19+
rustc()
20+
.input("empty.rs")
21+
.linker_flavor(link_flavor)
22+
.arg("-Zpre-link-arg=a")
23+
.arg("-Zpre-link-args=b c")
24+
.arg("-Zpre-link-args=d e")
25+
.arg("-Zpre-link-arg=f")
26+
.run_fail()
27+
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
28+
}

tests/run-make/ls-metadata/Makefile

-8
This file was deleted.

tests/run-make/ls-metadata/rmake.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Passing invalid files to -Z ls (which lists the symbols
2+
// defined by a library crate) used to cause a segmentation fault.
3+
// As this was fixed in #11262, this test checks that no segfault
4+
// occurs when passing the invalid file `bar` to -Z ls.
5+
// See https://github.com/rust-lang/rust/issues/11259
6+
7+
//@ ignore-cross-compile
8+
9+
use run_make_support::fs_wrapper;
10+
use run_make_support::rustc;
11+
12+
fn main() {
13+
rustc().input("foo.rs").run();
14+
rustc().arg("-Zls=root").input("foo").run();
15+
fs_wrapper::create_file("bar");
16+
rustc().arg("-Zls=root").input("bar").run();
17+
}

tests/run-make/lto-readonly-lib/Makefile

-13
This file was deleted.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// When the compiler is performing link time optimization, it will
2+
// need to copy the original rlib file, set the copy's permissions to read/write,
3+
// and modify that copy - even if the original
4+
// file is read-only. This test creates a read-only rlib, and checks that
5+
// compilation with LTO succeeds.
6+
// See https://github.com/rust-lang/rust/pull/17619
7+
8+
//@ ignore-cross-compile
9+
10+
use run_make_support::fs_wrapper;
11+
use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};
12+
13+
fn main() {
14+
rustc().input("lib.rs").run();
15+
test_while_readonly(rust_lib_name("lib"), || {
16+
rustc().input("main.rs").arg("-Clto").run();
17+
run("main");
18+
});
19+
}

0 commit comments

Comments
 (0)