Fallback to fat LTO for -Clto=thin in cg_gcc

Fallback to no LTO doesn't work in practice as Cargo asks rustc to
produce LTO-only rlibs with -Clinker-plugin-lto without providing any
indication if they will be used for thin or fat LTO, so we can't disable
-Clinker-plugin-lto for ThinLTO when using cg_gcc.
This commit is contained in:
bjorn3
2026-03-06 15:22:17 +00:00
parent f824853889
commit 15e839e006
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -539,5 +539,5 @@ pub(crate) struct UnexpectedBuiltinCfg {
}
#[derive(Diagnostic)]
#[diag("ThinLTO is not supported by the codegen backend")]
#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
pub(crate) struct ThinLtoNotSupportedByBackend;
+2 -2
View File
@@ -620,9 +620,9 @@ pub fn lto(&self) -> config::Lto {
config::LtoCli::Thin => {
// The user explicitly asked for ThinLTO
if !self.thin_lto_supported {
// Backend doesn't support ThinLTO, disable LTO.
// Backend doesn't support ThinLTO, fallback to fat LTO.
self.dcx().emit_warn(errors::ThinLtoNotSupportedByBackend);
return config::Lto::No;
return config::Lto::Fat;
}
return config::Lto::Thin;
}