Rollup merge of #125421 - Oneirical:bundle-them-yet-again, r=jieyouxu

Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

The test which is now called `non-pie-thread-local` has an unexplained "only-linux" flag. Could it be worth trying to remove it and changing the CI to test non-Linux platforms on it?
This commit is contained in:
Matthias Krüger 2024-05-23 14:09:25 +02:00 committed by GitHub
commit eb1b9b0048
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 85 additions and 30 deletions

View File

@ -45,6 +45,14 @@ impl Cc {
self
}
/// Adds directories to the list that the linker searches for libraries.
/// Equivalent to `-L`.
pub fn library_search_path<P: AsRef<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 {

View File

@ -156,13 +156,20 @@ impl Rustc {
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<P: AsRef<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<P: AsRef<Path>>(&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");

View File

@ -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
@ -98,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
@ -109,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-47384/Makefile
run-make/issue-47551/Makefile

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,16 @@
// 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
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();
}

View File

@ -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();
}

View File

@ -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)

View File

@ -1,6 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) foo.rs; $(RUSTC) bar.rs
$(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR)

View File

@ -0,0 +1,34 @@
// 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,--gc-sections")
.arg("-lpthread")
.arg("-ldl")
.out_exe("foo")
.run();
run("foo");
cc().input("foo.c")
.arg("-lfoo")
.library_search_path(tmp_dir())
.arg("-Wl,--gc-sections")
.arg("-lpthread")
.arg("-ldl")
.arg("-pie")
.arg("-fPIC")
.out_exe("foo")
.run();
run("foo");
}