linker: Simplify linking of compiler_builtins
and profiler_builtins
This also fixes linking of native libraries bundled into these crates when `-Zpacked-bundled-libs` is enabled
This commit is contained in:
parent
cae3c936eb
commit
e792de28c8
2 changed files with 46 additions and 74 deletions
|
@ -833,20 +833,30 @@ impl CrateInfo {
|
|||
//
|
||||
// In order to get this left-to-right dependency ordering, we use the reverse
|
||||
// postorder of all crates putting the leaves at the right-most positions.
|
||||
let used_crates = tcx
|
||||
let mut compiler_builtins = None;
|
||||
let mut used_crates: Vec<_> = tcx
|
||||
.postorder_cnums(())
|
||||
.iter()
|
||||
.rev()
|
||||
.copied()
|
||||
.filter(|&cnum| !tcx.dep_kind(cnum).macros_only())
|
||||
.filter(|&cnum| {
|
||||
let link = !tcx.dep_kind(cnum).macros_only();
|
||||
if link && tcx.is_compiler_builtins(cnum) {
|
||||
compiler_builtins = Some(cnum);
|
||||
return false;
|
||||
}
|
||||
link
|
||||
})
|
||||
.collect();
|
||||
// `compiler_builtins` are always placed last to ensure that they're linked correctly.
|
||||
used_crates.extend(compiler_builtins);
|
||||
|
||||
let mut info = CrateInfo {
|
||||
target_cpu,
|
||||
exported_symbols,
|
||||
linked_symbols,
|
||||
local_crate_name,
|
||||
compiler_builtins: None,
|
||||
compiler_builtins,
|
||||
profiler_runtime: None,
|
||||
is_no_builtins: Default::default(),
|
||||
native_libraries: Default::default(),
|
||||
|
@ -872,9 +882,6 @@ impl CrateInfo {
|
|||
|
||||
let used_crate_source = tcx.used_crate_source(cnum);
|
||||
info.used_crate_source.insert(cnum, used_crate_source.clone());
|
||||
if tcx.is_compiler_builtins(cnum) {
|
||||
info.compiler_builtins = Some(cnum);
|
||||
}
|
||||
if tcx.is_profiler_runtime(cnum) {
|
||||
info.profiler_runtime = Some(cnum);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue