diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2bc3acc58cb22..88a180705be8c 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -24,7 +24,6 @@ run-make/dep-info-spaces/Makefile run-make/dep-info/Makefile run-make/dump-ice-to-disk/Makefile run-make/dump-mono-stats/Makefile -run-make/dylib-chain/Makefile run-make/emit-path-unhashed/Makefile run-make/emit-shared-files/Makefile run-make/emit-stack-sizes/Makefile @@ -68,7 +67,6 @@ run-make/issue-35164/Makefile run-make/issue-36710/Makefile run-make/issue-37839/Makefile run-make/issue-40535/Makefile -run-make/issue-47384/Makefile run-make/issue-47551/Makefile run-make/issue-68794-textrel-on-minimal-lib/Makefile run-make/issue-69368/Makefile @@ -107,7 +105,6 @@ run-make/mingw-export-call-convention/Makefile run-make/mismatching-target-triples/Makefile run-make/missing-crate-dependency/Makefile run-make/mixing-libs/Makefile -run-make/msvc-opt-minsize/Makefile run-make/native-link-modifier-bundle/Makefile run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile @@ -153,7 +150,6 @@ run-make/reproducible-build-2/Makefile run-make/reproducible-build/Makefile run-make/return-non-c-like-enum-from-c/Makefile run-make/return-non-c-like-enum/Makefile -run-make/rlib-chain/Makefile run-make/rlib-format-packed-bundled-libs-2/Makefile run-make/rlib-format-packed-bundled-libs-3/Makefile run-make/rlib-format-packed-bundled-libs/Makefile @@ -183,7 +179,6 @@ run-make/target-cpu-native/Makefile run-make/target-specs/Makefile run-make/target-without-atomic-cas/Makefile run-make/test-benches/Makefile -run-make/test-harness/Makefile run-make/thumb-none-cortex-m/Makefile run-make/thumb-none-qemu/Makefile run-make/track-path-dep-info/Makefile diff --git a/tests/run-make/dylib-chain/Makefile b/tests/run-make/dylib-chain/Makefile deleted file mode 100644 index f1fea99c5ee91..0000000000000 --- a/tests/run-make/dylib-chain/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) m1.rs -C prefer-dynamic - $(RUSTC) m2.rs -C prefer-dynamic - $(RUSTC) m3.rs -C prefer-dynamic - $(RUSTC) m4.rs - $(call RUN,m4) - $(call REMOVE_DYLIBS,m1) - $(call REMOVE_DYLIBS,m2) - $(call REMOVE_DYLIBS,m3) - $(call FAIL,m4) diff --git a/tests/run-make/dylib-chain/rmake.rs b/tests/run-make/dylib-chain/rmake.rs new file mode 100644 index 0000000000000..a96cc3508750b --- /dev/null +++ b/tests/run-make/dylib-chain/rmake.rs @@ -0,0 +1,23 @@ +// In this test, m4 depends on m3, which depends on m2, which depends on m1. +// Even though dependencies are chained like this and there is no direct mention +// of m1 or m2 in m4.rs, compilation and execution should still succeed. Unlike the +// rlib-chain test, dynamic libraries contain upstream dependencies, and breaking +// the chain by removing the dylibs causes execution to fail. +// See https://github.com/rust-lang/rust/issues/10434 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{dynamic_lib_name, fs_wrapper, run, run_fail, rustc}; + +fn main() { + rustc().input("m1.rs").arg("-Cprefer-dynamic").run(); + rustc().input("m2.rs").arg("-Cprefer-dynamic").run(); + rustc().input("m3.rs").arg("-Cprefer-dynamic").run(); + rustc().input("m4.rs").run(); + run("m4"); + fs_wrapper::remove_file(dynamic_lib_name("m1")); + fs_wrapper::remove_file(dynamic_lib_name("m2")); + fs_wrapper::remove_file(dynamic_lib_name("m3")); + run_fail("m4"); +} diff --git a/tests/run-make/issue-47384/lib.rs b/tests/run-make/include-all-symbols-linking/lib.rs similarity index 100% rename from tests/run-make/issue-47384/lib.rs rename to tests/run-make/include-all-symbols-linking/lib.rs diff --git a/tests/run-make/issue-47384/linker.ld b/tests/run-make/include-all-symbols-linking/linker.ld similarity index 100% rename from tests/run-make/issue-47384/linker.ld rename to tests/run-make/include-all-symbols-linking/linker.ld diff --git a/tests/run-make/issue-47384/main.rs b/tests/run-make/include-all-symbols-linking/main.rs similarity index 100% rename from tests/run-make/issue-47384/main.rs rename to tests/run-make/include-all-symbols-linking/main.rs diff --git a/tests/run-make/include-all-symbols-linking/rmake.rs b/tests/run-make/include-all-symbols-linking/rmake.rs new file mode 100644 index 0000000000000..a443fc0a5c41b --- /dev/null +++ b/tests/run-make/include-all-symbols-linking/rmake.rs @@ -0,0 +1,29 @@ +// Linkers treat archives differently from object files: all object files participate in linking, +// while archives will only participate in linking if they can satisfy at least one undefined +// reference (version scripts doesn't count). This causes `#[no_mangle]` or `#[used]` items to +// be ignored by the linker, and since they never participate in the linking, using `KEEP` in the +// linker scripts can't keep them either. This causes #47384. After the fix in #95604, this test +// checks that these symbols and sections successfully appear in the output dynamic library. +// See https://github.com/rust-lang/rust/pull/95604 +// See https://github.com/rust-lang/rust/issues/47384 + +//FIXME(Oneirical): ignore flags: only linux and cross compile + +use run_make_support::{dynamic_lib_name, llvm_objdump, llvm_readobj, rustc}; + +fn main() { + rustc().crate_type("lib").input("lib.rs").run(); + rustc().crate_type("cdylib").link_args("-Tlinker.ld").input("main.rs").run(); + // Ensure `#[used]` and `KEEP`-ed section is there + llvm_objdump() + .arg("--full-contents") + .arg("--section=.static") + .input(dynamic_lib_name("main")) + .run(); + // Ensure `#[no_mangle]` symbol is there + llvm_readobj() + .arg("--symbols") + .input(dynamic_lib_name("main")) + .run() + .assert_stdout_contains("bar"); +} diff --git a/tests/run-make/issue-47384/Makefile b/tests/run-make/issue-47384/Makefile deleted file mode 100644 index afc77cb275aaa..0000000000000 --- a/tests/run-make/issue-47384/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -# only-linux -# ignore-cross-compile - -all: main.rs - $(RUSTC) --crate-type lib lib.rs - $(RUSTC) --crate-type cdylib -Clink-args="-Tlinker.ld" main.rs - # Ensure `#[used]` and `KEEP`-ed section is there - objdump -s -j".static" $(TMPDIR)/libmain.so - # Ensure `#[no_mangle]` symbol is there - nm $(TMPDIR)/libmain.so | $(CGREP) bar diff --git a/tests/run-make/msvc-opt-minsize/Makefile b/tests/run-make/msvc-opt-minsize/Makefile deleted file mode 100644 index 32e6e28018f7a..0000000000000 --- a/tests/run-make/msvc-opt-minsize/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) foo.rs -Copt-level=z 2>&1 - $(call RUN,foo) diff --git a/tests/run-make/msvc-opt-minsize/foo.rs b/tests/run-make/msvc-opt-minsize/foo.rs deleted file mode 100644 index 3f5496c08ee25..0000000000000 --- a/tests/run-make/msvc-opt-minsize/foo.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(test)] -extern crate test; - -fn foo(x: i32, y: i32) -> i64 { - (x + y) as i64 -} - -#[inline(never)] -fn bar() { - let _f = Box::new(0); - // This call used to trigger an LLVM bug in opt-level z where the base - // pointer gets corrupted, see issue #45034 - let y: fn(i32, i32) -> i64 = test::black_box(foo); - test::black_box(y(1, 2)); -} - -fn main() { - bar(); -} diff --git a/tests/run-make/rlib-chain/Makefile b/tests/run-make/rlib-chain/Makefile deleted file mode 100644 index 7a1f887fa5271..0000000000000 --- a/tests/run-make/rlib-chain/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) m1.rs - $(RUSTC) m2.rs - $(RUSTC) m3.rs - $(RUSTC) m4.rs - $(call RUN,m4) - rm $(TMPDIR)/*lib - $(call RUN,m4) diff --git a/tests/run-make/rlib-chain/rmake.rs b/tests/run-make/rlib-chain/rmake.rs new file mode 100644 index 0000000000000..0947262bf6200 --- /dev/null +++ b/tests/run-make/rlib-chain/rmake.rs @@ -0,0 +1,23 @@ +// In this test, m4 depends on m3, which depends on m2, which depends on m1. +// Even though dependencies are chained like this and there is no direct mention +// of m1 or m2 in m4.rs, compilation and execution should still succeed. Unlike +// the dylib-chain test, rlibs do not contain upstream dependencies, and removing +// the libraries still allows m4 to successfully execute. +// See https://github.com/rust-lang/rust/issues/10434 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{fs_wrapper, run, rust_lib_name, rustc}; + +fn main() { + rustc().input("m1.rs").run(); + rustc().input("m2.rs").run(); + rustc().input("m3.rs").run(); + rustc().input("m4.rs").run(); + run("m4"); + fs_wrapper::remove_file(rust_lib_name("m1")); + fs_wrapper::remove_file(rust_lib_name("m2")); + fs_wrapper::remove_file(rust_lib_name("m3")); + run("m4"); +} diff --git a/tests/run-make/test-harness/Makefile b/tests/run-make/test-harness/Makefile deleted file mode 100644 index ee8c9294f91ab..0000000000000 --- a/tests/run-make/test-harness/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - # check that #[cfg_attr(..., ignore)] does the right thing. - $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg - $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' - $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" - $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/tests/run-make/test-harness/rmake.rs b/tests/run-make/test-harness/rmake.rs new file mode 100644 index 0000000000000..1d211d2f6eb10 --- /dev/null +++ b/tests/run-make/test-harness/rmake.rs @@ -0,0 +1,21 @@ +// The way test suites run can be modified using configuration flags, +// ignoring certain tests while running others. This test contains two +// functions, one which must run and the other which must not. The standard +// output is checked to verify that the ignore configuration is doing its job, +// and that output is successfully minimized with the --quiet flag. +// See https://github.com/rust-lang/rust/commit/f7ebe23ae185991b0fee05b32fbb3e29b89a41bf + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{run, run_with_args, rustc}; + +fn main() { + rustc().arg("--test").input("test-ignore-cfg.rs").cfg("ignorecfg").run(); + // check that #[cfg_attr(..., ignore)] does the right thing. + run("test-ignore-cfg") + .assert_stdout_contains("shouldnotignore ... ok") + .assert_stdout_contains("shouldignore ... ignored"); + run_with_args("test-ignore-cfg", &["--quiet"]).assert_stdout_contains("i."); + run_with_args("test-ignore-cfg", &["--quiet"]).assert_stdout_not_contains("should"); +} diff --git a/tests/ui/windows-subsystem/console.rs b/tests/ui/windows/console.rs similarity index 100% rename from tests/ui/windows-subsystem/console.rs rename to tests/ui/windows/console.rs diff --git a/tests/ui/windows/msvc-opt-minsize.rs b/tests/ui/windows/msvc-opt-minsize.rs new file mode 100644 index 0000000000000..c1be168a05dde --- /dev/null +++ b/tests/ui/windows/msvc-opt-minsize.rs @@ -0,0 +1,31 @@ +// A previously outdated version of LLVM caused compilation failures on Windows +// specifically with optimization level `z`. After the update to a more recent LLVM +// version, this test checks that compilation and execution both succeed. +// See https://github.com/rust-lang/rust/issues/45034 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ only-windows +// Reason: the observed bug only occurs on Windows +//@ run-pass +//@ compile-flags: -C opt-level=z + +#![feature(test)] +extern crate test; + +fn foo(x: i32, y: i32) -> i64 { + (x + y) as i64 +} + +#[inline(never)] +fn bar() { + let _f = Box::new(0); + // This call used to trigger an LLVM bug in opt-level z where the base + // pointer gets corrupted, see issue #45034 + let y: fn(i32, i32) -> i64 = test::black_box(foo); + test::black_box(y(1, 2)); +} + +fn main() { + bar(); +} diff --git a/tests/ui/windows-subsystem/windows-subsystem-invalid.rs b/tests/ui/windows/windows-subsystem-invalid.rs similarity index 100% rename from tests/ui/windows-subsystem/windows-subsystem-invalid.rs rename to tests/ui/windows/windows-subsystem-invalid.rs diff --git a/tests/ui/windows-subsystem/windows-subsystem-invalid.stderr b/tests/ui/windows/windows-subsystem-invalid.stderr similarity index 100% rename from tests/ui/windows-subsystem/windows-subsystem-invalid.stderr rename to tests/ui/windows/windows-subsystem-invalid.stderr diff --git a/tests/ui/windows-subsystem/windows.rs b/tests/ui/windows/windows.rs similarity index 100% rename from tests/ui/windows-subsystem/windows.rs rename to tests/ui/windows/windows.rs