@@ -175,6 +175,17 @@ impl Step for Llvm {
175
175
cfg. define ( "LLVM_ENABLE_ZLIB" , "OFF" ) ;
176
176
}
177
177
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
+
178
189
if builder. config . llvm_thin_lto {
179
190
cfg. define ( "LLVM_ENABLE_LTO" , "Thin" ) ;
180
191
if !target. contains ( "apple" ) {
@@ -412,6 +423,14 @@ fn configure_cmake(
412
423
if let Some ( ref s) = builder. config . llvm_cflags {
413
424
cflags. push_str ( & format ! ( " {}" , s) ) ;
414
425
}
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
+ }
415
434
cfg. define ( "CMAKE_C_FLAGS" , cflags) ;
416
435
let mut cxxflags = builder. cflags ( target, GitRepo :: Llvm ) . join ( " " ) ;
417
436
if builder. config . llvm_static_stdcpp && !target. contains ( "msvc" ) && !target. contains ( "netbsd" ) {
0 commit comments