Generate symbols.o for proc-macros too

To ensure used statics are functioning correctly for proc-macros too.
This commit is contained in:
bjorn3 2025-06-17 20:31:16 +00:00
parent ae2fc9722f
commit 2bb98e2c48
4 changed files with 32 additions and 2 deletions

View file

@ -0,0 +1,4 @@
#![crate_type = "lib"]
#[used]
static VERY_IMPORTANT_SYMBOL: u32 = 12345;

View file

@ -0,0 +1,3 @@
#![crate_type = "proc-macro"]
extern crate dep as _;

View file

@ -0,0 +1,18 @@
// Test that #[used] statics are included in the final dylib for proc-macros too.
//@ ignore-cross-compile
//@ ignore-windows llvm-readobj --all doesn't show local symbols on Windows
//@ needs-crate-type: proc-macro
//@ ignore-musl (FIXME: can't find `-lunwind`)
use run_make_support::{dynamic_lib_name, llvm_readobj, rustc};
fn main() {
rustc().input("dep.rs").run();
rustc().input("proc_macro.rs").run();
llvm_readobj()
.input(dynamic_lib_name("proc_macro"))
.arg("--all")
.run()
.assert_stdout_contains("VERY_IMPORTANT_SYMBOL");
}