From 10db8c7bc220dd3cbbdc66e95aa270a26bcd8a8f Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 17 Jun 2024 15:14:21 -0400 Subject: [PATCH 1/3] rewrite separate-link to rmake.rs --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/separate-link/Makefile | 7 ------- tests/run-make/separate-link/rmake.rs | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/separate-link/Makefile create mode 100644 tests/run-make/separate-link/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index fdd0be79a4de7..47d92dafb6190 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -203,7 +203,6 @@ run-make/sanitizer-cdylib-link/Makefile run-make/sanitizer-dylib-link/Makefile run-make/sanitizer-staticlib-link/Makefile run-make/separate-link-fail/Makefile -run-make/separate-link/Makefile run-make/sepcomp-cci-copies/Makefile run-make/sepcomp-inlining/Makefile run-make/sepcomp-separate/Makefile diff --git a/tests/run-make/separate-link/Makefile b/tests/run-make/separate-link/Makefile deleted file mode 100644 index d01158d9f5fb0..0000000000000 --- a/tests/run-make/separate-link/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - echo 'fn main(){}' | $(RUSTC) -Z no-link - - $(RUSTC) -Z link-only $(TMPDIR)/rust_out.rlink - $(call RUN,rust_out) diff --git a/tests/run-make/separate-link/rmake.rs b/tests/run-make/separate-link/rmake.rs new file mode 100644 index 0000000000000..e063a1e5ab7b3 --- /dev/null +++ b/tests/run-make/separate-link/rmake.rs @@ -0,0 +1,14 @@ +// The compiler flags no-link (and by extension, link-only) used to be broken +// due to changes in encoding/decoding. This was patched, and this test ensures +// that these flags are not broken again, resulting in successful compilation. +// See https://github.com/rust-lang/rust/issues/77857 + +//@ ignore-cross-compile + +use run_make_support::{run, rustc}; + +fn main() { + rustc().stdin(b"fn main(){}").arg("-Zno-link").arg("-").run(); + rustc().arg("-Zlink-only").input("rust_out.rlink").run(); + run("rust_out"); +} From dfba1b5ccafc490594a8f5a8b99b643279d55945 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 17 Jun 2024 15:59:39 -0400 Subject: [PATCH 2/3] rewrite separate-link-fail to rmake.rs --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/separate-link-fail/Makefile | 7 ------- tests/run-make/separate-link-fail/foo.rs | 1 + tests/run-make/separate-link-fail/rmake.rs | 15 +++++++++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/separate-link-fail/Makefile create mode 100644 tests/run-make/separate-link-fail/foo.rs create mode 100644 tests/run-make/separate-link-fail/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 47d92dafb6190..8f1d36bb26d82 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -202,7 +202,6 @@ run-make/rustdoc-io-error/Makefile run-make/sanitizer-cdylib-link/Makefile run-make/sanitizer-dylib-link/Makefile run-make/sanitizer-staticlib-link/Makefile -run-make/separate-link-fail/Makefile run-make/sepcomp-cci-copies/Makefile run-make/sepcomp-inlining/Makefile run-make/sepcomp-separate/Makefile diff --git a/tests/run-make/separate-link-fail/Makefile b/tests/run-make/separate-link-fail/Makefile deleted file mode 100644 index bfd18fbf972d6..0000000000000 --- a/tests/run-make/separate-link-fail/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -include ../tools.mk - -all: - echo 'fn main(){}' > $(TMPDIR)/main.rs - # Make sure that this fails - ! $(RUSTC) -Z link-only $(TMPDIR)/main.rs 2> $(TMPDIR)/stderr.txt - $(CGREP) "The input does not look like a .rlink file" < $(TMPDIR)/stderr.txt diff --git a/tests/run-make/separate-link-fail/foo.rs b/tests/run-make/separate-link-fail/foo.rs new file mode 100644 index 0000000000000..f328e4d9d04c3 --- /dev/null +++ b/tests/run-make/separate-link-fail/foo.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/separate-link-fail/rmake.rs b/tests/run-make/separate-link-fail/rmake.rs new file mode 100644 index 0000000000000..b5d5300de68f7 --- /dev/null +++ b/tests/run-make/separate-link-fail/rmake.rs @@ -0,0 +1,15 @@ +// rustc usually wants Rust code as its input. The flag `link-only` is one +// exception, where a .rlink file is instead requested. The compiler should +// fail when the user is wrongly passing the original Rust code +// instead of the generated .rlink file when this flag is on. +// https://github.com/rust-lang/rust/issues/95297 + +use run_make_support::rustc; + +fn main() { + rustc() + .arg("-Zlink-only") + .input("foo.rs") + .run_fail() + .assert_stderr_contains("The input does not look like a .rlink file"); +} From 78998f3fea3aba636e50aa0a6abcafa51d66eff7 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 17 Jun 2024 16:11:14 -0400 Subject: [PATCH 3/3] rewrite allocator-shim-circular-deps to ui test --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../allocator-shim-circular-deps/Makefile | 12 ------------ .../allocator-shim-circular-deps/rmake.rs | 16 ++++++++++++++++ tests/run-make/separate-link/rmake.rs | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 tests/run-make/allocator-shim-circular-deps/Makefile create mode 100644 tests/run-make/allocator-shim-circular-deps/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 8f1d36bb26d82..39a567b13a4fe 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -1,4 +1,3 @@ -run-make/allocator-shim-circular-deps/Makefile run-make/archive-duplicate-names/Makefile run-make/atomic-lock-free/Makefile run-make/branch-protection-check-IBT/Makefile diff --git a/tests/run-make/allocator-shim-circular-deps/Makefile b/tests/run-make/allocator-shim-circular-deps/Makefile deleted file mode 100644 index f667e2e2ec293..0000000000000 --- a/tests/run-make/allocator-shim-circular-deps/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# This test is designed to intentionally introduce a circular dependency scenario to check that a specific compiler bug doesn't make a resurgence. -# The bug in question arose when at least one crate required a global allocator, and that crate was placed after the one defining it in the linker order. -# The generated symbols.o should not result in any linker errors. -# See https://github.com/rust-lang/rust/issues/112715 - -# ignore-cross-compile -include ../tools.mk - -all: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) my_lib.rs - $(RUSTC) main.rs --test --extern my_lib=$(TMPDIR)/libmy_lib.rlib diff --git a/tests/run-make/allocator-shim-circular-deps/rmake.rs b/tests/run-make/allocator-shim-circular-deps/rmake.rs new file mode 100644 index 0000000000000..7d6b0bd204a13 --- /dev/null +++ b/tests/run-make/allocator-shim-circular-deps/rmake.rs @@ -0,0 +1,16 @@ +// This test is designed to intentionally introduce a circular dependency scenario to check +// that a specific compiler bug doesn't make a resurgence. +// The bug in question arose when at least one crate +// required a global allocator, and that crate was placed after +// the one defining it in the linker order. +// The generated symbols.o should not result in any linker errors. +// See https://github.com/rust-lang/rust/issues/112715 + +//@ ignore-cross-compile + +use run_make_support::{rust_lib_name, rustc}; + +fn main() { + rustc().input("my_lib.rs").run(); + rustc().input("main.rs").arg("--test").extern_("my_lib", rust_lib_name("my_lib")).run(); +} diff --git a/tests/run-make/separate-link/rmake.rs b/tests/run-make/separate-link/rmake.rs index e063a1e5ab7b3..e91b25489bc59 100644 --- a/tests/run-make/separate-link/rmake.rs +++ b/tests/run-make/separate-link/rmake.rs @@ -1,5 +1,5 @@ // The compiler flags no-link (and by extension, link-only) used to be broken -// due to changes in encoding/decoding. This was patched, and this test ensures +// due to changes in encoding/decoding. This was patched, and this test checks // that these flags are not broken again, resulting in successful compilation. // See https://github.com/rust-lang/rust/issues/77857