Skip to content

Commit

Permalink
linker: Link profiler_builtins even if it's marked as NotLinked
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Nov 12, 2022
1 parent 58e4644 commit c2358a1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2454,15 +2454,17 @@ fn add_upstream_rust_crates<'a>(
// We must always link crates `compiler_builtins` and `profiler_builtins` statically.
// Even if they were already included into a dylib
// (e.g. `libstd` when `-C prefer-dynamic` is used).
// FIXME: `dependency_formats` can report `profiler_builtins` as `NotLinked` for some
// reason, it shouldn't do that because `profiler_builtins` should indeed be linked.
let linkage = data[cnum.as_usize() - 1];
let link_static_crate = linkage == Linkage::Static
|| linkage == Linkage::IncludedFromDylib
|| (linkage == Linkage::IncludedFromDylib || linkage == Linkage::NotLinked)
&& (codegen_results.crate_info.compiler_builtins == Some(cnum)
|| codegen_results.crate_info.profiler_runtime == Some(cnum));

let mut bundled_libs = Default::default();
match linkage {
Linkage::Static | Linkage::IncludedFromDylib => {
Linkage::Static | Linkage::IncludedFromDylib | Linkage::NotLinked => {
if link_static_crate {
bundled_libs = codegen_results.crate_info.native_libraries[&cnum]
.iter()
Expand All @@ -2483,7 +2485,6 @@ fn add_upstream_rust_crates<'a>(
let src = &codegen_results.crate_info.used_crate_source[&cnum];
add_dynamic_crate(cmd, sess, &src.dylib.as_ref().unwrap().0);
}
Linkage::NotLinked => {}
}

// Static libraries are linked for a subset of linked upstream crates.
Expand Down

0 comments on commit c2358a1

Please sign in to comment.