Skip to content

Commit 8040197

Browse files
committed
add test that tracks that functions defined in extern blocks are not exported
this maybe should change, but now at least it won't be changed unintentionally
1 parent 249482e commit 8040197

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/run-make/naked-symbol-visibility/a_rust_dylib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,16 @@ extern "C" fn naked_weak_linkage() -> u32 {
7272
extern "C" fn naked_external_linkage() -> u32 {
7373
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
7474
}
75+
76+
// functions that are declared in an `extern "C"` block are currently not exported
77+
// this maybe should change in the future, this is just tracking the current behavior
78+
// reported in https://github.com/rust-lang/rust/issues/128071
79+
std::arch::global_asm! {
80+
".globl function_defined_in_global_asm",
81+
"function_defined_in_global_asm:",
82+
"ret",
83+
}
84+
85+
extern "C" {
86+
pub fn function_defined_in_global_asm();
87+
}

tests/run-make/naked-symbol-visibility/rmake.rs

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ fn main() {
2525
rustc().arg("-Zshare-generics=yes").input("a_rust_dylib.rs").run();
2626
global_function(&rdylib_name, "public_vanilla_generic_function_from_rust_dylib");
2727
global_function(&rdylib_name, "public_naked_generic_function_from_rust_dylib");
28+
29+
// functions that are declared in an `extern "C"` block are currently not exported
30+
// this maybe should change in the future, this is just tracking the current behavior
31+
// reported in https://github.com/rust-lang/rust/issues/128071
32+
not_exported(&rdylib_name, "function_defined_in_global_asm");
2833
}
2934

3035
#[track_caller]

0 commit comments

Comments
 (0)