authorbors <bors@rust-lang.org> 2024-07-10 08:51:20 UTC
committerbors <bors@rust-lang.org> 2024-07-10 08:51:20 UTC
log0fdfb61795b40037955154638fe35f20b16c8e55
tree4fe2c87674a1be8f09cde38542a243cbfc80b890
parent649feb9c1a3c56650a4b6fa638b23103cbcd0dcd
parentd44732120cfd6f49d49bc333ad60c0539aedee19

Auto merge of #127006 - Oneirical:holmes-the-detestive, r=Kobzol

Migrate `extern-flag-pathless`, `silly-file-names`, `metadata-dep-info`, `cdylib-fewer-symbols` and `symbols-include-type-name` `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). `cdylib-fewer-symbols` demands a Windows try-job. (Almost guaranteed to fail, but 7 years is a long time) try-job: x86_64-gnu-distcheck try-job: x86_64-msvc try-job: aarch64-apple

13 files changed, 125 insertions(+), 87 deletions(-)

src/tools/tidy/src/allowed_run_make_makefiles.txt-5
......@@ -9,7 +9,6 @@ run-make/c-unwind-abi-catch-lib-panic/Makefile
99run-make/c-unwind-abi-catch-panic/Makefile
1010run-make/cat-and-grep-sanity-check/Makefile
1111run-make/cdylib-dylib-linkage/Makefile
12run-make/cdylib-fewer-symbols/Makefile
1312run-make/compiler-lookup-paths-2/Makefile
1413run-make/compiler-lookup-paths/Makefile
1514run-make/compiler-rt-works-on-mingw/Makefile
......@@ -28,7 +27,6 @@ run-make/env-dep-info/Makefile
2827run-make/export-executable-symbols/Makefile
2928run-make/extern-diff-internal-name/Makefile
3029run-make/extern-flag-disambiguates/Makefile
31run-make/extern-flag-pathless/Makefile
3230run-make/extern-fn-explicit-align/Makefile
3331run-make/extern-fn-generic/Makefile
3432run-make/extern-fn-mangle/Makefile
......@@ -86,7 +84,6 @@ run-make/lto-smoke-c/Makefile
8684run-make/macos-deployment-target/Makefile
8785run-make/macos-fat-archive/Makefile
8886run-make/manual-link/Makefile
89run-make/metadata-dep-info/Makefile
9087run-make/min-global-align/Makefile
9188run-make/missing-crate-dependency/Makefile
9289run-make/mixing-libs/Makefile
......@@ -126,7 +123,6 @@ run-make/sanitizer-cdylib-link/Makefile
126123run-make/sanitizer-dylib-link/Makefile
127124run-make/sanitizer-staticlib-link/Makefile
128125run-make/share-generics-dylib/Makefile
129run-make/silly-file-names/Makefile
130126run-make/simd-ffi/Makefile
131127run-make/split-debuginfo/Makefile
132128run-make/stable-symbol-names/Makefile
......@@ -137,7 +133,6 @@ run-make/staticlib-dylib-linkage/Makefile
137133run-make/std-core-cycle/Makefile
138134run-make/symbol-mangling-hashed/Makefile
139135run-make/symbol-visibility/Makefile
140run-make/symbols-include-type-name/Makefile
141136run-make/sysroot-crates-are-unstable/Makefile
142137run-make/test-benches/Makefile
143138run-make/thumb-none-cortex-m/Makefile
tests/run-make/cdylib-fewer-symbols/Makefile deleted-15
......@@ -1,15 +0,0 @@
1# ignore-cross-compile
2
3# Test that allocator-related symbols don't show up as exported from a cdylib as
4# they're internal to Rust and not part of the public ABI.
5# See https://github.com/rust-lang/rust/commit/fbf98697021173a30b84d9145df0966a23a2f9d2
6
7include ../tools.mk
8
9# ignore-windows
10# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU
11# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753
12
13all:
14 $(RUSTC) foo.rs
15 nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_
tests/run-make/cdylib-fewer-symbols/rmake.rs created+21
......@@ -0,0 +1,21 @@
1// Symbols related to the allocator should be hidden and not exported from a cdylib,
2// for they are internal to Rust
3// and not part of the public ABI (application binary interface). This test checks that
4// four such symbols are successfully hidden.
5// See https://github.com/rust-lang/rust/pull/45710
6
7//@ ignore-cross-compile
8// Reason: The __rust_ symbol appears during cross-compilation.
9
10use run_make_support::{dynamic_lib_name, llvm_readobj, rustc};
11
12fn main() {
13 // Compile a cdylib
14 rustc().input("foo.rs").run();
15 let out =
16 llvm_readobj().arg("--dyn-symbols").input(dynamic_lib_name("foo")).run().stdout_utf8();
17 assert!(!&out.contains("__rdl_"), "{out}");
18 assert!(!&out.contains("__rde_"), "{out}");
19 assert!(!&out.contains("__rg_"), "{out}");
20 assert!(!&out.contains("__rust_"), "{out}");
21}
tests/run-make/extern-flag-pathless/Makefile deleted-34
......@@ -1,34 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test mixing pathless --extern with paths.
5
6# Test for static linking by checking that the binary runs if the dylib
7# is removed and test for dynamic linking by checking that the binary
8# fails to run if the dylib is removed.
9
10all:
11 $(RUSTC) bar.rs --crate-type=rlib --crate-type=dylib -Cprefer-dynamic
12
13 # rlib preferred over dylib
14 $(RUSTC) foo.rs --extern bar
15 mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
16 $(call RUN,foo)
17 mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
18
19 $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
20 mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
21 $(call RUN,foo)
22 mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
23
24 # explicit --extern overrides pathless
25 $(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
26 mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
27 $(call FAIL,foo)
28 mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
29
30 # prefer-dynamic does what it says
31 $(RUSTC) foo.rs --extern bar -C prefer-dynamic
32 mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
33 $(call FAIL,foo)
34 mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
tests/run-make/extern-flag-pathless/rmake.rs created+43
......@@ -0,0 +1,43 @@
1// It is possible, since #64882, to use the --extern flag without an explicit
2// path. In the event of two --extern flags, the explicit one with a path will take
3// priority, but otherwise, it is a more concise way of fetching specific libraries.
4// This test checks that the default priority of explicit extern flags and rlibs is
5// respected.
6// See https://github.com/rust-lang/rust/pull/64882
7
8//@ ignore-cross-compile
9// Reason: the compiled binary is executed
10
11use run_make_support::{dynamic_lib_name, fs_wrapper, run, run_fail, rust_lib_name, rustc};
12
13fn main() {
14 rustc().input("bar.rs").crate_type("rlib").crate_type("dylib").arg("-Cprefer-dynamic").run();
15
16 // By default, the rlib has priority over the dylib.
17 rustc().input("foo.rs").arg("--extern").arg("bar").run();
18 fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
19 run("foo");
20 fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
21
22 rustc().input("foo.rs").extern_("bar", rust_lib_name("bar")).arg("--extern").arg("bar").run();
23 fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
24 run("foo");
25 fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
26
27 // The first explicit usage of extern overrides the second pathless --extern bar.
28 rustc()
29 .input("foo.rs")
30 .extern_("bar", dynamic_lib_name("bar"))
31 .arg("--extern")
32 .arg("bar")
33 .run();
34 fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
35 run_fail("foo");
36 fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
37
38 // With prefer-dynamic, execution fails as it refuses to use the rlib.
39 rustc().input("foo.rs").arg("--extern").arg("bar").arg("-Cprefer-dynamic").run();
40 fs_wrapper::rename(dynamic_lib_name("bar"), "bar.tmp");
41 run_fail("foo");
42 fs_wrapper::rename("bar.tmp", dynamic_lib_name("bar"));
43}
tests/run-make/metadata-dep-info/Makefile deleted-7
......@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --emit=metadata,dep-info --crate-type lib dash-separated.rs -C extra-filename=_something-extra
5 # Strip TMPDIR since it is a machine specific absolute path
6 sed "s%.*[/\\]%%" "$(TMPDIR)"/dash-separated_something-extra.d > "$(TMPDIR)"/dash-separated_something-extra.normalized.d
7 $(RUSTC_TEST_OP) "$(TMPDIR)"/dash-separated_something-extra.normalized.d dash-separated_something-extra.normalized.d
tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d created+5
......@@ -0,0 +1,5 @@
1libdash_separated_something-extra.rmeta: dash-separated.rs
2
3dash-separated_something-extra.d: dash-separated.rs
4
5dash-separated.rs:
tests/run-make/metadata-dep-info/dash-separated_something-extra.normalized.d deleted-5
......@@ -1,5 +0,0 @@
1libdash_separated_something-extra.rmeta: dash-separated.rs
2
3dash-separated_something-extra.d: dash-separated.rs
4
5dash-separated.rs:
tests/run-make/metadata-dep-info/rmake.rs created+20
......@@ -0,0 +1,20 @@
1// Emitting dep-info alongside metadata would present subtle discrepancies
2// in the output file, such as the filename transforming underscores_ into hyphens-.
3// After the fix in #114750, this test checks that the emitted files are identical
4// to the expected output.
5// See https://github.com/rust-lang/rust/issues/68839
6
7use run_make_support::{diff, rustc};
8
9fn main() {
10 rustc()
11 .emit("metadata,dep-info")
12 .crate_type("lib")
13 .input("dash-separated.rs")
14 .extra_filename("_something-extra")
15 .run();
16 diff()
17 .expected_file("dash-separated_something-extra.expected.d")
18 .actual_file("dash-separated_something-extra.d")
19 .run();
20}
tests/run-make/silly-file-names/Makefile deleted-12
......@@ -1,12 +0,0 @@
1# ignore-cross-compile we need to execute the binary
2# ignore-windows we create files with < and > in their names
3
4include ../tools.mk
5
6all:
7 echo '"comes from a file with a name that begins with <"' > "$(TMPDIR)/<leading-lt"
8 echo '"comes from a file with a name that ends with >"' > "$(TMPDIR)/trailing-gt>"
9 cp silly-file-names.rs "$(TMPDIR)/silly-file-names.rs"
10 $(RUSTC) "$(TMPDIR)/silly-file-names.rs" -o "$(TMPDIR)/silly-file-names"
11 "$(TMPDIR)/silly-file-names" > "$(TMPDIR)/silly-file-names.run.stdout"
12 $(RUSTC_TEST_OP) "$(TMPDIR)/silly-file-names.run.stdout" silly-file-names.run.stdout
tests/run-make/silly-file-names/rmake.rs created+24
......@@ -0,0 +1,24 @@
1// There used to be assert! checks in the compiler to error on encountering
2// files starting or ending with < or > respectively, as a preventive measure
3// against "fake" files like <anon>. However, this was not truly required,
4// as rustc has other checks to verify the veracity of a file. This test includes
5// some files with < and > in their names and prints out their output to stdout,
6// expecting no errors.
7// See https://github.com/rust-lang/rust/issues/73419
8
9//@ ignore-cross-compile
10// Reason: the compiled binary is executed
11//@ ignore-windows
12// Reason: Windows refuses files with < and > in their names
13
14use run_make_support::{diff, fs_wrapper, run, rustc};
15
16fn main() {
17 fs_wrapper::create_file("<leading-lt");
18 fs_wrapper::write("<leading-lt", r#""comes from a file with a name that begins with <""#);
19 fs_wrapper::create_file("trailing-gt>");
20 fs_wrapper::write("trailing-gt>", r#""comes from a file with a name that ends with >""#);
21 rustc().input("silly-file-names.rs").output("silly-file-names").run();
22 let out = run("silly-file-names").stdout_utf8();
23 diff().expected_file("silly-file-names.run.stdout").actual_text("actual-stdout", out).run();
24}
tests/run-make/symbols-include-type-name/Makefile deleted-9
......@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# Check that symbol names for methods include type names, instead of <impl>.
4
5OUT=$(TMPDIR)/lib.s
6
7all:
8 $(RUSTC) --crate-type staticlib --emit asm lib.rs
9 $(CGREP) Def < $(OUT)
tests/run-make/symbols-include-type-name/rmake.rs created+12
......@@ -0,0 +1,12 @@
1// Method names used to be obfuscated when exported into symbols,
2// leaving only an obscure `<impl>`. After the fix in #30328,
3// this test checks that method names are successfully saved in the symbol list.
4// See https://github.com/rust-lang/rust/issues/30260
5
6use run_make_support::{invalid_utf8_contains, rustc};
7
8fn main() {
9 rustc().crate_type("staticlib").emit("asm").input("lib.rs").run();
10 // Check that symbol names for methods include type names, instead of <impl>.
11 invalid_utf8_contains("lib.s", "Def");
12}