From b167a15d64c0777afa6b90d7883368c629049a16 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 19 Jun 2024 15:46:27 -0400 Subject: [PATCH] rewrite rmeta-preferred to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/include-bytes-deps/rmake.rs | 2 -- .../metadata-only-crate-no-ice/rmake.rs | 4 ++-- tests/run-make/rmeta-preferred/Makefile | 16 ---------------- tests/run-make/rmeta-preferred/rmake.rs | 18 ++++++++++++++++++ 5 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 tests/run-make/rmeta-preferred/Makefile create mode 100644 tests/run-make/rmeta-preferred/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 4fbfa442fcc..70c1b055c6e 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -132,7 +132,6 @@ run-make/return-non-c-like-enum-from-c/Makefile run-make/rlib-format-packed-bundled-libs-2/Makefile run-make/rlib-format-packed-bundled-libs-3/Makefile run-make/rlib-format-packed-bundled-libs/Makefile -run-make/rmeta-preferred/Makefile run-make/rustc-macro-dep-files/Makefile run-make/sanitizer-cdylib-link/Makefile run-make/sanitizer-dylib-link/Makefile diff --git a/tests/run-make/include-bytes-deps/rmake.rs b/tests/run-make/include-bytes-deps/rmake.rs index 6ca29fa664c..ea371ddae56 100644 --- a/tests/run-make/include-bytes-deps/rmake.rs +++ b/tests/run-make/include-bytes-deps/rmake.rs @@ -3,8 +3,6 @@ // and this test checks that this is still the case. // See https://github.com/rust-lang/rust/pull/24423 -//FIXME(Oneirical): check if works without ignore freebsd - use run_make_support::{invalid_utf8_contains, rustc}; fn main() { diff --git a/tests/run-make/metadata-only-crate-no-ice/rmake.rs b/tests/run-make/metadata-only-crate-no-ice/rmake.rs index 825da12cfd1..e6f852fca41 100644 --- a/tests/run-make/metadata-only-crate-no-ice/rmake.rs +++ b/tests/run-make/metadata-only-crate-no-ice/rmake.rs @@ -9,6 +9,6 @@ fn main() { rustc().input("baz.rs").emit("metadata").run(); rustc().input("bar.rs").emit("metadata").extern_("baz", "libbaz.rmeta").run(); - // There should be no internal compiler error message. - rustc().input("foo.rs").emit("metadata").extern_("bar", "libbaz.rmeta").run().assert_stderr_not_contains("unexpectedly panicked"); + // There should be no internal compiler error. + rustc().input("foo.rs").emit("metadata").extern_("bar", "libbaz.rmeta").run(); } diff --git a/tests/run-make/rmeta-preferred/Makefile b/tests/run-make/rmeta-preferred/Makefile deleted file mode 100644 index 3bf12cced29..00000000000 --- a/tests/run-make/rmeta-preferred/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Test that using rlibs and rmeta dep crates work together. Specifically, that -# there can be both an rmeta and an rlib file and rustc will prefer the rmeta -# file. -# -# This behavior is simply making sure this doesn't accidentally change; in this -# case we want to make sure that the rlib isn't being used as that would cause -# bugs in -Zbinary-dep-depinfo (see #68298). - -all: - $(RUSTC) rmeta_aux.rs --crate-type=rlib --emit link,metadata - $(RUSTC) lib.rs --crate-type=rlib --emit dep-info -Zbinary-dep-depinfo - $(CGREP) "librmeta_aux.rmeta" < $(TMPDIR)/lib.d - $(CGREP) -v "librmeta_aux.rlib" < $(TMPDIR)/lib.d diff --git a/tests/run-make/rmeta-preferred/rmake.rs b/tests/run-make/rmeta-preferred/rmake.rs new file mode 100644 index 00000000000..09cba06e2f5 --- /dev/null +++ b/tests/run-make/rmeta-preferred/rmake.rs @@ -0,0 +1,18 @@ +// This test compiles `lib.rs`'s dependency, `rmeta_aux.rs`, as both an rlib +// and an rmeta crate. By default, rustc should give the metadata crate (rmeta) +// precedence over the rust-lib (rlib). This test inspects the contents of the binary +// and that the correct (rmeta) crate was used. +// rlibs being preferred could indicate a resurgence of the -Zbinary-dep-depinfo bug +// seen in #68298. +// See https://github.com/rust-lang/rust/pull/37681 + +//@ ignore-cross-compile + +use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rustc}; + +fn main() { + rustc().input("rmeta_aux.rs").crate_type("rlib").emit("link,metadata").run(); + rustc().input("lib.rs").crate_type("rlib").emit("dep-info").arg("-Zbinary-dep-depinfo").run(); + invalid_utf8_contains("lib.d", "librmeta_aux.rmeta"); + invalid_utf8_not_contains("lib.d", "librmeta_aux.rlib"); +}