about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make/cdylib-fewer-symbols/Makefile15
-rw-r--r--tests/run-make/cdylib-fewer-symbols/rmake.rs23
2 files changed, 23 insertions, 15 deletions
diff --git a/tests/run-make/cdylib-fewer-symbols/Makefile b/tests/run-make/cdylib-fewer-symbols/Makefile
deleted file mode 100644
index d587cece5be..00000000000
--- a/tests/run-make/cdylib-fewer-symbols/Makefile
+++ /dev/null
@@ -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_
diff --git a/tests/run-make/cdylib-fewer-symbols/rmake.rs b/tests/run-make/cdylib-fewer-symbols/rmake.rs
new file mode 100644
index 00000000000..8a8d31e6e49
--- /dev/null
+++ b/tests/run-make/cdylib-fewer-symbols/rmake.rs
@@ -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_"));
+}