-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.
Description
Currently, all items in a crate are codegened, and only stripped later in a linker pass:
rust/compiler/rustc_monomorphize/src/partitioning/mod.rs
Lines 201 to 205 in 6c4bda6
// Next we try to make as many symbols "internal" as possible, so LLVM has | |
// more freedom to optimize. | |
if !tcx.sess.link_dead_code() { | |
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_internalize_symbols"); | |
partitioner.internalize_symbols(cx, &mut post_inlining); |
rust/compiler/rustc_codegen_ssa/src/back/link.rs
Lines 2179 to 2190 in a24a020
// 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() { | |
// 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(); | |
if crate_type != CrateType::Executable || !sess.opts.unstable_opts.export_executable_symbols | |
{ | |
cmd.gc_sections(keep_metadata); |
dead_code
pass; we should use its results to avoid running codegen on unreachable items.
This is a prerequisite for #103356, but I expect it will be a large boost to compile times even if that never lands.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.