Rollup merge of #126964 - Oneirical:total-catestrophe, r=Kobzol

Migrate `lto-empty`, `invalid-so` and `issue-20626` `run-make` tests to rmake.rs

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
This commit is contained in:
Matthias Krüger 2024-06-26 07:50:20 +02:00 committed by GitHub
commit bf8da39aa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 50 additions and 32 deletions

View File

@ -55,13 +55,11 @@ run-make/incr-foreign-head-span/Makefile
run-make/interdependent-c-libraries/Makefile run-make/interdependent-c-libraries/Makefile
run-make/intrinsic-unreachable/Makefile run-make/intrinsic-unreachable/Makefile
run-make/invalid-library/Makefile run-make/invalid-library/Makefile
run-make/invalid-so/Makefile
run-make/issue-107094/Makefile run-make/issue-107094/Makefile
run-make/issue-109934-lto-debuginfo/Makefile run-make/issue-109934-lto-debuginfo/Makefile
run-make/issue-14698/Makefile run-make/issue-14698/Makefile
run-make/issue-15460/Makefile run-make/issue-15460/Makefile
run-make/issue-18943/Makefile run-make/issue-18943/Makefile
run-make/issue-20626/Makefile
run-make/issue-22131/Makefile run-make/issue-22131/Makefile
run-make/issue-25581/Makefile run-make/issue-25581/Makefile
run-make/issue-26006/Makefile run-make/issue-26006/Makefile
@ -97,7 +95,6 @@ run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile run-make/long-linker-command-lines/Makefile
run-make/longjmp-across-rust/Makefile run-make/longjmp-across-rust/Makefile
run-make/lto-dylib-dep/Makefile run-make/lto-dylib-dep/Makefile
run-make/lto-empty/Makefile
run-make/lto-linkage-used-attr/Makefile run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-smoke-c/Makefile run-make/lto-smoke-c/Makefile

View File

@ -1,7 +0,0 @@
include ../tools.mk
DYLIB_NAME := $(shell echo | $(RUSTC) --crate-name foo --crate-type dylib --print file-names -)
all:
echo >> $(TMPDIR)/$(DYLIB_NAME)
$(RUSTC) --crate-type lib --extern foo=$(TMPDIR)/$(DYLIB_NAME) bar.rs 2>&1 | $(CGREP) 'invalid metadata files for crate `foo`'

View File

@ -0,0 +1,17 @@
// When a fake library was given to the compiler, it would
// result in an obscure and unhelpful error message. This test
// creates a false "foo" dylib, and checks that the standard error
// explains that the file exists, but that its metadata is incorrect.
// See https://github.com/rust-lang/rust/pull/88368
use run_make_support::{dynamic_lib_name, fs_wrapper, rustc};
fn main() {
fs_wrapper::create_file(dynamic_lib_name("foo"));
rustc()
.crate_type("lib")
.extern_("foo", dynamic_lib_name("foo"))
.input("bar.rs")
.run_fail()
.assert_stderr_contains("invalid metadata files for crate `foo`");
}

View File

@ -1,9 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# Test output to be four
# The original error only occurred when printing, not when comparing using assert!
all:
$(RUSTC) foo.rs -O
[ `$(call RUN,foo)` = "4" ]

View File

@ -1,13 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all: cdylib-fat cdylib-thin
cdylib-fat:
$(RUSTC) lib.rs -C lto=fat -C opt-level=3 -C incremental=$(TMPDIR)/inc-fat
$(RUSTC) lib.rs -C lto=fat -C opt-level=3 -C incremental=$(TMPDIR)/inc-fat
cdylib-thin:
$(RUSTC) lib.rs -C lto=thin -C opt-level=3 -C incremental=$(TMPDIR)/inc-thin
$(RUSTC) lib.rs -C lto=thin -C opt-level=3 -C incremental=$(TMPDIR)/inc-thin

View File

@ -0,0 +1,17 @@
// Compiling Rust code twice in a row with "fat" link-time-optimizations used to cause
// an internal compiler error (ICE). This was due to how the compiler would cache some modules
// to make subsequent compilations faster, at least one of which was required for LTO to link
// into. After this was patched in #63956, this test checks that the bug does not make
// a resurgence.
// See https://github.com/rust-lang/rust/issues/63349
//@ ignore-cross-compile
use run_make_support::rustc;
fn main() {
rustc().input("lib.rs").arg("-Clto=fat").opt_level("3").incremental("inc-fat").run();
rustc().input("lib.rs").arg("-Clto=fat").opt_level("3").incremental("inc-fat").run();
rustc().input("lib.rs").arg("-Clto=thin").opt_level("3").incremental("inc-thin").run();
rustc().input("lib.rs").arg("-Clto=thin").opt_level("3").incremental("inc-thin").run();
}

View File

@ -0,0 +1,16 @@
// Despite the absence of any unsafe Rust code, foo.rs in this test would,
// because of the raw function pointer,
// cause undefined behavior and fail to print the expected result, "4" -
// only when activating optimizations (opt-level 2). This test checks
// that this bug does not make a resurgence.
// Note that the bug cannot be observed in an assert_eq!, only in the stdout.
// See https://github.com/rust-lang/rust/issues/20626
//@ ignore-cross-compile
use run_make_support::{run, rustc};
fn main() {
rustc().input("foo.rs").opt().run();
run("foo").assert_stdout_equals("4");
}