From c24d1c7ff8fd6374a8bf8b1172e04ae828da438d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 22 May 2024 14:40:41 -0400 Subject: [PATCH 1/3] Rewrite `core-no-oom-handling` as rmake.rs --- src/tools/run-make-support/src/rustc.rs | 9 ++++++++- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/core-no-oom-handling/Makefile | 6 ------ tests/run-make/core-no-oom-handling/rmake.rs | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/core-no-oom-handling/Makefile create mode 100644 tests/run-make/core-no-oom-handling/rmake.rs diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index f581204d5f1..1c83b630861 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -156,13 +156,20 @@ pub fn crate_type(&mut self, crate_type: &str) -> &mut Self { self } - /// Add a directory to the library search path. Equivalent to `-L`` in rustc. + /// Add a directory to the library search path. Equivalent to `-L` in rustc. pub fn library_search_path>(&mut self, path: P) -> &mut Self { self.cmd.arg("-L"); self.cmd.arg(path.as_ref()); self } + /// Override the system root. Equivalent to `--sysroot` in rustc. + pub fn sysroot>(&mut self, path: P) -> &mut Self { + self.cmd.arg("--sysroot"); + self.cmd.arg(path.as_ref()); + self + } + /// Specify the edition year. pub fn edition(&mut self, edition: &str) -> &mut Self { self.cmd.arg("--edition"); diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 96fb8e27e6d..2d62a064fae 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -25,7 +25,6 @@ run-make/compiler-rt-works-on-mingw/Makefile run-make/compressed-debuginfo/Makefile run-make/const-prop-lint/Makefile run-make/const_fn_mir/Makefile -run-make/core-no-oom-handling/Makefile run-make/crate-data-smoke/Makefile run-make/crate-hash-rustc-version/Makefile run-make/crate-name-priority/Makefile diff --git a/tests/run-make/core-no-oom-handling/Makefile b/tests/run-make/core-no-oom-handling/Makefile deleted file mode 100644 index 28c5261ff85..00000000000 --- a/tests/run-make/core-no-oom-handling/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -include ../tools.mk - -FAKEROOT=$(TMPDIR)/fakeroot - -all: - $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --sysroot=$(FAKEROOT) --cfg no_global_oom_handling diff --git a/tests/run-make/core-no-oom-handling/rmake.rs b/tests/run-make/core-no-oom-handling/rmake.rs new file mode 100644 index 00000000000..8b697e3cfa3 --- /dev/null +++ b/tests/run-make/core-no-oom-handling/rmake.rs @@ -0,0 +1,16 @@ +// This test checks that the core library can still compile correctly +// when the no_global_oom_handling feature is turned on. +// See https://github.com/rust-lang/rust/pull/110649 + +use run_make_support::{rustc, tmp_dir}; + +fn main() { + rustc() + .edition("2021") + .arg("-Dwarnings") + .crate_type("rlib") + .input("../../../library/core/src/lib.rs") + .sysroot(tmp_dir().join("fakeroot")); + .cfg("no_global_oom_handling") + .run(); +} From d4e5426256db81e8a5fc7b737f373a162b632a45 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 22 May 2024 15:25:43 -0400 Subject: [PATCH 2/3] rewrite and rename `issue-24445` to rmake --- src/tools/run-make-support/src/cc.rs | 8 +++++ .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/issue-24445/Makefile | 11 ------ .../foo.c | 0 .../foo.rs | 0 tests/run-make/non-pie-thread-local/rmake.rs | 36 +++++++++++++++++++ 6 files changed, 44 insertions(+), 12 deletions(-) delete mode 100644 tests/run-make/issue-24445/Makefile rename tests/run-make/{issue-24445 => non-pie-thread-local}/foo.c (100%) rename tests/run-make/{issue-24445 => non-pie-thread-local}/foo.rs (100%) create mode 100644 tests/run-make/non-pie-thread-local/rmake.rs diff --git a/src/tools/run-make-support/src/cc.rs b/src/tools/run-make-support/src/cc.rs index a67f5c8a9ee..799c36b1049 100644 --- a/src/tools/run-make-support/src/cc.rs +++ b/src/tools/run-make-support/src/cc.rs @@ -45,6 +45,14 @@ pub fn input>(&mut self, path: P) -> &mut Self { self } + /// Adds directories to the list that the linker searches for libraries. + /// Equivalent to `-L`. + pub fn library_search_path>(&mut self, path: P) -> &mut Self { + self.cmd.arg("-L"); + self.cmd.arg(path.as_ref()); + self + } + /// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable /// is under `$TMPDIR`. pub fn out_exe(&mut self, name: &str) -> &mut Self { diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2d62a064fae..b4b40bdd7fb 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -97,7 +97,6 @@ run-make/issue-15460/Makefile run-make/issue-18943/Makefile run-make/issue-20626/Makefile run-make/issue-22131/Makefile -run-make/issue-24445/Makefile run-make/issue-25581/Makefile run-make/issue-26006/Makefile run-make/issue-26092/Makefile diff --git a/tests/run-make/issue-24445/Makefile b/tests/run-make/issue-24445/Makefile deleted file mode 100644 index a13910aa73e..00000000000 --- a/tests/run-make/issue-24445/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# only-linux - -all: - $(RUSTC) foo.rs - $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo - $(call RUN,foo) - $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo - $(call RUN,foo) diff --git a/tests/run-make/issue-24445/foo.c b/tests/run-make/non-pie-thread-local/foo.c similarity index 100% rename from tests/run-make/issue-24445/foo.c rename to tests/run-make/non-pie-thread-local/foo.c diff --git a/tests/run-make/issue-24445/foo.rs b/tests/run-make/non-pie-thread-local/foo.rs similarity index 100% rename from tests/run-make/issue-24445/foo.rs rename to tests/run-make/non-pie-thread-local/foo.rs diff --git a/tests/run-make/non-pie-thread-local/rmake.rs b/tests/run-make/non-pie-thread-local/rmake.rs new file mode 100644 index 00000000000..fb89e4199c7 --- /dev/null +++ b/tests/run-make/non-pie-thread-local/rmake.rs @@ -0,0 +1,36 @@ +// It was once required to use a position-independent executable (PIE) +// in order to use the thread_local! macro, or some symbols would contain +// a NULL address. This was fixed, and this test checks a non-PIE, then a PIE +// build to see if this bug makes a resurgence. +// See https://github.com/rust-lang/rust/pull/24448 + +//@ ignore-cross compile +//@ only-linux + +use run_make_support::{cc, run, rustc, tmp_dir}; + +fn main() { + rustc().input("foo.rs").run(); + cc().input("foo.c") + .arg("-lfoo") + .library_search_path(tmp_dir()) + .arg("-Wl") + .arg("--gc-sections") + .arg("-lpthread") + .arg("-ldl") + .out_exe(tmp_dir().join("foo")) + .run(); + run("foo"); + cc().input("foo.c") + .arg("-lfoo") + .library_search_path(tmp_dir()) + .arg("-Wl") + .arg("--gc-sections") + .arg("-lpthread") + .arg("-ldl") + .arg("-pie") + .arg("-fPIC") + .out_exe(tmp_dir().join("foo")) + .run(); + run("foo"); +} From 1f17e27ae3ebcf20ac20534ce443b8ab61c01f50 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 22 May 2024 15:55:02 -0400 Subject: [PATCH 3/3] Rewrite and rename `issue-38237` to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/alloc-no-oom-handling/rmake.rs | 2 +- tests/run-make/alloc-no-rc/rmake.rs | 2 +- tests/run-make/alloc-no-sync/rmake.rs | 2 +- tests/run-make/core-no-oom-handling/rmake.rs | 4 ++-- .../bar.rs | 0 .../baz.rs | 0 .../foo.rs | 0 tests/run-make/deref-impl-rustdoc-ice/rmake.rs | 16 ++++++++++++++++ tests/run-make/issue-38237/Makefile | 6 ------ tests/run-make/non-pie-thread-local/rmake.rs | 12 +++++------- 11 files changed, 26 insertions(+), 19 deletions(-) rename tests/run-make/{issue-38237 => deref-impl-rustdoc-ice}/bar.rs (100%) rename tests/run-make/{issue-38237 => deref-impl-rustdoc-ice}/baz.rs (100%) rename tests/run-make/{issue-38237 => deref-impl-rustdoc-ice}/foo.rs (100%) create mode 100644 tests/run-make/deref-impl-rustdoc-ice/rmake.rs delete mode 100644 tests/run-make/issue-38237/Makefile diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index b4b40bdd7fb..9da830236e2 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -107,7 +107,6 @@ run-make/issue-35164/Makefile run-make/issue-36710/Makefile run-make/issue-37839/Makefile run-make/issue-37893/Makefile -run-make/issue-38237/Makefile run-make/issue-40535/Makefile run-make/issue-46239/Makefile run-make/issue-47384/Makefile diff --git a/tests/run-make/alloc-no-oom-handling/rmake.rs b/tests/run-make/alloc-no-oom-handling/rmake.rs index fec3c653294..4bca5d1f1ef 100644 --- a/tests/run-make/alloc-no-oom-handling/rmake.rs +++ b/tests/run-make/alloc-no-oom-handling/rmake.rs @@ -1,4 +1,4 @@ -// This test checks that alloc can still compile correctly +// This test checks that alloc can still compile successfully // when the unstable no_global_oom_handling feature is turned on. // See https://github.com/rust-lang/rust/pull/84266 diff --git a/tests/run-make/alloc-no-rc/rmake.rs b/tests/run-make/alloc-no-rc/rmake.rs index c5744a3f5ee..8ff73324b08 100644 --- a/tests/run-make/alloc-no-rc/rmake.rs +++ b/tests/run-make/alloc-no-rc/rmake.rs @@ -1,4 +1,4 @@ -// This test checks that alloc can still compile correctly +// This test checks that alloc can still compile successfully // when the unstable no_rc feature is turned on. // See https://github.com/rust-lang/rust/pull/84266 diff --git a/tests/run-make/alloc-no-sync/rmake.rs b/tests/run-make/alloc-no-sync/rmake.rs index 6410eca80ab..3a3ceed6867 100644 --- a/tests/run-make/alloc-no-sync/rmake.rs +++ b/tests/run-make/alloc-no-sync/rmake.rs @@ -1,4 +1,4 @@ -// This test checks that alloc can still compile correctly +// This test checks that alloc can still compile successfully // when the unstable no_sync feature is turned on. // See https://github.com/rust-lang/rust/pull/84266 diff --git a/tests/run-make/core-no-oom-handling/rmake.rs b/tests/run-make/core-no-oom-handling/rmake.rs index 8b697e3cfa3..75767421cd1 100644 --- a/tests/run-make/core-no-oom-handling/rmake.rs +++ b/tests/run-make/core-no-oom-handling/rmake.rs @@ -1,4 +1,4 @@ -// This test checks that the core library can still compile correctly +// This test checks that the core library can still compile successfully // when the no_global_oom_handling feature is turned on. // See https://github.com/rust-lang/rust/pull/110649 @@ -10,7 +10,7 @@ fn main() { .arg("-Dwarnings") .crate_type("rlib") .input("../../../library/core/src/lib.rs") - .sysroot(tmp_dir().join("fakeroot")); + .sysroot(tmp_dir().join("fakeroot")) .cfg("no_global_oom_handling") .run(); } diff --git a/tests/run-make/issue-38237/bar.rs b/tests/run-make/deref-impl-rustdoc-ice/bar.rs similarity index 100% rename from tests/run-make/issue-38237/bar.rs rename to tests/run-make/deref-impl-rustdoc-ice/bar.rs diff --git a/tests/run-make/issue-38237/baz.rs b/tests/run-make/deref-impl-rustdoc-ice/baz.rs similarity index 100% rename from tests/run-make/issue-38237/baz.rs rename to tests/run-make/deref-impl-rustdoc-ice/baz.rs diff --git a/tests/run-make/issue-38237/foo.rs b/tests/run-make/deref-impl-rustdoc-ice/foo.rs similarity index 100% rename from tests/run-make/issue-38237/foo.rs rename to tests/run-make/deref-impl-rustdoc-ice/foo.rs diff --git a/tests/run-make/deref-impl-rustdoc-ice/rmake.rs b/tests/run-make/deref-impl-rustdoc-ice/rmake.rs new file mode 100644 index 00000000000..c2156de03a9 --- /dev/null +++ b/tests/run-make/deref-impl-rustdoc-ice/rmake.rs @@ -0,0 +1,16 @@ +// A very specific set of circumstances (mainly, implementing Deref, and +// having a procedural macro and a Debug derivation in external crates) caused +// an internal compiler error (ICE) when trying to use rustdoc. This test +// reproduces the exact circumstances which caused the bug and checks +// that it does not happen again. +// See https://github.com/rust-lang/rust/issues/38237 + +//@ ignore-cross-compile + +use run_make_support::{rustc, rustdoc, tmp_dir}; + +fn main() { + rustc().input("foo.rs").run(); + rustc().input("bar.rs").run(); + rustdoc().input("baz.rs").library_search_path(tmp_dir()).output(tmp_dir()).run(); +} diff --git a/tests/run-make/issue-38237/Makefile b/tests/run-make/issue-38237/Makefile deleted file mode 100644 index 80dddc5bd13..00000000000 --- a/tests/run-make/issue-38237/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) foo.rs; $(RUSTC) bar.rs - $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) diff --git a/tests/run-make/non-pie-thread-local/rmake.rs b/tests/run-make/non-pie-thread-local/rmake.rs index fb89e4199c7..1ef447e7860 100644 --- a/tests/run-make/non-pie-thread-local/rmake.rs +++ b/tests/run-make/non-pie-thread-local/rmake.rs @@ -4,7 +4,7 @@ // build to see if this bug makes a resurgence. // See https://github.com/rust-lang/rust/pull/24448 -//@ ignore-cross compile +//@ ignore-cross-compile //@ only-linux use run_make_support::{cc, run, rustc, tmp_dir}; @@ -14,23 +14,21 @@ fn main() { cc().input("foo.c") .arg("-lfoo") .library_search_path(tmp_dir()) - .arg("-Wl") - .arg("--gc-sections") + .arg("-Wl,--gc-sections") .arg("-lpthread") .arg("-ldl") - .out_exe(tmp_dir().join("foo")) + .out_exe("foo") .run(); run("foo"); cc().input("foo.c") .arg("-lfoo") .library_search_path(tmp_dir()) - .arg("-Wl") - .arg("--gc-sections") + .arg("-Wl,--gc-sections") .arg("-lpthread") .arg("-ldl") .arg("-pie") .arg("-fPIC") - .out_exe(tmp_dir().join("foo")) + .out_exe("foo") .run(); run("foo"); }