1
Fork 0

Auto merge of #95604 - nbdd0121:used2, r=petrochenkov

Generate synthetic object file to ensure all exported and used symbols participate in the linking

Fix #50007 and #47384

This is the synthetic object file approach that I described in https://github.com/rust-lang/rust/pull/95363#issuecomment-1079932354, allowing all exported and used symbols to be linked while still allowing them to be GCed.

Related #93791, #95363

r? `@petrochenkov`
cc `@carbotaniuman`
This commit is contained in:
bors 2022-04-25 16:14:54 +00:00
commit 18b53cefdf
23 changed files with 324 additions and 75 deletions

View file

@ -801,6 +801,12 @@ impl CrateInfo {
.iter()
.map(|&c| (c, crate::back::linker::exported_symbols(tcx, c)))
.collect();
let linked_symbols = tcx
.sess
.crate_types()
.iter()
.map(|&c| (c, crate::back::linker::linked_symbols(tcx, c)))
.collect();
let local_crate_name = tcx.crate_name(LOCAL_CRATE);
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
let subsystem = tcx.sess.first_attr_value_str_by_name(crate_attrs, sym::windows_subsystem);
@ -834,6 +840,7 @@ impl CrateInfo {
let mut info = CrateInfo {
target_cpu,
exported_symbols,
linked_symbols,
local_crate_name,
compiler_builtins: None,
profiler_runtime: None,