Skip to content

Commit

Permalink
add test that tracks that functions defined in extern blocks are not …
Browse files Browse the repository at this point in the history
…exported

this maybe should change, but now at least it won't be changed unintentionally
  • Loading branch information
folkertdev committed Jul 30, 2024
1 parent 249482e commit 8040197
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/run-make/naked-symbol-visibility/a_rust_dylib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,16 @@ extern "C" fn naked_weak_linkage() -> u32 {
extern "C" fn naked_external_linkage() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
}

// functions that are declared in an `extern "C"` block are currently not exported
// this maybe should change in the future, this is just tracking the current behavior
// reported in https://github.com/rust-lang/rust/issues/128071
std::arch::global_asm! {
".globl function_defined_in_global_asm",
"function_defined_in_global_asm:",
"ret",
}

extern "C" {
pub fn function_defined_in_global_asm();
}
5 changes: 5 additions & 0 deletions tests/run-make/naked-symbol-visibility/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ fn main() {
rustc().arg("-Zshare-generics=yes").input("a_rust_dylib.rs").run();
global_function(&rdylib_name, "public_vanilla_generic_function_from_rust_dylib");
global_function(&rdylib_name, "public_naked_generic_function_from_rust_dylib");

// functions that are declared in an `extern "C"` block are currently not exported
// this maybe should change in the future, this is just tracking the current behavior
// reported in https://github.com/rust-lang/rust/issues/128071
not_exported(&rdylib_name, "function_defined_in_global_asm");
}

#[track_caller]
Expand Down

0 comments on commit 8040197

Please sign in to comment.