From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/run-make/issue-85401-static-mir/Makefile | 16 ++++++++++++++++ tests/run-make/issue-85401-static-mir/bar.rs | 4 ++++ tests/run-make/issue-85401-static-mir/baz.rs | 3 +++ tests/run-make/issue-85401-static-mir/foo.rs | 5 +++++ 4 files changed, 28 insertions(+) create mode 100644 tests/run-make/issue-85401-static-mir/Makefile create mode 100644 tests/run-make/issue-85401-static-mir/bar.rs create mode 100644 tests/run-make/issue-85401-static-mir/baz.rs create mode 100644 tests/run-make/issue-85401-static-mir/foo.rs (limited to 'tests/run-make/issue-85401-static-mir') diff --git a/tests/run-make/issue-85401-static-mir/Makefile b/tests/run-make/issue-85401-static-mir/Makefile new file mode 100644 index 000000000..99590166b --- /dev/null +++ b/tests/run-make/issue-85401-static-mir/Makefile @@ -0,0 +1,16 @@ +include ../../run-make-fulldeps/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) diff --git a/tests/run-make/issue-85401-static-mir/bar.rs b/tests/run-make/issue-85401-static-mir/bar.rs new file mode 100644 index 000000000..15b12ecf3 --- /dev/null +++ b/tests/run-make/issue-85401-static-mir/bar.rs @@ -0,0 +1,4 @@ +pub fn bar() { + println!("bar {}", foo::FOO); + foo::foo(); +} diff --git a/tests/run-make/issue-85401-static-mir/baz.rs b/tests/run-make/issue-85401-static-mir/baz.rs new file mode 100644 index 000000000..2ff4c51e5 --- /dev/null +++ b/tests/run-make/issue-85401-static-mir/baz.rs @@ -0,0 +1,3 @@ +fn main() { + bar::bar() +} diff --git a/tests/run-make/issue-85401-static-mir/foo.rs b/tests/run-make/issue-85401-static-mir/foo.rs new file mode 100644 index 000000000..d064c4546 --- /dev/null +++ b/tests/run-make/issue-85401-static-mir/foo.rs @@ -0,0 +1,5 @@ +pub static FOO: &str = "foo"; + +pub fn foo() { + println!("foo"); +} -- cgit v1.2.3