diff options
| author | Oneirical <manchot@videotron.ca> | 2024-06-27 11:08:49 -0400 |
|---|---|---|
| committer | Oneirical <manchot@videotron.ca> | 2024-07-02 11:37:59 -0400 |
| commit | 3a656462ef59a5d5288e0eb9651060d640c975ed (patch) | |
| tree | a7cec5dd9f23a6d99f70b75ac67fad7c03e76c1f /tests | |
| parent | 86bd3498b2c5a6a40f3db62c48a22f81d7713950 (diff) | |
| download | rust-3a656462ef59a5d5288e0eb9651060d640c975ed.tar.gz rust-3a656462ef59a5d5288e0eb9651060d640c975ed.zip | |
rewrite and rename issue-47384 to rmake
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/include-all-symbols-linking/lib.rs (renamed from tests/run-make/issue-47384/lib.rs) | 0 | ||||
| -rw-r--r-- | tests/run-make/include-all-symbols-linking/linker.ld (renamed from tests/run-make/issue-47384/linker.ld) | 0 | ||||
| -rw-r--r-- | tests/run-make/include-all-symbols-linking/main.rs (renamed from tests/run-make/issue-47384/main.rs) | 0 | ||||
| -rw-r--r-- | tests/run-make/include-all-symbols-linking/rmake.rs | 29 | ||||
| -rw-r--r-- | tests/run-make/issue-47384/Makefile | 12 |
5 files changed, 29 insertions, 12 deletions
diff --git a/tests/run-make/issue-47384/lib.rs b/tests/run-make/include-all-symbols-linking/lib.rs index 99508bcdaf3..99508bcdaf3 100644 --- a/tests/run-make/issue-47384/lib.rs +++ b/tests/run-make/include-all-symbols-linking/lib.rs diff --git a/tests/run-make/issue-47384/linker.ld b/tests/run-make/include-all-symbols-linking/linker.ld index 2e70acab3f4..2e70acab3f4 100644 --- a/tests/run-make/issue-47384/linker.ld +++ b/tests/run-make/include-all-symbols-linking/linker.ld diff --git a/tests/run-make/issue-47384/main.rs b/tests/run-make/include-all-symbols-linking/main.rs index 02572632517..02572632517 100644 --- a/tests/run-make/issue-47384/main.rs +++ b/tests/run-make/include-all-symbols-linking/main.rs diff --git a/tests/run-make/include-all-symbols-linking/rmake.rs b/tests/run-make/include-all-symbols-linking/rmake.rs new file mode 100644 index 00000000000..a443fc0a5c4 --- /dev/null +++ b/tests/run-make/include-all-symbols-linking/rmake.rs @@ -0,0 +1,29 @@ +// Linkers treat archives differently from object files: all object files participate in linking, +// while archives will only participate in linking if they can satisfy at least one undefined +// reference (version scripts doesn't count). This causes `#[no_mangle]` or `#[used]` items to +// be ignored by the linker, and since they never participate in the linking, using `KEEP` in the +// linker scripts can't keep them either. This causes #47384. After the fix in #95604, this test +// checks that these symbols and sections successfully appear in the output dynamic library. +// See https://github.com/rust-lang/rust/pull/95604 +// See https://github.com/rust-lang/rust/issues/47384 + +//FIXME(Oneirical): ignore flags: only linux and cross compile + +use run_make_support::{dynamic_lib_name, llvm_objdump, llvm_readobj, rustc}; + +fn main() { + rustc().crate_type("lib").input("lib.rs").run(); + rustc().crate_type("cdylib").link_args("-Tlinker.ld").input("main.rs").run(); + // Ensure `#[used]` and `KEEP`-ed section is there + llvm_objdump() + .arg("--full-contents") + .arg("--section=.static") + .input(dynamic_lib_name("main")) + .run(); + // Ensure `#[no_mangle]` symbol is there + llvm_readobj() + .arg("--symbols") + .input(dynamic_lib_name("main")) + .run() + .assert_stdout_contains("bar"); +} diff --git a/tests/run-make/issue-47384/Makefile b/tests/run-make/issue-47384/Makefile deleted file mode 100644 index afc77cb275a..00000000000 --- a/tests/run-make/issue-47384/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -# only-linux -# ignore-cross-compile - -all: main.rs - $(RUSTC) --crate-type lib lib.rs - $(RUSTC) --crate-type cdylib -Clink-args="-Tlinker.ld" main.rs - # Ensure `#[used]` and `KEEP`-ed section is there - objdump -s -j".static" $(TMPDIR)/libmain.so - # Ensure `#[no_mangle]` symbol is there - nm $(TMPDIR)/libmain.so | $(CGREP) bar |
