@@ -25,7 +25,7 @@ use std::collections::HashSet;
2525use std:: iter;
2626use std:: path:: { Path , PathBuf } ;
2727
28- use crate :: core:: config:: TargetSelection ;
28+ use crate :: core:: config:: { RustcLto , TargetSelection } ;
2929use crate :: utils:: exec:: { BootstrapCommand , command} ;
3030use crate :: { Build , CLang , GitRepo } ;
3131
@@ -53,6 +53,15 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
5353 }
5454 }
5555 }
56+ match build. config . rust_lto {
57+ RustcLto :: Off | RustcLto :: ThinLocal => { }
58+ RustcLto :: Thin => {
59+ cfg. flag_if_supported ( "-flto=thin" ) ;
60+ }
61+ RustcLto :: Fat => {
62+ cfg. flag_if_supported ( "-flto=full" ) ;
63+ }
64+ }
5665 cfg
5766}
5867
@@ -113,7 +122,7 @@ pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) {
113122 } ;
114123
115124 build. cc . insert ( target, compiler. clone ( ) ) ;
116- let mut cflags = build. cc_handled_clags ( target, CLang :: C ) ;
125+ let mut cflags = build. cc_handled_cflags ( target, CLang :: C ) ;
117126 cflags. extend ( build. cc_unhandled_cflags ( target, GitRepo :: Rustc , CLang :: C ) ) ;
118127
119128 // If we use llvm-libunwind, we will need a C++ compiler as well for all targets
@@ -140,7 +149,7 @@ pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) {
140149 build. do_if_verbose ( || println ! ( "CC_{} = {:?}" , target. triple, build. cc( target) ) ) ;
141150 build. do_if_verbose ( || println ! ( "CFLAGS_{} = {cflags:?}" , target. triple) ) ;
142151 if let Ok ( cxx) = build. cxx ( target) {
143- let mut cxxflags = build. cc_handled_clags ( target, CLang :: Cxx ) ;
152+ let mut cxxflags = build. cc_handled_cflags ( target, CLang :: Cxx ) ;
144153 cxxflags. extend ( build. cc_unhandled_cflags ( target, GitRepo :: Rustc , CLang :: Cxx ) ) ;
145154 build. do_if_verbose ( || println ! ( "CXX_{} = {cxx:?}" , target. triple) ) ;
146155 build. do_if_verbose ( || println ! ( "CXXFLAGS_{} = {cxxflags:?}" , target. triple) ) ;
0 commit comments