Rollup merge of #142641 - bjorn3:proc_macro_symbols_o, r=jieyouxu
Generate symbols.o for proc-macros too To ensure used statics are functioning correctly for proc-macros too.
This commit is contained in:
@@ -1870,8 +1870,13 @@ pub(crate) fn linked_symbols(
|
|||||||
crate_type: CrateType,
|
crate_type: CrateType,
|
||||||
) -> Vec<(String, SymbolExportKind)> {
|
) -> Vec<(String, SymbolExportKind)> {
|
||||||
match crate_type {
|
match crate_type {
|
||||||
CrateType::Executable | CrateType::Cdylib | CrateType::Dylib | CrateType::Sdylib => (),
|
CrateType::Executable
|
||||||
CrateType::Staticlib | CrateType::ProcMacro | CrateType::Rlib => {
|
| CrateType::ProcMacro
|
||||||
|
| CrateType::Cdylib
|
||||||
|
| CrateType::Dylib
|
||||||
|
| CrateType::Sdylib => (),
|
||||||
|
CrateType::Staticlib | CrateType::Rlib => {
|
||||||
|
// These are not linked, so no need to generate symbols.o for them.
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
tests/run-make/used-proc-macro/dep.rs
Normal file
4
tests/run-make/used-proc-macro/dep.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
#[used]
|
||||||
|
static VERY_IMPORTANT_SYMBOL: u32 = 12345;
|
||||||
3
tests/run-make/used-proc-macro/proc_macro.rs
Normal file
3
tests/run-make/used-proc-macro/proc_macro.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#![crate_type = "proc-macro"]
|
||||||
|
|
||||||
|
extern crate dep as _;
|
||||||
18
tests/run-make/used-proc-macro/rmake.rs
Normal file
18
tests/run-make/used-proc-macro/rmake.rs
Normal 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");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user