rewrite cdylib-fewer-symbols to rmake

This commit is contained in:
Oneirical 2024-06-26 16:09:45 -04:00
parent db21af1a72
commit 7c29298ea9
3 changed files with 23 additions and 16 deletions

View File

@ -9,7 +9,6 @@ run-make/c-unwind-abi-catch-lib-panic/Makefile
run-make/c-unwind-abi-catch-panic/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/cdylib-dylib-linkage/Makefile
run-make/cdylib-fewer-symbols/Makefile
run-make/compiler-lookup-paths-2/Makefile
run-make/compiler-lookup-paths/Makefile
run-make/compiler-rt-works-on-mingw/Makefile

View File

@ -1,15 +0,0 @@
# ignore-cross-compile
# Test that allocator-related symbols don't show up as exported from a cdylib as
# they're internal to Rust and not part of the public ABI.
# See https://github.com/rust-lang/rust/commit/fbf98697021173a30b84d9145df0966a23a2f9d2
include ../tools.mk
# ignore-windows
# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU
# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753
all:
$(RUSTC) foo.rs
nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_

View File

@ -0,0 +1,23 @@
// Symbols related to the allocator should be hidden and not exported from a cdylib,
// for they are internal to Rust
// and not part of the public ABI (application binary interface). This test checks that
// four such symbols are successfully hidden.
// See https://github.com/rust-lang/rust/pull/45710
//FIXME(Oneirical): try it on windows, restore ignore
// See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753
//FIXME(Oneirical): I also removed cross-compile ignore since there is no binary execution
use run_make_support::{dynamic_lib_name, llvm_readobj, rustc};
fn main() {
// Compile a cdylib
rustc().input("foo.rs").run();
let out = llvm_readobj().arg("--symbols").input(dynamic_lib_name("foo")).run().stdout_utf8();
let out = // All hidden symbols must be removed.
out.lines().filter(|&line| !line.trim().contains("HIDDEN")).collect::<Vec<_>>().join("\n");
assert!(!&out.contains("__rdl_"));
assert!(!&out.contains("__rde_"));
assert!(!&out.contains("__rg_"));
assert!(!&out.contains("__ruse_"));
}