@@ -264,7 +264,7 @@ impl Step for Llvm {
264264 cfg. define ( "PYTHON_EXECUTABLE" , python) ;
265265 }
266266
267- configure_cmake ( builder, target, & mut cfg) ;
267+ configure_cmake ( builder, target, & mut cfg, true ) ;
268268
269269 // FIXME: we don't actually need to build all LLVM tools and all LLVM
270270 // libraries here, e.g., we just want a few components and a few
@@ -303,7 +303,12 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
303303 panic ! ( "\n \n bad LLVM version: {}, need >=7.0\n \n " , version)
304304}
305305
306- fn configure_cmake ( builder : & Builder < ' _ > , target : Interned < String > , cfg : & mut cmake:: Config ) {
306+ fn configure_cmake (
307+ builder : & Builder < ' _ > ,
308+ target : Interned < String > ,
309+ cfg : & mut cmake:: Config ,
310+ use_compiler_launcher : bool ,
311+ ) {
307312 // Do not print installation messages for up-to-date files.
308313 // LLVM and LLD builds can produce a lot of those and hit CI limits on log size.
309314 cfg. define ( "CMAKE_INSTALL_MESSAGE" , "LAZY" ) ;
@@ -374,9 +379,11 @@ fn configure_cmake(builder: &Builder<'_>, target: Interned<String>, cfg: &mut cm
374379 } else {
375380 // If ccache is configured we inform the build a little differently how
376381 // to invoke ccache while also invoking our compilers.
377- if let Some ( ref ccache) = builder. config . ccache {
378- cfg. define ( "CMAKE_C_COMPILER_LAUNCHER" , ccache)
379- . define ( "CMAKE_CXX_COMPILER_LAUNCHER" , ccache) ;
382+ if use_compiler_launcher {
383+ if let Some ( ref ccache) = builder. config . ccache {
384+ cfg. define ( "CMAKE_C_COMPILER_LAUNCHER" , ccache)
385+ . define ( "CMAKE_CXX_COMPILER_LAUNCHER" , ccache) ;
386+ }
380387 }
381388 cfg. define ( "CMAKE_C_COMPILER" , sanitize_cc ( cc) )
382389 . define ( "CMAKE_CXX_COMPILER" , sanitize_cc ( cxx) ) ;
@@ -460,7 +467,7 @@ impl Step for Lld {
460467 t ! ( fs:: create_dir_all( & out_dir) ) ;
461468
462469 let mut cfg = cmake:: Config :: new ( builder. src . join ( "src/llvm-project/lld" ) ) ;
463- configure_cmake ( builder, target, & mut cfg) ;
470+ configure_cmake ( builder, target, & mut cfg, true ) ;
464471
465472 // This is an awful, awful hack. Discovered when we migrated to using
466473 // clang-cl to compile LLVM/LLD it turns out that LLD, when built out of
@@ -597,10 +604,7 @@ impl Step for Sanitizers {
597604 let _time = util:: timeit ( & builder) ;
598605
599606 let mut cfg = cmake:: Config :: new ( & compiler_rt_dir) ;
600- cfg. target ( & self . target ) ;
601- cfg. host ( & builder. config . build ) ;
602607 cfg. profile ( "Release" ) ;
603-
604608 cfg. define ( "CMAKE_C_COMPILER_TARGET" , self . target ) ;
605609 cfg. define ( "COMPILER_RT_BUILD_BUILTINS" , "OFF" ) ;
606610 cfg. define ( "COMPILER_RT_BUILD_CRT" , "OFF" ) ;
@@ -612,6 +616,12 @@ impl Step for Sanitizers {
612616 cfg. define ( "COMPILER_RT_USE_LIBCXX" , "OFF" ) ;
613617 cfg. define ( "LLVM_CONFIG_PATH" , & llvm_config) ;
614618
619+ // On Darwin targets the sanitizer runtimes are build as universal binaries.
620+ // Unfortunately sccache currently lacks support to build them successfully.
621+ // Disable compiler launcher on Darwin targets to avoid potential issues.
622+ let use_compiler_launcher = !self . target . contains ( "apple-darwin" ) ;
623+ configure_cmake ( builder, self . target , & mut cfg, use_compiler_launcher) ;
624+
615625 t ! ( fs:: create_dir_all( & out_dir) ) ;
616626 cfg. out_dir ( out_dir) ;
617627
0 commit comments