@@ -175,6 +175,17 @@ impl Step for Llvm {
175175 cfg. define ( "LLVM_ENABLE_ZLIB" , "OFF" ) ;
176176 }
177177
178+ // Are we compiling for iOS/tvOS?
179+ if target. contains ( "apple-ios" ) || target. contains ( "apple-tvos" ) {
180+ // These two defines prevent CMake from automatically trying to add a MacOSX sysroot, which leads to a compiler error.
181+ cfg. define ( "CMAKE_OSX_SYSROOT" , "/" ) ;
182+ cfg. define ( "CMAKE_OSX_DEPLOYMENT_TARGET" , "" ) ;
183+ // Prevent cmake from adding -bundle to CFLAGS automatically, which leads to a compiler error because "-bitcode_bundle" also gets added.
184+ cfg. define ( "LLVM_ENABLE_PLUGINS" , "OFF" ) ;
185+ // Zlib fails to link properly, leading to a compiler error.
186+ cfg. define ( "LLVM_ENABLE_ZLIB" , "OFF" ) ;
187+ }
188+
178189 if builder. config . llvm_thin_lto {
179190 cfg. define ( "LLVM_ENABLE_LTO" , "Thin" ) ;
180191 if !target. contains ( "apple" ) {
@@ -412,6 +423,14 @@ fn configure_cmake(
412423 if let Some ( ref s) = builder. config . llvm_cflags {
413424 cflags. push_str ( & format ! ( " {}" , s) ) ;
414425 }
426+ // Some compiler features used by LLVM (such as thread locals) will not work on a min version below iOS 10.
427+ if target. contains ( "apple-ios" ) {
428+ if target. contains ( "86-" ) {
429+ cflags. push_str ( " -miphonesimulator-version-min=10.0" ) ;
430+ } else {
431+ cflags. push_str ( " -miphoneos-version-min=10.0" ) ;
432+ }
433+ }
415434 cfg. define ( "CMAKE_C_FLAGS" , cflags) ;
416435 let mut cxxflags = builder. cflags ( target, GitRepo :: Llvm ) . join ( " " ) ;
417436 if builder. config . llvm_static_stdcpp && !target. contains ( "msvc" ) && !target. contains ( "netbsd" ) {
0 commit comments