From d83ada35ed22598398ee1cc629b8f544c627197f Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 16 Jul 2024 13:45:56 -0400 Subject: [PATCH 1/3] rewrite and rename issue-85401-static-mir --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../bar.rs | 0 .../baz.rs | 0 .../foo.rs | 0 tests/run-make/ice-static-mir/rmake.rs | 42 +++++++++++++++++++ .../run-make/issue-85401-static-mir/Makefile | 16 ------- 6 files changed, 42 insertions(+), 17 deletions(-) rename tests/run-make/{issue-85401-static-mir => ice-static-mir}/bar.rs (100%) rename tests/run-make/{issue-85401-static-mir => ice-static-mir}/baz.rs (100%) rename tests/run-make/{issue-85401-static-mir => ice-static-mir}/foo.rs (100%) create mode 100644 tests/run-make/ice-static-mir/rmake.rs delete mode 100644 tests/run-make/issue-85401-static-mir/Makefile diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2e26f9344b899..9e9d70bc6c630 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -54,7 +54,6 @@ run-make/issue-36710/Makefile run-make/issue-47551/Makefile run-make/issue-69368/Makefile run-make/issue-84395-lto-embed-bitcode/Makefile -run-make/issue-85401-static-mir/Makefile run-make/issue-88756-default-output/Makefile run-make/issue-97463-abi-param-passing/Makefile run-make/jobserver-error/Makefile diff --git a/tests/run-make/issue-85401-static-mir/bar.rs b/tests/run-make/ice-static-mir/bar.rs similarity index 100% rename from tests/run-make/issue-85401-static-mir/bar.rs rename to tests/run-make/ice-static-mir/bar.rs diff --git a/tests/run-make/issue-85401-static-mir/baz.rs b/tests/run-make/ice-static-mir/baz.rs similarity index 100% rename from tests/run-make/issue-85401-static-mir/baz.rs rename to tests/run-make/ice-static-mir/baz.rs diff --git a/tests/run-make/issue-85401-static-mir/foo.rs b/tests/run-make/ice-static-mir/foo.rs similarity index 100% rename from tests/run-make/issue-85401-static-mir/foo.rs rename to tests/run-make/ice-static-mir/foo.rs diff --git a/tests/run-make/ice-static-mir/rmake.rs b/tests/run-make/ice-static-mir/rmake.rs new file mode 100644 index 0000000000000..2d4ffa379b62b --- /dev/null +++ b/tests/run-make/ice-static-mir/rmake.rs @@ -0,0 +1,42 @@ +// Trying to access mid-level internal representation (MIR) in statics +// used to cause an internal compiler error (ICE), now handled as a proper +// error since #100211. This test checks that the correct error is printed +// during the linking process, and not the ICE. +// See https://github.com/rust-lang/rust/issues/85401 + +use run_make_support::{bin_name, rust_lib_name, rustc}; + +fn main() { + rustc() + .crate_type("rlib") + .crate_name("foo") + .arg("-Crelocation-model=pic") + .edition("2018") + .input("foo.rs") + .arg("-Zalways-encode-mir=yes") + .emit("metadata") + .output("libfoo.rmeta") + .run(); + rustc() + .crate_type("rlib") + .crate_name("bar") + .arg("-Crelocation-model=pic") + .edition("2018") + .input("bar.rs") + .output(rust_lib_name("bar")) + .extern_("foo", "libfoo.rmeta") + .run(); + rustc() + .crate_type("bin") + .crate_name("baz") + .arg("-Crelocation-model=pic") + .edition("2018") + .input("baz.rs") + .output(bin_name("baz")) + .extern_("bar", rust_lib_name("bar")) + .run_fail() + .assert_stderr_contains( + "crate `foo` required to be available in rlib format, but was not found in this form", + ) + .assert_stdout_not_contains("internal compiler error"); +} diff --git a/tests/run-make/issue-85401-static-mir/Makefile b/tests/run-make/issue-85401-static-mir/Makefile deleted file mode 100644 index 47a36b6e45355..0000000000000 --- a/tests/run-make/issue-85401-static-mir/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -include ../tools.mk - -# Regression test for issue #85401 -# Verify that we do not ICE when trying to access MIR for statics, -# but emit an error when linking. - -OUTPUT_FILE := $(TMPDIR)/build-output - -all: - $(RUSTC) --crate-type rlib --crate-name foo -Crelocation-model=pic --edition=2018 foo.rs -Zalways-encode-mir=yes --emit metadata -o $(TMPDIR)/libfoo.rmeta - $(RUSTC) --crate-type rlib --crate-name bar -Crelocation-model=pic --edition=2018 bar.rs -o $(TMPDIR)/libbar.rlib --extern=foo=$(TMPDIR)/libfoo.rmeta - $(RUSTC) --crate-type bin --crate-name baz -Crelocation-model=pic --edition=2018 baz.rs -o $(TMPDIR)/baz -L $(TMPDIR) --extern=bar=$(TMPDIR)/libbar.rlib > $(OUTPUT_FILE) 2>&1; [ $$? -eq 1 ] - cat $(OUTPUT_FILE) - $(CGREP) 'crate `foo` required to be available in rlib format, but was not found in this form' < $(OUTPUT_FILE) - # -v tests are fragile, hopefully this text won't change - $(CGREP) -v "internal compiler error" < $(OUTPUT_FILE) From 890ef1180b96683602ecd7ce0fe19a431d6474e2 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 16 Jul 2024 14:01:02 -0400 Subject: [PATCH 2/3] rewrite missing-crate-dependency to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/missing-crate-dependency/Makefile | 9 --------- .../run-make/missing-crate-dependency/rmake.rs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 tests/run-make/missing-crate-dependency/Makefile create mode 100644 tests/run-make/missing-crate-dependency/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 9e9d70bc6c630..349f0e3169f41 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -75,7 +75,6 @@ run-make/macos-deployment-target/Makefile run-make/macos-fat-archive/Makefile run-make/manual-link/Makefile run-make/min-global-align/Makefile -run-make/missing-crate-dependency/Makefile run-make/native-link-modifier-bundle/Makefile run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile diff --git a/tests/run-make/missing-crate-dependency/Makefile b/tests/run-make/missing-crate-dependency/Makefile deleted file mode 100644 index 7c271ab8a90de..0000000000000 --- a/tests/run-make/missing-crate-dependency/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib crateA.rs - $(RUSTC) --crate-type=rlib crateB.rs - $(call REMOVE_RLIBS,crateA) - # Ensure crateC fails to compile since dependency crateA is missing - $(RUSTC) crateC.rs 2>&1 | \ - $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on' diff --git a/tests/run-make/missing-crate-dependency/rmake.rs b/tests/run-make/missing-crate-dependency/rmake.rs new file mode 100644 index 0000000000000..ab916fc6b6131 --- /dev/null +++ b/tests/run-make/missing-crate-dependency/rmake.rs @@ -0,0 +1,17 @@ +// A simple smoke test to check that rustc fails compilation +// and outputs a helpful message when a dependency is missing +// in a dependency chain. +// See https://github.com/rust-lang/rust/issues/12146 + +use run_make_support::{fs_wrapper, rust_lib_name, rustc}; + +fn main() { + rustc().crate_type("rlib").input("crateA.rs").run(); + rustc().crate_type("rlib").input("crateB.rs").run(); + fs_wrapper::remove_file(rust_lib_name("crateA")); + // Ensure that crateC fails to compile, as the crateA dependency is missing. + rustc() + .input("crateC.rs") + .run_fail() + .assert_stderr_contains("can't find crate for `crateA` which `crateB` depends on"); +} From 3ba62f0a63c6b0092b6fec3bbc8877045073d827 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 16 Jul 2024 14:12:12 -0400 Subject: [PATCH 3/3] rewrite unstable-flag-required to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/missing-crate-dependency/rmake.rs | 4 ++-- tests/run-make/unstable-flag-required/Makefile | 4 ---- tests/run-make/unstable-flag-required/rmake.rs | 12 ++++++++++++ 4 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/unstable-flag-required/Makefile create mode 100644 tests/run-make/unstable-flag-required/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 349f0e3169f41..282b615c5bf4d 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -120,5 +120,4 @@ run-make/test-benches/Makefile run-make/thumb-none-cortex-m/Makefile run-make/thumb-none-qemu/Makefile run-make/translation/Makefile -run-make/unstable-flag-required/Makefile run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile diff --git a/tests/run-make/missing-crate-dependency/rmake.rs b/tests/run-make/missing-crate-dependency/rmake.rs index ab916fc6b6131..dae77032f7d4a 100644 --- a/tests/run-make/missing-crate-dependency/rmake.rs +++ b/tests/run-make/missing-crate-dependency/rmake.rs @@ -3,12 +3,12 @@ // in a dependency chain. // See https://github.com/rust-lang/rust/issues/12146 -use run_make_support::{fs_wrapper, rust_lib_name, rustc}; +use run_make_support::{rfs, rust_lib_name, rustc}; fn main() { rustc().crate_type("rlib").input("crateA.rs").run(); rustc().crate_type("rlib").input("crateB.rs").run(); - fs_wrapper::remove_file(rust_lib_name("crateA")); + rfs::remove_file(rust_lib_name("crateA")); // Ensure that crateC fails to compile, as the crateA dependency is missing. rustc() .input("crateC.rs") diff --git a/tests/run-make/unstable-flag-required/Makefile b/tests/run-make/unstable-flag-required/Makefile deleted file mode 100644 index 17dd15b079c62..0000000000000 --- a/tests/run-make/unstable-flag-required/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr diff --git a/tests/run-make/unstable-flag-required/rmake.rs b/tests/run-make/unstable-flag-required/rmake.rs new file mode 100644 index 0000000000000..c521436c203d5 --- /dev/null +++ b/tests/run-make/unstable-flag-required/rmake.rs @@ -0,0 +1,12 @@ +// The flag `--output-format` is unauthorized on beta and stable releases, which led +// to confusion for maintainers doing testing on nightly. Tying it to an unstable flag +// elucidates this, and this test checks that `--output-format` cannot be passed on its +// own. +// See https://github.com/rust-lang/rust/pull/82497 + +use run_make_support::{diff, rustdoc}; + +fn main() { + let out = rustdoc().output_format("json").input("x.html").run_fail().stderr_utf8(); + diff().expected_file("output-format-json.stderr").actual_text("actual-json", out).run(); +}