@@ -158,6 +158,7 @@ pub struct Config {
158158 pub rust_new_symbol_mangling : Option < bool > ,
159159 pub rust_profile_use : Option < String > ,
160160 pub rust_profile_generate : Option < String > ,
161+ pub rust_lto : RustcLto ,
161162 pub llvm_profile_use : Option < String > ,
162163 pub llvm_profile_generate : bool ,
163164 pub llvm_libunwind_default : Option < LlvmLibunwind > ,
@@ -319,6 +320,28 @@ impl SplitDebuginfo {
319320 }
320321}
321322
323+ /// LTO mode used for compiling rustc itself.
324+ #[ derive( Default ) ]
325+ pub enum RustcLto {
326+ #[ default]
327+ ThinLocal ,
328+ Thin ,
329+ Fat
330+ }
331+
332+ impl std:: str:: FromStr for RustcLto {
333+ type Err = String ;
334+
335+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
336+ match s {
337+ "thin-local" => Ok ( RustcLto :: ThinLocal ) ,
338+ "thin" => Ok ( RustcLto :: Thin ) ,
339+ "fat" => Ok ( RustcLto :: Fat ) ,
340+ _ => Err ( format ! ( "Invalid value for rustc LTO: {}" , s) ) ,
341+ }
342+ }
343+ }
344+
322345#[ derive( Copy , Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
323346pub struct TargetSelection {
324347 pub triple : Interned < String > ,
@@ -726,6 +749,7 @@ define_config! {
726749 profile_use: Option <String > = "profile-use" ,
727750 // ignored; this is set from an env var set by bootstrap.py
728751 download_rustc: Option <StringOrBool > = "download-rustc" ,
752+ lto: Option <String > = "lto" ,
729753 }
730754}
731755
@@ -1173,6 +1197,13 @@ impl Config {
11731197 config. rust_profile_use = flags. rust_profile_use . or ( rust. profile_use ) ;
11741198 config. rust_profile_generate = flags. rust_profile_generate . or ( rust. profile_generate ) ;
11751199 config. download_rustc_commit = download_ci_rustc_commit ( & config, rust. download_rustc ) ;
1200+
1201+ config. rust_lto = rust
1202+ . lto
1203+ . as_deref ( )
1204+ . map ( RustcLto :: from_str)
1205+ . map ( |v| v. expect ( "invalid value for rust.lto" ) )
1206+ . unwrap_or_default ( ) ;
11761207 } else {
11771208 config. rust_profile_use = flags. rust_profile_use ;
11781209 config. rust_profile_generate = flags. rust_profile_generate ;
0 commit comments