mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Keep metadata when using gc-sections with profile-generate.
When building with profile-generate request that metadata is kept during the gc_sections call, as this can sometimes strip out profile data. This missing information in the prof files can then result in missing functions when using the profile information.
This commit is contained in:
parent
95fb131521
commit
7c98b3cfe3
@ -1931,7 +1931,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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user