From 760b505c9aef6f6a144a9bb0e4836d27a502d77f Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 17 May 2024 11:06:21 -0400 Subject: [PATCH 1/4] Rewrite static-unwinding as rmake.rs --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/static-unwinding/Makefile | 8 -------- tests/run-make/static-unwinding/rmake.rs | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 tests/run-make/static-unwinding/Makefile create mode 100644 tests/run-make/static-unwinding/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 1a3d6f8d813..0ccb39d64e7 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -264,7 +264,6 @@ run-make/stable-symbol-names/Makefile run-make/static-dylib-by-default/Makefile run-make/static-extern-type/Makefile run-make/static-pie/Makefile -run-make/static-unwinding/Makefile run-make/staticlib-blank-lib/Makefile run-make/staticlib-dylib-linkage/Makefile run-make/std-core-cycle/Makefile diff --git a/tests/run-make/static-unwinding/Makefile b/tests/run-make/static-unwinding/Makefile deleted file mode 100644 index 4b093f93608..00000000000 --- a/tests/run-make/static-unwinding/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# ignore-cross-compile -# needs-unwind -include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) main.rs - $(call RUN,main) diff --git a/tests/run-make/static-unwinding/rmake.rs b/tests/run-make/static-unwinding/rmake.rs new file mode 100644 index 00000000000..ee3d9a342f9 --- /dev/null +++ b/tests/run-make/static-unwinding/rmake.rs @@ -0,0 +1,15 @@ +// During unwinding, an implementation of Drop is possible to clean up resources. +// This test implements drop in both a main function and its static library. +// If the test succeeds, a Rust program being a static library does not affect Drop implementations. +// See https://github.com/rust-lang/rust/issues/10434 + +//@ ignore-cross-compile +//@ needs-unwind + +use run_make_support::{run, rustc}; + +fn main() { + rustc().input("lib.rs").run(); + rustc().input("main.rs").run(); + run("main"); +} From 14a031fdf6c83ac51e614c2836c1768999758f3b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 17 May 2024 11:49:20 -0400 Subject: [PATCH 2/4] rewrite issue64319 and rename --- src/tools/run-make-support/src/rustc.rs | 6 +++ tests/run-make/issue64319/Makefile | 40 ----------------- .../bar.rs | 0 .../foo.rs | 0 .../share-generics-export-again/rmake.rs | 45 +++++++++++++++++++ 5 files changed, 51 insertions(+), 40 deletions(-) delete mode 100644 tests/run-make/issue64319/Makefile rename tests/run-make/{issue64319 => share-generics-export-again}/bar.rs (100%) rename tests/run-make/{issue64319 => share-generics-export-again}/foo.rs (100%) create mode 100644 tests/run-make/share-generics-export-again/rmake.rs diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index d034826a830..f581204d5f1 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -64,6 +64,12 @@ pub fn opt(&mut self) -> &mut Self { self } + /// Specify a specific optimization level. + pub fn opt_level(&mut self, option: &str) -> &mut Self { + self.cmd.arg(format!("-Copt-level={option}")); + self + } + /// Specify type(s) of output files to generate. pub fn emit(&mut self, kinds: &str) -> &mut Self { self.cmd.arg(format!("--emit={kinds}")); diff --git a/tests/run-make/issue64319/Makefile b/tests/run-make/issue64319/Makefile deleted file mode 100644 index 56346cbcc15..00000000000 --- a/tests/run-make/issue64319/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Different optimization levels imply different values for `-Zshare-generics`, -# so try out a whole bunch of combinations to make sure everything is compatible -all: - # First up, try some defaults - $(RUSTC) --crate-type rlib foo.rs - $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 - - # Next try mixing up some things explicitly - $(RUSTC) --crate-type rlib foo.rs -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no - $(RUSTC) --crate-type rlib foo.rs -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes - $(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no - $(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes - - # Now combine a whole bunch of options together - $(RUSTC) --crate-type rlib foo.rs - $(RUSTC) --crate-type dylib bar.rs - $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 - $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 - $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 - $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -C opt-level=s - $(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=yes - $(RUSTC) --crate-type dylib bar.rs -C opt-level=z - $(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=no - $(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=yes diff --git a/tests/run-make/issue64319/bar.rs b/tests/run-make/share-generics-export-again/bar.rs similarity index 100% rename from tests/run-make/issue64319/bar.rs rename to tests/run-make/share-generics-export-again/bar.rs diff --git a/tests/run-make/issue64319/foo.rs b/tests/run-make/share-generics-export-again/foo.rs similarity index 100% rename from tests/run-make/issue64319/foo.rs rename to tests/run-make/share-generics-export-again/foo.rs diff --git a/tests/run-make/share-generics-export-again/rmake.rs b/tests/run-make/share-generics-export-again/rmake.rs new file mode 100644 index 00000000000..b9964eb442a --- /dev/null +++ b/tests/run-make/share-generics-export-again/rmake.rs @@ -0,0 +1,45 @@ +// When crates had different optimization levels, a bug caused +// incorrect symbol name generations. -Z share-generics could +// also fail to re-export upstream generics on multiple compile +// runs of the same dynamic library. + +// This test repeatedly compiles an rlib and a dylib with these flags +// to check if this bug ever returns. + +// See https://github.com/rust-lang/rust/pull/68277 +// See https://github.com/rust-lang/rust/issues/64319 +//@ ignore-cross-compile + +use run_make_support::rustc; + +fn main() { + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("3").run(); + rustc().crate_type("rlib").input("foo.rs").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").arg("-Zshare-generics=no").run(); + rustc().crate_type("rlib").input("foo.rs").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").arg("-Zshare-generics=yes").run(); + rustc().crate_type("rlib").input("foo.rs").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").arg("-Zshare-generics=no").run(); + rustc().crate_type("rlib").input("foo.rs").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").arg("-Zshare-generics=yes").run(); + rustc().crate_type("rlib").input("foo.rs").run(); + rustc().crate_type("dylib").input("bar.rs").run(); + rustc().crate_type("dylib").input("bar.rs").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("1").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("1").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("1").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("2").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("2").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("2").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("3").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("3").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("3").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("s").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("s").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("s").arg("-Zshare-generics=yes").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("z").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("z").arg("-Zshare-generics=no").run(); + rustc().crate_type("dylib").input("bar.rs").opt_level("z").arg("-Zshare-generics=yes").run(); +} From 184be49a1ef3e77c69bc85f1b9f419928da48e9a Mon Sep 17 00:00:00 2001 From: Julien <96022417+Oneirical@users.noreply.github.com> Date: Fri, 17 May 2024 12:07:55 -0400 Subject: [PATCH 3/4] Update allowed_run_make_makefiles.txt --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 1a3d6f8d813..4f88454001a 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -128,7 +128,6 @@ run-make/issue-85401-static-mir/Makefile run-make/issue-85441/Makefile run-make/issue-88756-default-output/Makefile run-make/issue-97463-abi-param-passing/Makefile -run-make/issue64319/Makefile run-make/jobserver-error/Makefile run-make/libs-through-symlinks/Makefile run-make/libtest-json/Makefile From e9edced09694cbc27844acb44fa357ba94823fda Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 17 May 2024 14:41:54 -0400 Subject: [PATCH 4/4] rewrite and rename issue-28766 --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../{issue-28766 => box-struct-no-segfault}/foo.rs | 0 .../{issue-28766 => box-struct-no-segfault}/main.rs | 0 tests/run-make/box-struct-no-segfault/rmake.rs | 13 +++++++++++++ tests/run-make/issue-28766/Makefile | 5 ----- 5 files changed, 13 insertions(+), 6 deletions(-) rename tests/run-make/{issue-28766 => box-struct-no-segfault}/foo.rs (100%) rename tests/run-make/{issue-28766 => box-struct-no-segfault}/main.rs (100%) create mode 100644 tests/run-make/box-struct-no-segfault/rmake.rs delete mode 100644 tests/run-make/issue-28766/Makefile diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 1a3d6f8d813..a21a5bf9d99 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -103,7 +103,6 @@ run-make/issue-25581/Makefile run-make/issue-26006/Makefile run-make/issue-26092/Makefile run-make/issue-28595/Makefile -run-make/issue-28766/Makefile run-make/issue-30063/Makefile run-make/issue-33329/Makefile run-make/issue-35164/Makefile diff --git a/tests/run-make/issue-28766/foo.rs b/tests/run-make/box-struct-no-segfault/foo.rs similarity index 100% rename from tests/run-make/issue-28766/foo.rs rename to tests/run-make/box-struct-no-segfault/foo.rs diff --git a/tests/run-make/issue-28766/main.rs b/tests/run-make/box-struct-no-segfault/main.rs similarity index 100% rename from tests/run-make/issue-28766/main.rs rename to tests/run-make/box-struct-no-segfault/main.rs diff --git a/tests/run-make/box-struct-no-segfault/rmake.rs b/tests/run-make/box-struct-no-segfault/rmake.rs new file mode 100644 index 00000000000..5406f765e6c --- /dev/null +++ b/tests/run-make/box-struct-no-segfault/rmake.rs @@ -0,0 +1,13 @@ +// The crate "foo" tied to this test executes a very specific function, +// which involves boxing an instance of the struct Foo. However, +// this once caused a segmentation fault in cargo release builds due to an LLVM +// incorrect assertion. +// This test checks that this bug does not resurface. +// See https://github.com/rust-lang/rust/issues/28766 + +use run_make_support::{rustc, tmp_dir}; + +fn main() { + rustc().opt().input("foo.rs").run(); + rustc().opt().library_search_path(tmp_dir()).input("main.rs").run(); +} diff --git a/tests/run-make/issue-28766/Makefile b/tests/run-make/issue-28766/Makefile deleted file mode 100644 index 96d0bdc2b2a..00000000000 --- a/tests/run-make/issue-28766/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) -O foo.rs - $(RUSTC) -O -L $(TMPDIR) main.rs