From 6ba0a84df9172ea01f3c3661b4d8364e5a79ba69 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 25 Jun 2024 14:27:43 -0400 Subject: [PATCH 1/3] rewrite lto-empty to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/lto-empty/Makefile | 13 ------------- tests/run-make/lto-empty/rmake.rs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 tests/run-make/lto-empty/Makefile create mode 100644 tests/run-make/lto-empty/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 07073ef5d40..7c882d3ce15 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/long-linker-command-lines-cmd-exe/Makefile run-make/long-linker-command-lines/Makefile run-make/longjmp-across-rust/Makefile run-make/lto-dylib-dep/Makefile -run-make/lto-empty/Makefile run-make/lto-linkage-used-attr/Makefile run-make/lto-no-link-whole-rlib/Makefile run-make/lto-smoke-c/Makefile diff --git a/tests/run-make/lto-empty/Makefile b/tests/run-make/lto-empty/Makefile deleted file mode 100644 index 1b795c4b738..00000000000 --- a/tests/run-make/lto-empty/Makefile +++ /dev/null @@ -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 - diff --git a/tests/run-make/lto-empty/rmake.rs b/tests/run-make/lto-empty/rmake.rs new file mode 100644 index 00000000000..7146d6e10ef --- /dev/null +++ b/tests/run-make/lto-empty/rmake.rs @@ -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(); +} From fe2406bcef7d0c51a39537283c7c151c8a2da238 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 25 Jun 2024 14:45:49 -0400 Subject: [PATCH 2/3] rewrite invalid-so to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/invalid-so/Makefile | 7 ------- tests/run-make/invalid-so/rmake.rs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/invalid-so/Makefile create mode 100644 tests/run-make/invalid-so/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 7c882d3ce15..560fd5c586e 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -55,7 +55,6 @@ run-make/incr-foreign-head-span/Makefile run-make/interdependent-c-libraries/Makefile run-make/intrinsic-unreachable/Makefile run-make/invalid-library/Makefile -run-make/invalid-so/Makefile run-make/issue-107094/Makefile run-make/issue-109934-lto-debuginfo/Makefile run-make/issue-14698/Makefile diff --git a/tests/run-make/invalid-so/Makefile b/tests/run-make/invalid-so/Makefile deleted file mode 100644 index e36c7040bc6..00000000000 --- a/tests/run-make/invalid-so/Makefile +++ /dev/null @@ -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`' diff --git a/tests/run-make/invalid-so/rmake.rs b/tests/run-make/invalid-so/rmake.rs new file mode 100644 index 00000000000..5cfda05334e --- /dev/null +++ b/tests/run-make/invalid-so/rmake.rs @@ -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`"); +} From ee529b72f911250a4c5b717f42fb955cdc08aad5 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 25 Jun 2024 15:02:19 -0400 Subject: [PATCH 3/3] rewrite and rename issue-20626 to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/issue-20626/Makefile | 9 --------- .../foo.rs | 0 .../rmake.rs | 16 ++++++++++++++++ 4 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 tests/run-make/issue-20626/Makefile rename tests/run-make/{issue-20626 => raw-fn-pointer-opt-undefined-behavior}/foo.rs (100%) create mode 100644 tests/run-make/raw-fn-pointer-opt-undefined-behavior/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 560fd5c586e..cb68589d8a4 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -60,7 +60,6 @@ run-make/issue-109934-lto-debuginfo/Makefile run-make/issue-14698/Makefile run-make/issue-15460/Makefile run-make/issue-18943/Makefile -run-make/issue-20626/Makefile run-make/issue-22131/Makefile run-make/issue-25581/Makefile run-make/issue-26006/Makefile diff --git a/tests/run-make/issue-20626/Makefile b/tests/run-make/issue-20626/Makefile deleted file mode 100644 index 63eee910a9c..00000000000 --- a/tests/run-make/issue-20626/Makefile +++ /dev/null @@ -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" ] diff --git a/tests/run-make/issue-20626/foo.rs b/tests/run-make/raw-fn-pointer-opt-undefined-behavior/foo.rs similarity index 100% rename from tests/run-make/issue-20626/foo.rs rename to tests/run-make/raw-fn-pointer-opt-undefined-behavior/foo.rs diff --git a/tests/run-make/raw-fn-pointer-opt-undefined-behavior/rmake.rs b/tests/run-make/raw-fn-pointer-opt-undefined-behavior/rmake.rs new file mode 100644 index 00000000000..61cf559a8fe --- /dev/null +++ b/tests/run-make/raw-fn-pointer-opt-undefined-behavior/rmake.rs @@ -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"); +}