@@ -2111,7 +2111,7 @@ impl Build {
21112111 None => false ,
21122112 } ;
21132113
2114- let is_sim = match target. split ( '-' ) . nth ( 3 ) {
2114+ let is_arm_sim = match target. split ( '-' ) . nth ( 3 ) {
21152115 Some ( v) => v == "sim" ,
21162116 None => false ,
21172117 } ;
@@ -2139,14 +2139,14 @@ impl Build {
21392139 ) ) ;
21402140 }
21412141 }
2142- } else if is_sim {
2142+ } else if is_arm_sim {
21432143 match arch {
21442144 "arm64" | "aarch64" => ArchSpec :: Simulator ( "-arch arm64" ) ,
21452145 "x86_64" => ArchSpec :: Simulator ( "-m64" ) ,
21462146 _ => {
21472147 return Err ( Error :: new (
21482148 ErrorKind :: ArchitectureInvalid ,
2149- "Unknown architecture for iOS simulator target." ,
2149+ "Unknown architecture for simulator target." ,
21502150 ) ) ;
21512151 }
21522152 }
@@ -2209,11 +2209,15 @@ impl Build {
22092209 ArchSpec :: Catalyst ( _) => "macosx" . to_owned ( ) ,
22102210 } ;
22112211
2212- if !is_mac {
2212+ // AppleClang sometimes needs sysroot even for darwin
2213+ if cmd. is_xctoolchain_clang ( ) || !target. ends_with ( "-darwin" ) {
22132214 self . print ( & format ! ( "Detecting {} SDK path for {}" , os, sdk) ) ;
22142215 let sdk_path = self . apple_sdk_root ( sdk. as_str ( ) ) ?;
22152216 cmd. args . push ( "-isysroot" . into ( ) ) ;
22162217 cmd. args . push ( sdk_path) ;
2218+ }
2219+
2220+ if !is_mac {
22172221 cmd. args . push ( "-fembed-bitcode" . into ( ) ) ;
22182222 }
22192223 /*
@@ -3111,6 +3115,17 @@ impl Tool {
31113115 self . family == ToolFamily :: Clang
31123116 }
31133117
3118+ /// Whether the tool is AppleClang under .xctoolchain
3119+ #[ cfg( target_os = "macos" ) ]
3120+ fn is_xctoolchain_clang ( & self ) -> bool {
3121+ let path = self . path . to_str ( ) . unwrap ( ) ;
3122+ path. contains ( ".xctoolchain/" )
3123+ }
3124+ #[ cfg( not( target_os = "macos" ) ) ]
3125+ fn is_xctoolchain_clang ( & self ) -> bool {
3126+ false
3127+ }
3128+
31143129 /// Whether the tool is MSVC-like.
31153130 pub fn is_like_msvc ( & self ) -> bool {
31163131 match self . family {
0 commit comments