Skip to content

Commit

Permalink
Auto merge of #87004 - JamieCunliffe:pgo-gc-sections, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Don't use gc-sections with profile-generate.

When building with profile-generate don't call gc_sections as this can
can sometimes strip out profile data. This missing information in the
prof files can then result in missing functions when using the profile
information.

#78226

r? `@Mark-Simulacrum`
  • Loading branch information
bors committed Jul 18, 2021
2 parents 5921685 + 7c98b3c commit b548d9f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,12 @@ fn add_order_independent_options(
// Try to strip as much out of the generated object by removing unused
// sections if possible. See more comments in linker.rs
if !sess.link_dead_code() {
let keep_metadata = crate_type == CrateType::Dylib;
// If PGO is enabled sometimes gc_sections will remove the profile data section
// as it appears to be unused. This can then cause the PGO profile file to lose
// some functions. If we are generating a profile we shouldn't strip those metadata
// sections to ensure we have all the data for PGO.
let keep_metadata =
crate_type == CrateType::Dylib || sess.opts.cg.profile_generate.enabled();
cmd.gc_sections(keep_metadata);
}

Expand Down

0 comments on commit b548d9f

Please sign in to comment.