authorbors <bors@rust-lang.org> 2024-06-29 07:12:17 UTC
committerbors <bors@rust-lang.org> 2024-06-29 07:12:17 UTC
log38d0f87a493e9ab736185d1d7d17a5c51652740f
treeb1ff96664a3535f81205dbb119eac12d5c6f67e5
parentd38cd229b75a7a608e4971c46d1fb5a99343e430
parent4c9eeda36d24e1da8bdf74bd344cd98cb4b98c09

Auto merge of #126698 - Oneirical:tessteract, r=Kobzol

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-msvc

14 files changed, 129 insertions(+), 75 deletions(-)

src/tools/compiletest/src/command-list.rs+2
......@@ -53,6 +53,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
5353 "ignore-gnu",
5454 "ignore-haiku",
5555 "ignore-horizon",
56 "ignore-i686-pc-windows-gnu",
5657 "ignore-i686-pc-windows-msvc",
5758 "ignore-illumos",
5859 "ignore-ios",
......@@ -174,6 +175,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
174175 "only-bpf",
175176 "only-cdb",
176177 "only-gnu",
178 "only-i686-pc-windows-gnu",
177179 "only-i686-pc-windows-msvc",
178180 "only-ios",
179181 "only-linux",
src/tools/tidy/src/allowed_run_make_makefiles.txt-4
......@@ -70,7 +70,6 @@ run-make/issue-37839/Makefile
7070run-make/issue-40535/Makefile
7171run-make/issue-47384/Makefile
7272run-make/issue-47551/Makefile
73run-make/issue-68794-textrel-on-minimal-lib/Makefile
7473run-make/issue-69368/Makefile
7574run-make/issue-83045/Makefile
7675run-make/issue-83112-incr-test-moved-file/Makefile
......@@ -137,7 +136,6 @@ run-make/profile/Makefile
137136run-make/prune-link-args/Makefile
138137run-make/raw-dylib-alt-calling-convention/Makefile
139138run-make/raw-dylib-c/Makefile
140run-make/raw-dylib-cross-compilation/Makefile
141139run-make/raw-dylib-custom-dlltool/Makefile
142140run-make/raw-dylib-import-name-type/Makefile
143141run-make/raw-dylib-inline-cross-dylib/Makefile
......@@ -187,9 +185,7 @@ run-make/track-path-dep-info/Makefile
187185run-make/track-pgo-dep-info/Makefile
188186run-make/translation/Makefile
189187run-make/type-mismatch-same-crate-name/Makefile
190run-make/unknown-mod-stdin/Makefile
191188run-make/unstable-flag-required/Makefile
192run-make/used-cdylib-macos/Makefile
193189run-make/volatile-intrinsics/Makefile
194190run-make/wasm-exceptions-nostd/Makefile
195191run-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
10include ../tools.mk
11
12# only-linux
13
14all:
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 @@
1void foo();
2
3int 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]
4pub 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
8include ../tools.mk
9
10all:
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
12use run_make_support::{llvm_objdump, rust_lib_name, rustc};
13
14fn 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 @@
1void foo();
2
3int 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]
4pub 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
12use run_make_support::{
13 cc, dynamic_lib_name, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name,
14};
15
16fn 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
3include ../tools.mk
4
5all:
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
12use run_make_support::{diff, rustc};
13
14fn 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 @@
1include ../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
9all:
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
7use run_make_support::{dynamic_lib_name, llvm_readobj, rustc};
8
9fn 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}