From ff00622f6e68555e2820edf954a5ab6be0b7109e Mon Sep 17 00:00:00 2001 From: DianQK Date: Tue, 22 Oct 2024 10:46:10 +0800 Subject: [PATCH] Add a test case for #131164 --- tests/run-make/rust-lld-link-script-provide/main.rs | 7 +++++++ tests/run-make/rust-lld-link-script-provide/rmake.rs | 12 ++++++++++++ tests/run-make/rust-lld-link-script-provide/script.t | 1 + 3 files changed, 20 insertions(+) create mode 100644 tests/run-make/rust-lld-link-script-provide/main.rs create mode 100644 tests/run-make/rust-lld-link-script-provide/rmake.rs create mode 100644 tests/run-make/rust-lld-link-script-provide/script.t diff --git a/tests/run-make/rust-lld-link-script-provide/main.rs b/tests/run-make/rust-lld-link-script-provide/main.rs new file mode 100644 index 0000000000000..5c19e7a4bbf6b --- /dev/null +++ b/tests/run-make/rust-lld-link-script-provide/main.rs @@ -0,0 +1,7 @@ +#[no_mangle] +fn foo() {} + +#[no_mangle] +fn bar() {} + +fn main() {} diff --git a/tests/run-make/rust-lld-link-script-provide/rmake.rs b/tests/run-make/rust-lld-link-script-provide/rmake.rs new file mode 100644 index 0000000000000..01eb31e91a403 --- /dev/null +++ b/tests/run-make/rust-lld-link-script-provide/rmake.rs @@ -0,0 +1,12 @@ +// This test ensures that the “symbol not found” error does not occur +// when the symbols in the `PROVIDE` of the link script can be eliminated. +// This is a regression test for #131164. + +//@ needs-rust-lld +//@ only-x86_64-unknown-linux-gnu + +use run_make_support::rustc; + +fn main() { + rustc().input("main.rs").arg("-Zlinker-features=+lld").link_arg("-Tscript.t").run(); +} diff --git a/tests/run-make/rust-lld-link-script-provide/script.t b/tests/run-make/rust-lld-link-script-provide/script.t new file mode 100644 index 0000000000000..4c4c6ddfc36b0 --- /dev/null +++ b/tests/run-make/rust-lld-link-script-provide/script.t @@ -0,0 +1 @@ +PROVIDE(foo = bar);