Skip to content

Commit 27ea1de

Browse files
committed
Auto merge of #127044 - Oneirical:fantestic-journey, r=<try>
Migrate `dylib-chain`, `rlib-chain`, `issue-47384`, `msvc-opt-minsize` and `test-harness` `run-make` tests to ui/rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). `issue-47384` demands a Windows/Apple try-job. try-job: x86_64-msvc try-job: aarch64-apple
2 parents 2495953 + 2019f15 commit 27ea1de

File tree

19 files changed

+127
-75
lines changed

19 files changed

+127
-75
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ run-make/dep-info-spaces/Makefile
2424
run-make/dep-info/Makefile
2525
run-make/dump-ice-to-disk/Makefile
2626
run-make/dump-mono-stats/Makefile
27-
run-make/dylib-chain/Makefile
2827
run-make/emit-path-unhashed/Makefile
2928
run-make/emit-shared-files/Makefile
3029
run-make/emit-stack-sizes/Makefile
@@ -68,7 +67,6 @@ run-make/issue-35164/Makefile
6867
run-make/issue-36710/Makefile
6968
run-make/issue-37839/Makefile
7069
run-make/issue-40535/Makefile
71-
run-make/issue-47384/Makefile
7270
run-make/issue-47551/Makefile
7371
run-make/issue-68794-textrel-on-minimal-lib/Makefile
7472
run-make/issue-69368/Makefile
@@ -107,7 +105,6 @@ run-make/mingw-export-call-convention/Makefile
107105
run-make/mismatching-target-triples/Makefile
108106
run-make/missing-crate-dependency/Makefile
109107
run-make/mixing-libs/Makefile
110-
run-make/msvc-opt-minsize/Makefile
111108
run-make/native-link-modifier-bundle/Makefile
112109
run-make/native-link-modifier-whole-archive/Makefile
113110
run-make/no-alloc-shim/Makefile
@@ -153,7 +150,6 @@ run-make/reproducible-build-2/Makefile
153150
run-make/reproducible-build/Makefile
154151
run-make/return-non-c-like-enum-from-c/Makefile
155152
run-make/return-non-c-like-enum/Makefile
156-
run-make/rlib-chain/Makefile
157153
run-make/rlib-format-packed-bundled-libs-2/Makefile
158154
run-make/rlib-format-packed-bundled-libs-3/Makefile
159155
run-make/rlib-format-packed-bundled-libs/Makefile
@@ -183,7 +179,6 @@ run-make/target-cpu-native/Makefile
183179
run-make/target-specs/Makefile
184180
run-make/target-without-atomic-cas/Makefile
185181
run-make/test-benches/Makefile
186-
run-make/test-harness/Makefile
187182
run-make/thumb-none-cortex-m/Makefile
188183
run-make/thumb-none-qemu/Makefile
189184
run-make/track-path-dep-info/Makefile

