rewrite export-executable-symbols to rmake

This commit is contained in:
Oneirical 2024-07-22 13:04:32 -04:00
parent 2a3e4c547b
commit 3cc1056ff7
5 changed files with 30 additions and 17 deletions

View File

@ -9,7 +9,6 @@ run-make/dep-info-doesnt-run-much/Makefile
run-make/dep-info-spaces/Makefile run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile run-make/dep-info/Makefile
run-make/emit-to-stdout/Makefile run-make/emit-to-stdout/Makefile
run-make/export-executable-symbols/Makefile
run-make/extern-fn-reachable/Makefile run-make/extern-fn-reachable/Makefile
run-make/fmt-write-bloat/Makefile run-make/fmt-write-bloat/Makefile
run-make/foreign-double-unwind/Makefile run-make/foreign-double-unwind/Makefile

View File

@ -8,7 +8,7 @@
//@ needs-unwind //@ needs-unwind
// Reason: this test exercises unwinding a panic // Reason: this test exercises unwinding a panic
use run_make_support::{cc, is_msvc, llvm_ar, run, rustc}; use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name};
fn main() { fn main() {
// Compile `add.c` into an object file. // Compile `add.c` into an object file.
@ -25,9 +25,9 @@ fn main() {
// Now, create an archive using these two objects. // Now, create an archive using these two objects.
if is_msvc() { if is_msvc() {
llvm_ar().obj_to_ar().args(&["libadd.a", "add.obj", "panic.o"]).run(); llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.obj", "panic.o"]).run();
} else { } else {
llvm_ar().obj_to_ar().args(&["libadd.a", "add.o", "panic.o"]).run(); llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.o", "panic.o"]).run();
}; };
// Compile `main.rs`, which will link into our library, and run it. // Compile `main.rs`, which will link into our library, and run it.

View File

@ -1,11 +0,0 @@
include ../tools.mk
# ignore-wasm32
# ignore-wasm64
# ignore-none no-std is not supported
# only-linux
all:
$(RUSTC) -Zexport-executable-symbols main.rs --target $(TARGET) --crate-type=bin
nm $(TMPDIR)/main | $(CGREP) exported_symbol

View File

@ -0,0 +1,25 @@
// The unstable flag `-Z export-executable-symbols` exports symbols from executables, as if
// they were dynamic libraries. This test is a simple smoke test to check that this feature
// works by using it in compilation, then checking that the output binary contains the exported
// symbol.
// See https://github.com/rust-lang/rust/pull/85673
//@ only-unix
// Reason: the export-executable-symbols flag only works on Unix
// due to hardcoded platform-specific implementation
// (See #85673)
//@ ignore-wasm32
//@ ignore-wasm64
//@ ignore-none
// Reason: no-std is not supported
use run_make_support::{bin_name, llvm_readobj, rustc};
fn main() {
rustc().arg("-Zexport-executable-symbols").input("main.rs").crate_type("bin").run();
llvm_readobj()
.symbols()
.input(bin_name("main"))
.run()
.assert_stdout_contains("exported_symbol");
}

View File

@ -10,8 +10,8 @@
//@ needs-unwind //@ needs-unwind
// Reason: unwinding panics is exercised in this test // Reason: unwinding panics is exercised in this test
//FIXME(Oneirical): ignore-i686-pc-windows-gnu //@ ignore-i686-pc-windows-gnu
// This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder // Reason: This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder
// so cross-DLL unwinding does not work. // so cross-DLL unwinding does not work.
use run_make_support::{run_fail, rustc}; use run_make_support::{run_fail, rustc};