@@ -2515,7 +2515,8 @@ impl Build {
25152515 ArchSpec :: Catalyst ( _) => "macosx" . to_owned ( ) ,
25162516 } ;
25172517
2518- if !is_mac {
2518+ // AppleClang sometimes requires sysroot even for darwin
2519+ if cmd. is_xctoolchain_clang ( ) || !target. ends_with ( "-darwin" ) {
25192520 self . print ( & format_args ! ( "Detecting {:?} SDK path for {}" , os, sdk) ) ;
25202521 let sdk_path = if let Some ( sdkroot) = env:: var_os ( "SDKROOT" ) {
25212522 sdkroot
@@ -2525,7 +2526,10 @@ impl Build {
25252526
25262527 cmd. args . push ( "-isysroot" . into ( ) ) ;
25272528 cmd. args . push ( sdk_path) ;
2528- // TODO: Remove this once Apple stops accepting apps built with Xcode 13
2529+ }
2530+
2531+ // TODO: Remove this once Apple stops accepting apps built with Xcode 13
2532+ if !is_mac {
25292533 cmd. args . push ( "-fembed-bitcode" . into ( ) ) ;
25302534 }
25312535
@@ -3718,6 +3722,17 @@ impl Tool {
37183722 self . family == ToolFamily :: Clang
37193723 }
37203724
3725+ /// Whether the tool is AppleClang under .xctoolchain
3726+ #[ cfg( target_vendor = "apple" ) ]
3727+ fn is_xctoolchain_clang ( & self ) -> bool {
3728+ let path = self . path . to_string_lossy ( ) ;
3729+ path. contains ( ".xctoolchain/" )
3730+ }
3731+ #[ cfg( not( target_vendor = "apple" ) ) ]
3732+ fn is_xctoolchain_clang ( & self ) -> bool {
3733+ false
3734+ }
3735+
37213736 /// Whether the tool is MSVC-like.
37223737 pub fn is_like_msvc ( & self ) -> bool {
37233738 match self . family {
0 commit comments