tests/run-make/dylib-chain/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/run-make/dylib-chain/rmake.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// In this test, m4 depends on m3, which depends on m2, which depends on m1.
2+
// Even though dependencies are chained like this and there is no direct mention
3+
// of m1 or m2 in m4.rs, compilation and execution should still succeed. Unlike the
4+
// rlib-chain test, dynamic libraries contain upstream dependencies, and breaking
5+
// the chain by removing the dylibs causes execution to fail.
6+
// See https://github.com/rust-lang/rust/issues/10434
7+
8+
//@ ignore-cross-compile
9+
// Reason: the compiled binary is executed
10+
11+
use run_make_support::{dynamic_lib_name, fs_wrapper, run, run_fail, rustc};
12+
13+
fn main() {
14+
rustc().input("m1.rs").arg("-Cprefer-dynamic").run();
15+
rustc().input("m2.rs").arg("-Cprefer-dynamic").run();
16+
rustc().input("m3.rs").arg("-Cprefer-dynamic").run();
17+
rustc().input("m4.rs").run();
18+
run("m4");
19+
fs_wrapper::remove_file(dynamic_lib_name("m1"));
20+
fs_wrapper::remove_file(dynamic_lib_name("m2"));
21+
fs_wrapper::remove_file(dynamic_lib_name("m3"));
22+
run_fail("m4");
23+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Linkers treat archives differently from object files: all object files participate in linking,
2+
// while archives will only participate in linking if they can satisfy at least one undefined
3+
// reference (version scripts doesn't count). This causes `#[no_mangle]` or `#[used]` items to
4+
// be ignored by the linker, and since they never participate in the linking, using `KEEP` in the
5+
// linker scripts can't keep them either. This causes #47384. After the fix in #95604, this test
6+
// checks that these symbols and sections successfully appear in the output dynamic library.
7+
// See https://github.com/rust-lang/rust/pull/95604
8+
// See https://github.com/rust-lang/rust/issues/47384
9+
10+
//FIXME(Oneirical): ignore flags: only linux and cross compile
11+
12+
use run_make_support::{dynamic_lib_name, llvm_objdump, llvm_readobj, rustc};
13+
14+
fn main() {
15+
rustc().crate_type("lib").input("lib.rs").run();
16+
rustc().crate_type("cdylib").link_args("-Tlinker.ld").input("main.rs").run();
17+
// Ensure `#[used]` and `KEEP`-ed section is there
18+
llvm_objdump()
19+
.arg("--full-contents")
20+
.arg("--section=.static")
21+
.input(dynamic_lib_name("main"))
22+
.run();
23+
// Ensure `#[no_mangle]` symbol is there
24+
llvm_readobj()
25+
.arg("--symbols")
26+
.input(dynamic_lib_name("main"))
27+
.run()
28+
.assert_stdout_contains("bar");
29+
}

tests/run-make/issue-47384/Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/run-make/msvc-opt-minsize/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/run-make/msvc-opt-minsize/foo.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/run-make/rlib-chain/Makefile

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/run-make/rlib-chain/rmake.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// In this test, m4 depends on m3, which depends on m2, which depends on m1.
2+
// Even though dependencies are chained like this and there is no direct mention
3+
// of m1 or m2 in m4.rs, compilation and execution should still succeed. Unlike
4+
// the dylib-chain test, rlibs do not contain upstream dependencies, and removing
5+
// the libraries still allows m4 to successfully execute.
6+
// See https://github.com/rust-lang/rust/issues/10434
7+
8+
//@ ignore-cross-compile
9+
// Reason: the compiled binary is executed
10+
11+
use run_make_support::{fs_wrapper, run, rust_lib_name, rustc};
12+
13+
fn main() {
14+
rustc().input("m1.rs").run();
15+
rustc().input("m2.rs").run();
16+
rustc().input("m3.rs").run();
17+
rustc().input("m4.rs").run();
18+
run("m4");
19+
fs_wrapper::remove_file(rust_lib_name("m1"));
20+
fs_wrapper::remove_file(rust_lib_name("m2"));
21+
fs_wrapper::remove_file(rust_lib_name("m3"));
22+
run("m4");
23+
}

tests/run-make/test-harness/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/run-make/test-harness/rmake.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// The way test suites run can be modified using configuration flags,
2+
// ignoring certain tests while running others. This test contains two
3+
// functions, one which must run and the other which must not. The standard
4+
// output is checked to verify that the ignore configuration is doing its job,
5+
// and that output is successfully minimized with the --quiet flag.
6+
// See https://github.com/rust-lang/rust/commit/f7ebe23ae185991b0fee05b32fbb3e29b89a41bf
7+
8+
//@ ignore-cross-compile
9+
// Reason: the compiled binary is executed
10+
11+
use run_make_support::{run, run_with_args, rustc};
12+
13+
fn main() {
14+
rustc().arg("--test").input("test-ignore-cfg.rs").cfg("ignorecfg").run();
15+
// check that #[cfg_attr(..., ignore)] does the right thing.
16+
run("test-ignore-cfg")
17+
.assert_stdout_contains("shouldnotignore ... ok")
18+
.assert_stdout_contains("shouldignore ... ignored");
19+
run_with_args("test-ignore-cfg", &["--quiet"]).assert_stdout_contains("i.");
20+
run_with_args("test-ignore-cfg", &["--quiet"]).assert_stdout_not_contains("should");
21+
}
File renamed without changes.

tests/ui/windows/msvc-opt-minsize.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// A previously outdated version of LLVM caused compilation failures on Windows
2+
// specifically with optimization level `z`. After the update to a more recent LLVM
3+
// version, this test checks that compilation and execution both succeed.
4+
// See https://github.com/rust-lang/rust/issues/45034
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
//@ only-windows
9+
// Reason: the observed bug only occurs on Windows
10+
//@ run-pass
11+
//@ compile-flags: -C opt-level=z
12+
13+
#![feature(test)]
14+
extern crate test;
15+
16+
fn foo(x: i32, y: i32) -> i64 {
17+
(x + y) as i64
18+
}
19+
20+
#[inline(never)]
21+
fn bar() {
22+
let _f = Box::new(0);
23+
// This call used to trigger an LLVM bug in opt-level z where the base
24+
// pointer gets corrupted, see issue #45034
25+
let y: fn(i32, i32) -> i64 = test::black_box(foo);
26+
test::black_box(y(1, 2));
27+
}
28+
29+
fn main() {
30+
bar();
31+
}
File renamed without changes.

0 commit comments

Comments
 (0)