Remove -Zemit-thin-lto flag

As far as I can tell it was introduced to allow fat LTO with
-Clinker-plugin-lto. Later a change was made to automatically disable
ThinLTO summary generation when -Clinker-plugin-lto -Clto=fat is used,
so we can safely remove it.
This commit is contained in:
bjorn3
2026-02-12 11:07:04 +00:00
parent 59fd4ef94d
commit 6366a698e3
7 changed files with 11 additions and 21 deletions
@@ -786,7 +786,6 @@ fn handle_offload<'ll>(cx: &'ll SimpleCx<'_>, old_fn: &llvm::Value) {
config.verify_llvm_ir,
config.lint_llvm_ir,
thin_lto_buffer,
config.emit_thin_lto,
config.emit_thin_lto_summary,
merge_functions,
unroll_loops,
@@ -1033,7 +1032,7 @@ pub(crate) fn codegen(
"LLVM_module_codegen_make_bitcode",
&*module.name,
);
ThinBuffer::new(llmod, config.emit_thin_lto)
ThinBuffer::new(llmod, cgcx.lto != Lto::Fat)
};
let data = thin.data();
let _timer = prof
@@ -2376,7 +2376,6 @@ pub(crate) fn LLVMRustOptimize<'a>(
VerifyIR: bool,
LintIR: bool,
ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>,
EmitThinLTO: bool,
EmitThinLTOSummary: bool,
MergeFunctions: bool,
UnrollLoops: bool,
@@ -101,7 +101,6 @@ pub struct ModuleConfig {
pub emit_ir: bool,
pub emit_asm: bool,
pub emit_obj: EmitObj,
pub emit_thin_lto: bool,
pub emit_thin_lto_summary: bool,
// Miscellaneous flags. These are mostly copied from command-line
@@ -212,9 +211,6 @@ macro_rules! if_regular {
false
),
emit_obj,
// thin lto summaries prevent fat lto, so do not emit them if fat
// lto is requested. See PR #136840 for background information.
emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto && sess.lto() != Lto::Fat,
emit_thin_lto_summary: if_regular!(
sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode),
false
-1
View File
@@ -796,7 +796,6 @@ macro_rules! tracked {
tracked!(dwarf_version, Some(5));
tracked!(embed_metadata, false);
tracked!(embed_source, true);
tracked!(emit_thin_lto, false);
tracked!(emscripten_wasm_eh, false);
tracked!(export_executable_symbols, true);
tracked!(fewer_names, Some(true));
@@ -566,7 +566,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR,
bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef, bool EmitThinLTO,
bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef,
bool EmitThinLTOSummary, bool MergeFunctions, bool UnrollLoops,
bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls,
bool EmitLifetimeMarkers, registerEnzymeAndPassPipelineFn EnzymePtr,
@@ -808,7 +808,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
}
ModulePassManager MPM;
bool NeedThinLTOBufferPasses = EmitThinLTO;
bool NeedThinLTOBufferPasses = true;
auto ThinLTOBuffer = std::make_unique<LLVMRustThinLTOBuffer>();
raw_string_ostream ThinLTODataOS(ThinLTOBuffer->data);
raw_string_ostream ThinLinkDataOS(ThinLTOBuffer->thin_link_data);
@@ -840,12 +840,8 @@ extern "C" LLVMRustResult LLVMRustOptimize(
// bitcode for embedding is obtained after performing
// `ThinLTOPreLinkDefaultPipeline`.
MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(OptLevel));
if (EmitThinLTO) {
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
} else {
MPM.addPass(BitcodeWriterPass(ThinLTODataOS));
}
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
*ThinLTOBufferRef = ThinLTOBuffer.release();
MPM.addPass(PB.buildModuleOptimizationPipeline(
OptLevel, ThinOrFullLTOPhase::None));
@@ -870,6 +866,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
break;
case LLVMRustOptStage::FatLTO:
MPM = PB.buildLTODefaultPipeline(OptLevel, nullptr);
NeedThinLTOBufferPasses = false;
break;
}
}
@@ -895,9 +892,11 @@ extern "C" LLVMRustResult LLVMRustOptimize(
MPM.addPass(CanonicalizeAliasesPass());
MPM.addPass(NameAnonGlobalPass());
}
// For `-Copt-level=0`, ThinLTO, or LTO.
// For `-Copt-level=0`, and the pre-link fat/thin LTO stages.
if (ThinLTOBufferRef && *ThinLTOBufferRef == nullptr) {
if (EmitThinLTO) {
// thin lto summaries prevent fat lto, so do not emit them if fat
// lto is requested. See PR #136840 for background information.
if (OptStage != LLVMRustOptStage::PreLinkFatLTO) {
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
} else {
-2
View File
@@ -2335,8 +2335,6 @@ pub(crate) fn parse_align(slot: &mut Option<Align>, v: Option<&str>) -> bool {
"embed source text in DWARF debug sections (default: no)"),
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
"emit a section containing stack size metadata (default: no)"),
emit_thin_lto: bool = (true, parse_bool, [TRACKED],
"emit the bc module with thin LTO info (default: yes)"),
emscripten_wasm_eh: bool = (true, parse_bool, [TRACKED],
"Use WebAssembly error handling for wasm32-unknown-emscripten"),
enforce_type_length_limit: bool = (false, parse_bool, [TRACKED],
@@ -18,7 +18,7 @@ fn main() {
.arg("-Clinker-plugin-lto")
.arg(format!("-Clinker={}", env_var("CLANG")))
.arg("-Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized")
.arg("-Zemit-thin-lto=no")
.arg("-Clto=fat")
.run();
llvm_objcopy().dump_section(".llvmbc", "test.bc").arg("test").run();