| author | bors <bors@rust-lang.org> 2024-06-29 07:12:17 UTC |
| committer | bors <bors@rust-lang.org> 2024-06-29 07:12:17 UTC |
| log | 38d0f87a493e9ab736185d1d7d17a5c51652740f |
| tree | b1ff96664a3535f81205dbb119eac12d5c6f67e5 |
| parent | d38cd229b75a7a608e4971c46d1fb5a99343e430 |
| parent | 4c9eeda36d24e1da8bdf74bd344cd98cb4b98c09 |
Migrate `unknown-mod-stdin`, `issue-68794-textrel-on-minimal-lib`, `raw-dylib-cross-compilation` and `used-cdylib-macos` `run-make` tests to 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).
Seriously needs OSX/Windows try-jobs. If it fails, restore `only-linux` in `textrel-on-minimal-lib` and try again.
try-job: x86_64-mingw
try-job: x86_64-msvc14 files changed, 129 insertions(+), 75 deletions(-)
src/tools/compiletest/src/command-list.rs+2| ... | ... | @@ -53,6 +53,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ |
| 53 | 53 | "ignore-gnu", |
| 54 | 54 | "ignore-haiku", |
| 55 | 55 | "ignore-horizon", |
| 56 | "ignore-i686-pc-windows-gnu", | |
| 56 | 57 | "ignore-i686-pc-windows-msvc", |
| 57 | 58 | "ignore-illumos", |
| 58 | 59 | "ignore-ios", |
| ... | ... | @@ -174,6 +175,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ |
| 174 | 175 | "only-bpf", |
| 175 | 176 | "only-cdb", |
| 176 | 177 | "only-gnu", |
| 178 | "only-i686-pc-windows-gnu", | |
| 177 | 179 | "only-i686-pc-windows-msvc", |
| 178 | 180 | "only-ios", |
| 179 | 181 | "only-linux", |
src/tools/tidy/src/allowed_run_make_makefiles.txt-4| ... | ... | @@ -70,7 +70,6 @@ run-make/issue-37839/Makefile |
| 70 | 70 | run-make/issue-40535/Makefile |
| 71 | 71 | run-make/issue-47384/Makefile |
| 72 | 72 | run-make/issue-47551/Makefile |
| 73 | run-make/issue-68794-textrel-on-minimal-lib/Makefile | |
| 74 | 73 | run-make/issue-69368/Makefile |
| 75 | 74 | run-make/issue-83045/Makefile |
| 76 | 75 | run-make/issue-83112-incr-test-moved-file/Makefile |
| ... | ... | @@ -137,7 +136,6 @@ run-make/profile/Makefile |
| 137 | 136 | run-make/prune-link-args/Makefile |
| 138 | 137 | run-make/raw-dylib-alt-calling-convention/Makefile |
| 139 | 138 | run-make/raw-dylib-c/Makefile |
| 140 | run-make/raw-dylib-cross-compilation/Makefile | |
| 141 | 139 | run-make/raw-dylib-custom-dlltool/Makefile |
| 142 | 140 | run-make/raw-dylib-import-name-type/Makefile |
| 143 | 141 | run-make/raw-dylib-inline-cross-dylib/Makefile |
| ... | ... | @@ -187,9 +185,7 @@ run-make/track-path-dep-info/Makefile |
| 187 | 185 | run-make/track-pgo-dep-info/Makefile |
| 188 | 186 | run-make/translation/Makefile |
| 189 | 187 | run-make/type-mismatch-same-crate-name/Makefile |
| 190 | run-make/unknown-mod-stdin/Makefile | |
| 191 | 188 | run-make/unstable-flag-required/Makefile |
| 192 | run-make/used-cdylib-macos/Makefile | |
| 193 | 189 | run-make/volatile-intrinsics/Makefile |
| 194 | 190 | run-make/wasm-exceptions-nostd/Makefile |
| 195 | 191 | run-make/wasm-override-linker/Makefile |
tests/run-make/issue-68794-textrel-on-minimal-lib/Makefile deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | # ignore-cross-compile | |
| 2 | # Regression test for issue #68794 | |
| 3 | # | |
| 4 | # Verify that no text relocations are accidentally introduced by linking a | |
| 5 | # minimal rust staticlib. | |
| 6 | # | |
| 7 | # The test links a rust static library into a shared library, and checks that | |
| 8 | # the linker doesn't have to flag the resulting file as containing TEXTRELs. | |
| 9 | ||
| 10 | include ../tools.mk | |
| 11 | ||
| 12 | # only-linux | |
| 13 | ||
| 14 | all: | |
| 15 | 	$(RUSTC) foo.rs | |
| 16 | 	$(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \ | |
| 17 | 		$(EXTRACFLAGS) $(EXTRACXXFLAGS) | |
| 18 | 	readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1 |
tests/run-make/issue-68794-textrel-on-minimal-lib/bar.c deleted-6| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | void foo(); | |
| 2 | ||
| 3 | int main() { | |
| 4 | foo(); | |
| 5 | return 0; | |
| 6 | } |
tests/run-make/issue-68794-textrel-on-minimal-lib/foo.rs deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | #![crate_type = "staticlib"] | |
| 2 | ||
| 3 | #[no_mangle] | |
| 4 | pub extern "C" fn foo(x: u32) { | |
| 5 | // using the println! makes it so that enough code from the standard | |
| 6 | // library is included (see issue #68794) | |
| 7 | println!("foo: {}", x); | |
| 8 | } |
tests/run-make/raw-dylib-cross-compilation/Makefile deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | # Tests that raw-dylib cross compilation works correctly | |
| 2 | ||
| 3 | # needs-dlltool | |
| 4 | ||
| 5 | # i686 dlltool.exe can't product x64 binaries. | |
| 6 | # ignore-i686-pc-windows-gnu | |
| 7 | ||
| 8 | include ../tools.mk | |
| 9 | ||
| 10 | all: | |
| 11 | 	# Build as x86 and make sure that we have x86 objects only. | |
| 12 | 	$(RUSTC) --crate-type lib --crate-name i686_raw_dylib_test --target i686-pc-windows-gnu lib.rs | |
| 13 | 	"$(LLVM_BIN_DIR)"/llvm-objdump -a $(TMPDIR)/libi686_raw_dylib_test.rlib > $(TMPDIR)/i686.objdump.txt | |
| 14 | 	$(CGREP) "file format coff-i386" < $(TMPDIR)/i686.objdump.txt | |
| 15 | 	$(CGREP) -v "file format coff-x86-64" < $(TMPDIR)/i686.objdump.txt | |
| 16 | 	# Build as x64 and make sure that we have x64 objects only. | |
| 17 | 	$(RUSTC) --crate-type lib --crate-name x64_raw_dylib_test --target x86_64-pc-windows-gnu lib.rs | |
| 18 | 	"$(LLVM_BIN_DIR)"/llvm-objdump -a $(TMPDIR)/libx64_raw_dylib_test.rlib > $(TMPDIR)/x64.objdump.txt | |
| 19 | 	$(CGREP) "file format coff-x86-64" < $(TMPDIR)/x64.objdump.txt | |
| 20 | 	$(CGREP) -v "file format coff-i386" < $(TMPDIR)/x64.objdump.txt |
tests/run-make/raw-dylib-cross-compilation/rmake.rs created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | // When cross-compiling using `raw-dylib`, rustc would try to fetch some | |
| 2 | // very specific `dlltool` to complete the cross-compilation (such as `i686-w64-mingw32-dlltool`) | |
| 3 | // when Windows only calls it `dlltool`. This test performs some cross-compilation in a | |
| 4 | // way that previously failed due to this bug, and checks that it succeeds. | |
| 5 | // See https://github.com/rust-lang/rust/pull/108355 | |
| 6 | ||
| 7 | //@ ignore-i686-pc-windows-gnu | |
| 8 | // Reason: dlltool on this distribution is unable to produce x64 binaries | |
| 9 | //@ needs-dlltool | |
| 10 | // Reason: this is the utility being checked by this test | |
| 11 | ||
| 12 | use run_make_support::{llvm_objdump, rust_lib_name, rustc}; | |
| 13 | ||
| 14 | fn main() { | |
| 15 | // Build as x86 and make sure that we have x86 objects only. | |
| 16 | rustc() | |
| 17 | .crate_type("lib") | |
| 18 | .crate_name("i686_raw_dylib_test") | |
| 19 | .target("i686-pc-windows-gnu") | |
| 20 | .input("lib.rs") | |
| 21 | .run(); | |
| 22 | llvm_objdump() | |
| 23 | .arg("-a") | |
| 24 | .input(rust_lib_name("i686_raw_dylib_test")) | |
| 25 | .run() | |
| 26 | .assert_stdout_contains("file format coff-i386") | |
| 27 | .assert_stdout_not_contains("file format coff-x86-64"); | |
| 28 | // Build as x64 and make sure that we have x64 objects only. | |
| 29 | rustc() | |
| 30 | .crate_type("lib") | |
| 31 | .crate_name("x64_raw_dylib_test") | |
| 32 | .target("x86_64-pc-windows-gnu") | |
| 33 | .input("lib.rs") | |
| 34 | .run(); | |
| 35 | llvm_objdump() | |
| 36 | .arg("-a") | |
| 37 | .input(rust_lib_name("x64_raw_dylib_test")) | |
| 38 | .run() | |
| 39 | .assert_stdout_not_contains("file format coff-i386") | |
| 40 | .assert_stdout_contains("file format coff-x86-64"); | |
| 41 | } |
tests/run-make/textrel-on-minimal-lib/bar.c created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | void foo(); | |
| 2 | ||
| 3 | int main() { | |
| 4 | foo(); | |
| 5 | return 0; | |
| 6 | } |
tests/run-make/textrel-on-minimal-lib/foo.rs created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | #![crate_type = "staticlib"] | |
| 2 | ||
| 3 | #[no_mangle] | |
| 4 | pub extern "C" fn foo(x: u32) { | |
| 5 | // using the println! makes it so that enough code from the standard | |
| 6 | // library is included (see issue #68794) | |
| 7 | println!("foo: {}", x); | |
| 8 | } |
tests/run-make/textrel-on-minimal-lib/rmake.rs created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | // Verify that no text relocations are accidentally introduced by linking a | |
| 2 | // minimal rust staticlib. | |
| 3 | // The test links a rust static library into a shared library, and checks that | |
| 4 | // the linker doesn't have to flag the resulting file as containing TEXTRELs. | |
| 5 | // This bug otherwise breaks Android builds, which forbid TEXTRELs. | |
| 6 | // See https://github.com/rust-lang/rust/issues/68794 | |
| 7 | ||
| 8 | //@ ignore-cross-compile | |
| 9 | //@ ignore-windows | |
| 10 | // Reason: There is no `bar.dll` produced by CC to run readobj on | |
| 11 | ||
| 12 | use run_make_support::{ | |
| 13 | cc, dynamic_lib_name, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name, | |
| 14 | }; | |
| 15 | ||
| 16 | fn main() { | |
| 17 | rustc().input("foo.rs").run(); | |
| 18 | cc().input("bar.c") | |
| 19 | .input(static_lib_name("foo")) | |
| 20 | .out_exe(&dynamic_lib_name("bar")) | |
| 21 | .arg("-fPIC") | |
| 22 | .arg("-shared") | |
| 23 | .args(&extra_c_flags()) | |
| 24 | .args(&extra_cxx_flags()) | |
| 25 | .run(); | |
| 26 | llvm_readobj() | |
| 27 | .input(dynamic_lib_name("bar")) | |
| 28 | .arg("--dynamic") | |
| 29 | .run() | |
| 30 | .assert_stdout_not_contains("TEXTREL"); | |
| 31 | } |
tests/run-make/unknown-mod-stdin/Makefile deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | # ignore-windows | |
| 2 | ||
| 3 | include ../tools.mk | |
| 4 | ||
| 5 | all: | |
| 6 | 	echo 'mod unknown;' | $(RUSTC) --crate-type rlib - >$(TMPDIR)/unknown-mod.stdout 2>$(TMPDIR)/unknown-mod.stderr || echo "failed successfully" | |
| 7 | 	$(RUSTC_TEST_OP) "$(TMPDIR)"/unknown-mod.stdout unknown-mod.stdout | |
| 8 | 	$(RUSTC_TEST_OP) "$(TMPDIR)"/unknown-mod.stderr unknown-mod.stderr |
tests/run-make/unknown-mod-stdin/rmake.rs created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | // Rustc displays a compilation error when it finds a `mod` (module) | |
| 2 | // statement referencing a file that does not exist. However, a bug from 2019 | |
| 3 | // caused invalid `mod` statements to silently insert empty inline modules | |
| 4 | // instead of showing an error if the invalid `mod` statement had been passed | |
| 5 | // through standard input. This test checks that this bug does not make a resurgence. | |
| 6 | // See https://github.com/rust-lang/rust/issues/65601 | |
| 7 | ||
| 8 | // NOTE: This is not a UI test, because the bug which this test | |
| 9 | // is checking for is specifically tied to passing | |
| 10 | // `mod unknown;` through standard input. | |
| 11 | ||
| 12 | use run_make_support::{diff, rustc}; | |
| 13 | ||
| 14 | fn main() { | |
| 15 | let out = rustc().crate_type("rlib").stdin(b"mod unknown;").arg("-").run_fail(); | |
| 16 | diff() | |
| 17 | .actual_text("actual-stdout", out.stdout_utf8()) | |
| 18 | .expected_file("unknown-mod.stdout") | |
| 19 | .run(); | |
| 20 | diff() | |
| 21 | .actual_text("actual-stderr", out.stderr_utf8()) | |
| 22 | .expected_file("unknown-mod.stderr") | |
| 23 | .normalize(r#"\\"#, "/") | |
| 24 | .run(); | |
| 25 | } |
tests/run-make/used-cdylib-macos/Makefile deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | include ../tools.mk | |
| 2 | ||
| 3 | # only-apple | |
| 4 | # | |
| 5 | # This checks that `#[used]` passes through to the linker on | |
| 6 | # Apple targets. This is subject to change in the future, see | |
| 7 | # https://github.com/rust-lang/rust/pull/93718 for discussion | |
| 8 | ||
| 9 | all: | |
| 10 | 	$(RUSTC) -Copt-level=3 dylib_used.rs | |
| 11 | 	nm $(TMPDIR)/libdylib_used.dylib | $(CGREP) VERY_IMPORTANT_SYMBOL |
tests/run-make/used-cdylib-macos/rmake.rs created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | // This checks that `#[used]` passes through to the linker on | |
| 2 | // Apple targets. This is subject to change in the future. | |
| 3 | // See https://github.com/rust-lang/rust/pull/93718 | |
| 4 | ||
| 5 | //@ only-apple | |
| 6 | ||
| 7 | use run_make_support::{dynamic_lib_name, llvm_readobj, rustc}; | |
| 8 | ||
| 9 | fn main() { | |
| 10 | rustc().opt_level("3").input("dylib_used.rs").run(); | |
| 11 | llvm_readobj() | |
| 12 | .input(dynamic_lib_name("dylib_used")) | |
| 13 | .arg("--all") | |
| 14 | .run() | |
| 15 | .assert_stdout_contains("VERY_IMPORTANT_SYMBOL"); | |
| 16 | } |