From 060a13e9fd56b1d186ea016070e390067b9e893d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 18 Jun 2024 15:59:33 -0400 Subject: [PATCH 1/5] rewrite extern-flag-rename-transitive to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../extern-flag-rename-transitive/Makefile | 7 ------- .../extern-flag-rename-transitive/rmake.rs | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/extern-flag-rename-transitive/Makefile create mode 100644 tests/run-make/extern-flag-rename-transitive/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 1596257747f..6f57cb717ac 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -40,7 +40,6 @@ run-make/export-executable-symbols/Makefile run-make/extern-diff-internal-name/Makefile run-make/extern-flag-disambiguates/Makefile run-make/extern-flag-pathless/Makefile -run-make/extern-flag-rename-transitive/Makefile run-make/extern-fn-explicit-align/Makefile run-make/extern-fn-generic/Makefile run-make/extern-fn-mangle/Makefile diff --git a/tests/run-make/extern-flag-rename-transitive/Makefile b/tests/run-make/extern-flag-rename-transitive/Makefile deleted file mode 100644 index d16a8e20868..00000000000 --- a/tests/run-make/extern-flag-rename-transitive/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(RUSTC) baz.rs --extern a=$(TMPDIR)/libfoo.rlib - diff --git a/tests/run-make/extern-flag-rename-transitive/rmake.rs b/tests/run-make/extern-flag-rename-transitive/rmake.rs new file mode 100644 index 00000000000..0090d487f03 --- /dev/null +++ b/tests/run-make/extern-flag-rename-transitive/rmake.rs @@ -0,0 +1,14 @@ +// In this test, baz.rs is looking for an extern crate "a" which +// does not exist, and can only run through the --extern rustc flag +// defining that the "a" crate is in fact just "foo". This test +// checks that the --extern flag takes precedence over the extern +// crate statement in the code. +// See https://github.com/rust-lang/rust/pull/52723 + +use run_make_support::{rust_lib_name, rustc}; + +fn main() { + rustc().input("foo.rs").run(); + rustc().input("bar.rs").run(); + rustc().input("baz.rs").extern_("a", rust_lib_name("foo")).run(); +} From 9e2ace85f9d2a9fd24af197f2da81eb3a5db51b9 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 18 Jun 2024 16:05:56 -0400 Subject: [PATCH 2/5] rewrite debugger-visualizer-dep-info to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/debugger-visualizer-dep-info/Makefile | 9 --------- tests/run-make/debugger-visualizer-dep-info/rmake.rs | 11 +++++++++++ 3 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 tests/run-make/debugger-visualizer-dep-info/Makefile create mode 100644 tests/run-make/debugger-visualizer-dep-info/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 6f57cb717ac..4091cbbbcb8 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -23,7 +23,6 @@ run-make/cross-lang-lto-pgo-smoketest/Makefile run-make/cross-lang-lto-upstream-rlibs/Makefile run-make/cross-lang-lto/Makefile run-make/debug-assertions/Makefile -run-make/debugger-visualizer-dep-info/Makefile run-make/dep-info-doesnt-run-much/Makefile run-make/dep-info-spaces/Makefile run-make/dep-info/Makefile diff --git a/tests/run-make/debugger-visualizer-dep-info/Makefile b/tests/run-make/debugger-visualizer-dep-info/Makefile deleted file mode 100644 index 0877998a74f..00000000000 --- a/tests/run-make/debugger-visualizer-dep-info/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -# This test makes sure that files referenced via #[debugger_visualizer] are -# included in `--emit dep-info` output. - -all: - $(RUSTC) --emit dep-info main.rs - $(CGREP) "foo.py" < $(TMPDIR)/main.d - $(CGREP) "my_visualizers/bar.natvis" < $(TMPDIR)/main.d diff --git a/tests/run-make/debugger-visualizer-dep-info/rmake.rs b/tests/run-make/debugger-visualizer-dep-info/rmake.rs new file mode 100644 index 00000000000..65ffb2373e7 --- /dev/null +++ b/tests/run-make/debugger-visualizer-dep-info/rmake.rs @@ -0,0 +1,11 @@ +// This test checks that files referenced via #[debugger_visualizer] are +// included in `--emit dep-info` output. +// See https://github.com/rust-lang/rust/pull/111641 + +use run_make_support::{invalid_utf8_contains, rustc}; + +fn main() { + rustc().emit("dep-info").input("main.rs").run(); + invalid_utf8_contains("main.d", "foo.py"); + invalid_utf8_contains("main.d", "my_visualizers/bar.natvis"); +} From dff354e57fe030f8fa0467f092b75e8979a3cce9 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 18 Jun 2024 16:20:32 -0400 Subject: [PATCH 3/5] rewrite metadata-flag-frobs-symbols to rmake --- src/tools/run-make-support/src/rustc.rs | 6 ++++++ .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../metadata-flag-frobs-symbols/Makefile | 11 ---------- .../metadata-flag-frobs-symbols/rmake.rs | 21 +++++++++++++++++++ 4 files changed, 27 insertions(+), 12 deletions(-) delete mode 100644 tests/run-make/metadata-flag-frobs-symbols/Makefile create mode 100644 tests/run-make/metadata-flag-frobs-symbols/rmake.rs diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index 331e1a5ab8b..125f4b4bd62 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -73,6 +73,12 @@ pub fn opt_level(&mut self, option: &str) -> &mut Self { self } + /// Incorporate a hashed string to mangled symbols. + pub fn metadata(&mut self, meta: &str) -> &mut Self { + self.cmd.arg(format!("-Cmetadata={meta}")); + self + } + /// Add a suffix in each output filename. pub fn extra_filename(&mut self, suffix: &str) -> &mut Self { self.cmd.arg(format!("-Cextra-filename={suffix}")); diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 4091cbbbcb8..691248ea260 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -119,7 +119,6 @@ run-make/macos-fat-archive/Makefile run-make/manual-link/Makefile run-make/many-crates-but-no-match/Makefile run-make/metadata-dep-info/Makefile -run-make/metadata-flag-frobs-symbols/Makefile run-make/min-global-align/Makefile run-make/mingw-export-call-convention/Makefile run-make/mismatching-target-triples/Makefile diff --git a/tests/run-make/metadata-flag-frobs-symbols/Makefile b/tests/run-make/metadata-flag-frobs-symbols/Makefile deleted file mode 100644 index 53d7d065769..00000000000 --- a/tests/run-make/metadata-flag-frobs-symbols/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a - $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b - $(RUSTC) bar.rs \ - --extern foo1=$(TMPDIR)/libfoo-a.rlib \ - --extern foo2=$(TMPDIR)/libfoo-b.rlib \ - --print link-args - $(call RUN,bar) diff --git a/tests/run-make/metadata-flag-frobs-symbols/rmake.rs b/tests/run-make/metadata-flag-frobs-symbols/rmake.rs new file mode 100644 index 00000000000..12c07f9e3ae --- /dev/null +++ b/tests/run-make/metadata-flag-frobs-symbols/rmake.rs @@ -0,0 +1,21 @@ +// In this test, foo.rs is compiled twice with different hashes tied to its +// symbols thanks to the metadata flag. bar.rs then ensures that the memory locations +// of foo's symbols are different even though they came from the same original source code. +// This checks that the metadata flag is doing its job. +// See https://github.com/rust-lang/rust/issues/14471 + +//@ ignore-cross-compile + +use run_make_support::{run, rust_lib_name, rustc}; + +fn main() { + rustc().input("foo.rs").metadata("a").extra_filename("-a").run(); + rustc().input("foo.rs").metadata("b").extra_filename("-b").run(); + rustc() + .input("bar.rs") + .extern_("foo1", rust_lib_name("foo-a")) + .extern_("foo2", rust_lib_name("foo-b")) + .print("link-args") + .run(); + run("bar"); +} From d1e8c6bc7e93b6649e9dab0604dcc591dde03af0 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 18 Jun 2024 16:30:26 -0400 Subject: [PATCH 4/5] rewrite extern-overrides-distribution to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../extern-overrides-distribution/Makefile | 6 ------ .../extern-overrides-distribution/rmake.rs | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/extern-overrides-distribution/Makefile create mode 100644 tests/run-make/extern-overrides-distribution/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 691248ea260..8eee16e87a8 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -49,7 +49,6 @@ run-make/extern-fn-with-packed-struct/Makefile run-make/extern-fn-with-union/Makefile run-make/extern-multiple-copies/Makefile run-make/extern-multiple-copies2/Makefile -run-make/extern-overrides-distribution/Makefile run-make/extra-filename-with-temp-outputs/Makefile run-make/fmt-write-bloat/Makefile run-make/forced-unwind-terminate-pof/Makefile diff --git a/tests/run-make/extern-overrides-distribution/Makefile b/tests/run-make/extern-overrides-distribution/Makefile deleted file mode 100644 index bfd0dd6991b..00000000000 --- a/tests/run-make/extern-overrides-distribution/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) libc.rs -Cmetadata=foo - $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib diff --git a/tests/run-make/extern-overrides-distribution/rmake.rs b/tests/run-make/extern-overrides-distribution/rmake.rs new file mode 100644 index 00000000000..bd2553d4134 --- /dev/null +++ b/tests/run-make/extern-overrides-distribution/rmake.rs @@ -0,0 +1,14 @@ +// The --extern flag should override any "crate_type" declarations in the +// Rust files themselves. In this test, libc is compiled as "lib", but +// main.rs will only run with an rlib, which checks if the --extern flag +// is successfully overriding the default behaviour. +// See https://github.com/rust-lang/rust/pull/21782 + +//@ ignore-cross-compile + +use run_make_support::{rust_lib_name, rustc}; + +fn main() { + rustc().input("libc.rs").metadata("foo").run(); + rustc().input("main.rs").extern_("libc", rust_lib_name("libc")).run(); +} From e7ea063622d4a150fb22030b78d21b18f4855481 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 18 Jun 2024 16:43:52 -0400 Subject: [PATCH 5/5] rewrite forced-unwind-terminate-pof to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../forced-unwind-terminate-pof/Makefile | 9 --------- .../forced-unwind-terminate-pof/rmake.rs | 16 ++++++++++++++++ .../metadata-flag-frobs-symbols/rmake.rs | 1 - 4 files changed, 16 insertions(+), 11 deletions(-) delete mode 100644 tests/run-make/forced-unwind-terminate-pof/Makefile create mode 100644 tests/run-make/forced-unwind-terminate-pof/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 8eee16e87a8..a5ccb1b7842 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -51,7 +51,6 @@ run-make/extern-multiple-copies/Makefile run-make/extern-multiple-copies2/Makefile run-make/extra-filename-with-temp-outputs/Makefile run-make/fmt-write-bloat/Makefile -run-make/forced-unwind-terminate-pof/Makefile run-make/foreign-double-unwind/Makefile run-make/foreign-exceptions/Makefile run-make/foreign-rust-exceptions/Makefile diff --git a/tests/run-make/forced-unwind-terminate-pof/Makefile b/tests/run-make/forced-unwind-terminate-pof/Makefile deleted file mode 100644 index 871621520b9..00000000000 --- a/tests/run-make/forced-unwind-terminate-pof/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# ignore-cross-compile -# only-linux -include ../tools.mk - -all: foo - $(call RUN,foo) | $(CGREP) -v "cannot unwind" - -foo: foo.rs - $(RUSTC) $< diff --git a/tests/run-make/forced-unwind-terminate-pof/rmake.rs b/tests/run-make/forced-unwind-terminate-pof/rmake.rs new file mode 100644 index 00000000000..320ddb172b6 --- /dev/null +++ b/tests/run-make/forced-unwind-terminate-pof/rmake.rs @@ -0,0 +1,16 @@ +// During a forced unwind, crossing the non-Plain Old Frame +// would define the forced unwind as undefined behaviour, and +// immediately abort the unwinding process. This test checks +// that the forced unwinding takes precedence. +// See https://github.com/rust-lang/rust/issues/101469 + +//@ ignore-cross-compile +//@ ignore-windows +//Reason: pthread (POSIX threads) is not available on Windows + +use run_make_support::{run, rustc}; + +fn main() { + rustc().input("foo.rs").run(); + run("foo").assert_stdout_not_contains("cannot unwind"); +} diff --git a/tests/run-make/metadata-flag-frobs-symbols/rmake.rs b/tests/run-make/metadata-flag-frobs-symbols/rmake.rs index 12c07f9e3ae..938886957fb 100644 --- a/tests/run-make/metadata-flag-frobs-symbols/rmake.rs +++ b/tests/run-make/metadata-flag-frobs-symbols/rmake.rs @@ -15,7 +15,6 @@ fn main() { .input("bar.rs") .extern_("foo1", rust_lib_name("foo-a")) .extern_("foo2", rust_lib_name("foo-b")) - .print("link-args") .run(); run("bar"); }