From 75ee1d74a9ef4733971b1fb27f1e6219095dcb49 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 19 Jun 2024 16:18:33 -0400 Subject: [PATCH 1/3] rewrite relocation-model to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/relocation-model/Makefile | 20 -------------- tests/run-make/relocation-model/rmake.rs | 26 +++++++++++++++++++ 3 files changed, 26 insertions(+), 21 deletions(-) delete mode 100644 tests/run-make/relocation-model/Makefile create mode 100644 tests/run-make/relocation-model/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 2b273b92ec2d8..ad575e01609c9 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -164,7 +164,6 @@ run-make/raw-dylib-inline-cross-dylib/Makefile run-make/raw-dylib-link-ordinal/Makefile run-make/raw-dylib-stdcall-ordinal/Makefile run-make/redundant-libs/Makefile -run-make/relocation-model/Makefile run-make/relro-levels/Makefile run-make/remap-path-prefix-dwarf/Makefile run-make/remap-path-prefix/Makefile diff --git a/tests/run-make/relocation-model/Makefile b/tests/run-make/relocation-model/Makefile deleted file mode 100644 index 8cc5205ed51b4..0000000000000 --- a/tests/run-make/relocation-model/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: others - $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs - $(call RUN,foo) - - $(RUSTC) -C relocation-model=default foo.rs - $(call RUN,foo) - - $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj - -ifdef IS_MSVC -# FIXME(#28026) -others: -else -others: - $(RUSTC) -C relocation-model=static foo.rs - $(call RUN,foo) -endif diff --git a/tests/run-make/relocation-model/rmake.rs b/tests/run-make/relocation-model/rmake.rs new file mode 100644 index 0000000000000..978e2f685a64f --- /dev/null +++ b/tests/run-make/relocation-model/rmake.rs @@ -0,0 +1,26 @@ +// Generation of position-independent code (PIC) can be altered +// through use of the -C relocation-model rustc flag. This test +// uses varied values with this flag and checks that compilation +// succeeds. +// See https://github.com/rust-lang/rust/pull/13340 + +//@ ignore-cross-compile + +use run_make_support::{run, rustc}; + +fn main() { + // FIXME(Oneirical): This first one will likely fail on MSVC due to #28026. + // Remove this after try-job + rustc().arg("-Crelocation-model=static").input("foo.rs").run(); + run("foo"); + rustc().arg("-Crelocation-model=dynamic-no-pic").input("foo.rs").run(); + run("foo"); + rustc().arg("-Crelocation-model=default").input("foo.rs").run(); + run("foo"); + rustc() + .arg("-Crelocation-model=dynamic-no-pic") + .crate_type("dylib") + .emit("link,obj") + .input("foo.rs") + .run(); +} From f22b5afa6a4125ba9a9d0a2a43e60c282808c245 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 19 Jun 2024 16:43:22 -0400 Subject: [PATCH 2/3] rewrite error-writing-dependencies to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../error-writing-dependencies/Makefile | 8 -------- .../error-writing-dependencies/rmake.rs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 tests/run-make/error-writing-dependencies/Makefile create mode 100644 tests/run-make/error-writing-dependencies/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 ad575e01609c9..d5b981a508336 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -34,7 +34,6 @@ run-make/emit-shared-files/Makefile run-make/emit-stack-sizes/Makefile run-make/emit-to-stdout/Makefile run-make/env-dep-info/Makefile -run-make/error-writing-dependencies/Makefile run-make/export-executable-symbols/Makefile run-make/extern-diff-internal-name/Makefile run-make/extern-flag-disambiguates/Makefile diff --git a/tests/run-make/error-writing-dependencies/Makefile b/tests/run-make/error-writing-dependencies/Makefile deleted file mode 100644 index a5d30a647f817..0000000000000 --- a/tests/run-make/error-writing-dependencies/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../tools.mk - -all: - # Let's get a nice error message - $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \ - $(CGREP) "error writing dependencies" - # Make sure the filename shows up - $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz" diff --git a/tests/run-make/error-writing-dependencies/rmake.rs b/tests/run-make/error-writing-dependencies/rmake.rs new file mode 100644 index 0000000000000..2227f0a1a7f8a --- /dev/null +++ b/tests/run-make/error-writing-dependencies/rmake.rs @@ -0,0 +1,17 @@ +// Invalid paths passed to rustc used to cause internal compilation errors +// alongside an obscure error message. This was turned into a standard error, +// and this test checks that the cleaner error message is printed instead. +// See https://github.com/rust-lang/rust/issues/13517 + +use run_make_support::rustc; + +// NOTE: This cannot be a UI test due to the --out-dir flag, which is +// already present by default in UI testing. + +fn main() { + let out = rustc().input("foo.rs").emit("dep-info").out_dir("foo/bar/baz").run_fail(); + // The error message should be informative. + out.assert_stderr_contains("error writing dependencies"); + // The filename should appear. + out.assert_stderr_contains("baz"); +} From d37910a5b39c98144c3b2c39b1f83f57f84a4c2c Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 19 Jun 2024 16:52:36 -0400 Subject: [PATCH 3/3] rewrite crate-name-priority to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/crate-name-priority/Makefile | 12 ------------ tests/run-make/crate-name-priority/rmake.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 tests/run-make/crate-name-priority/Makefile create mode 100644 tests/run-make/crate-name-priority/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 d5b981a508336..df104ca9787c3 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -16,7 +16,6 @@ run-make/compiler-lookup-paths/Makefile run-make/compiler-rt-works-on-mingw/Makefile run-make/compressed-debuginfo/Makefile run-make/crate-hash-rustc-version/Makefile -run-make/crate-name-priority/Makefile run-make/cross-lang-lto-clang/Makefile run-make/cross-lang-lto-pgo-smoketest/Makefile run-make/cross-lang-lto-upstream-rlibs/Makefile diff --git a/tests/run-make/crate-name-priority/Makefile b/tests/run-make/crate-name-priority/Makefile deleted file mode 100644 index 4adaa75a71cf6..0000000000000 --- a/tests/run-make/crate-name-priority/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) foo.rs - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-name bar - rm $(TMPDIR)/$(call BIN,bar) - $(RUSTC) foo1.rs - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1) - rm $(TMPDIR)/$(call BIN,bar1) diff --git a/tests/run-make/crate-name-priority/rmake.rs b/tests/run-make/crate-name-priority/rmake.rs new file mode 100644 index 0000000000000..b7cb2c9971141 --- /dev/null +++ b/tests/run-make/crate-name-priority/rmake.rs @@ -0,0 +1,18 @@ +// The `crate_name` rustc flag should have higher priority +// over `#![crate_name = "foo"]` defined inside the source code. +// This test has a conflict between crate_names defined in the .rs files +// and the compiler flags, and checks that the flag is favoured each time. +// See https://github.com/rust-lang/rust/pull/15518 + +use run_make_support::{bin_name, fs_wrapper, rustc}; + +fn main() { + rustc().input("foo.rs").run(); + fs_wrapper::remove_file(bin_name("foo")); + rustc().input("foo.rs").crate_name("bar").run(); + fs_wrapper::remove_file(bin_name("bar")); + rustc().input("foo1.rs").run(); + fs_wrapper::remove_file(bin_name("foo")); + rustc().input("foo1.rs").output(bin_name("bar1")).run(); + fs_wrapper::remove_file(bin_name("bar1")); +}