1include(CMakeParseArguments) 2include(CompilerRTUtils) 3include(BuiltinTests) 4 5set(CMAKE_LIPO "lipo" CACHE PATH "path to the lipo tool") 6 7# On OS X SDKs can be installed anywhere on the base system and xcode-select can 8# set the default Xcode to use. This function finds the SDKs that are present in 9# the current Xcode. 10function(find_darwin_sdk_dir var sdk_name) 11 set(DARWIN_${sdk_name}_CACHED_SYSROOT "" CACHE STRING "Darwin SDK path for SDK ${sdk_name}.") 12 set(DARWIN_PREFER_PUBLIC_SDK OFF CACHE BOOL "Prefer Darwin public SDK, even when an internal SDK is present.") 13 14 if(DARWIN_${sdk_name}_CACHED_SYSROOT) 15 set(${var} ${DARWIN_${sdk_name}_CACHED_SYSROOT} PARENT_SCOPE) 16 return() 17 endif() 18 if(NOT DARWIN_PREFER_PUBLIC_SDK) 19 # Let's first try the internal SDK, otherwise use the public SDK. 20 execute_process( 21 COMMAND xcodebuild -version -sdk ${sdk_name}.internal Path 22 RESULT_VARIABLE result_process 23 OUTPUT_VARIABLE var_internal 24 OUTPUT_STRIP_TRAILING_WHITESPACE 25 ERROR_FILE /dev/null 26 ) 27 endif() 28 if((NOT result_process EQUAL 0) OR "" STREQUAL "${var_internal}") 29 execute_process( 30 COMMAND xcodebuild -version -sdk ${sdk_name} Path 31 RESULT_VARIABLE result_process 32 OUTPUT_VARIABLE var_internal 33 OUTPUT_STRIP_TRAILING_WHITESPACE 34 ERROR_FILE /dev/null 35 ) 36 else() 37 set(${var}_INTERNAL ${var_internal} PARENT_SCOPE) 38 endif() 39 if(result_process EQUAL 0) 40 set(${var} ${var_internal} PARENT_SCOPE) 41 endif() 42 set(DARWIN_${sdk_name}_CACHED_SYSROOT ${var_internal} CACHE STRING "Darwin SDK path for SDK ${sdk_name}." FORCE) 43endfunction() 44 45function(find_darwin_sdk_version var sdk_name) 46 # We deliberately don't cache the result here because 47 # CMake's caching causes too many problems. 48 set(result_process 1) 49 if(NOT DARWIN_PREFER_PUBLIC_SDK) 50 # Let's first try the internal SDK, otherwise use the public SDK. 51 execute_process( 52 COMMAND xcodebuild -version -sdk ${sdk_name}.internal SDKVersion 53 RESULT_VARIABLE result_process 54 OUTPUT_VARIABLE var_internal 55 OUTPUT_STRIP_TRAILING_WHITESPACE 56 ERROR_FILE /dev/null 57 ) 58 endif() 59 if((NOT ${result_process} EQUAL 0) OR "" STREQUAL "${var_internal}") 60 execute_process( 61 COMMAND xcodebuild -version -sdk ${sdk_name} SDKVersion 62 RESULT_VARIABLE result_process 63 OUTPUT_VARIABLE var_internal 64 OUTPUT_STRIP_TRAILING_WHITESPACE 65 ERROR_FILE /dev/null 66 ) 67 endif() 68 if(NOT result_process EQUAL 0) 69 message(FATAL_ERROR 70 "Failed to determine SDK version for \"${sdk_name}\" SDK") 71 endif() 72 # Check reported version looks sane. 73 if (NOT "${var_internal}" MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+)?$") 74 message(FATAL_ERROR 75 "Reported SDK version \"${var_internal}\" does not look like a version") 76 endif() 77 set(${var} ${var_internal} PARENT_SCOPE) 78endfunction() 79 80# There isn't a clear mapping of what architectures are supported with a given 81# target platform, but ld's version output does list the architectures it can 82# link for. 83function(darwin_get_toolchain_supported_archs output_var) 84 execute_process( 85 COMMAND "${CMAKE_LINKER}" -v 86 ERROR_VARIABLE LINKER_VERSION) 87 88 string(REGEX MATCH "configured to support archs: ([^\n]+)" 89 ARCHES_MATCHED "${LINKER_VERSION}") 90 if(ARCHES_MATCHED) 91 set(ARCHES "${CMAKE_MATCH_1}") 92 message(STATUS "Got ld supported ARCHES: ${ARCHES}") 93 string(REPLACE " " ";" ARCHES ${ARCHES}) 94 else() 95 # If auto-detecting fails, fall back to a default set 96 message(WARNING "Detecting supported architectures from 'ld -v' failed. Returning default set.") 97 set(ARCHES "i386;x86_64;armv7;armv7s;arm64") 98 endif() 99 100 set(${output_var} ${ARCHES} PARENT_SCOPE) 101endfunction() 102 103# This function takes an OS and a list of architectures and identifies the 104# subset of the architectures list that the installed toolchain can target. 105function(darwin_test_archs os valid_archs) 106 if(${valid_archs}) 107 message(STATUS "Using cached valid architectures for ${os}.") 108 return() 109 endif() 110 111 set(archs ${ARGN}) 112 if(NOT TEST_COMPILE_ONLY) 113 message(STATUS "Finding valid architectures for ${os}...") 114 set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c) 115 file(WRITE ${SIMPLE_C} "#include <stdio.h>\nint main() { printf(__FILE__); return 0; }\n") 116 117 set(os_linker_flags) 118 foreach(flag ${DARWIN_${os}_LINK_FLAGS}) 119 set(os_linker_flags "${os_linker_flags} ${flag}") 120 endforeach() 121 122 # Disable building for i386 for macOS SDK >= 10.15. The SDK doesn't support 123 # linking for i386 and the corresponding OS doesn't allow running macOS i386 124 # binaries. 125 if ("${os}" STREQUAL "osx") 126 find_darwin_sdk_version(macosx_sdk_version "macosx") 127 if ("${macosx_sdk_version}" VERSION_GREATER 10.15 OR "${macosx_sdk_version}" VERSION_EQUAL 10.15) 128 message(STATUS "Disabling i386 slice for ${valid_archs}") 129 list(REMOVE_ITEM archs "i386") 130 endif() 131 endif() 132 endif() 133 134 # The simple program will build for x86_64h on the simulator because it is 135 # compatible with x86_64 libraries (mostly), but since x86_64h isn't actually 136 # a valid or useful architecture for the iOS simulator we should drop it. 137 if(${os} MATCHES "^(iossim|tvossim|watchossim)$") 138 list(REMOVE_ITEM archs "x86_64h") 139 endif() 140 141 set(working_archs) 142 foreach(arch ${archs}) 143 144 set(arch_linker_flags "-arch ${arch} ${os_linker_flags}") 145 if(TEST_COMPILE_ONLY) 146 # `-w` is used to surpress compiler warnings which `try_compile_only()` treats as an error. 147 try_compile_only(CAN_TARGET_${os}_${arch} FLAGS -v -arch ${arch} ${DARWIN_${os}_CFLAGS} -w) 148 else() 149 set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) 150 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${arch_linker_flags}") 151 try_compile(CAN_TARGET_${os}_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_C} 152 COMPILE_DEFINITIONS "-v -arch ${arch}" ${DARWIN_${os}_CFLAGS} 153 OUTPUT_VARIABLE TEST_OUTPUT) 154 set(CMAKE_EXE_LINKER_FLAGS ${SAVED_CMAKE_EXE_LINKER_FLAGS}) 155 endif() 156 if(${CAN_TARGET_${os}_${arch}}) 157 list(APPEND working_archs ${arch}) 158 else() 159 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 160 "Testing compiler for supporting ${os}-${arch}:\n" 161 "${TEST_OUTPUT}\n") 162 endif() 163 endforeach() 164 set(${valid_archs} ${working_archs} 165 CACHE STRING "List of valid architectures for platform ${os}." FORCE) 166endfunction() 167 168# This function checks the host cpusubtype to see if it is post-haswell. Haswell 169# and later machines can run x86_64h binaries. Haswell is cpusubtype 8. 170function(darwin_filter_host_archs input output) 171 list_intersect(tmp_var DARWIN_osx_ARCHS ${input}) 172 execute_process( 173 COMMAND sysctl hw.cpusubtype 174 OUTPUT_VARIABLE SUBTYPE) 175 176 string(REGEX MATCH "hw.cpusubtype: ([0-9]*)" 177 SUBTYPE_MATCHED "${SUBTYPE}") 178 set(HASWELL_SUPPORTED Off) 179 if(SUBTYPE_MATCHED) 180 if(${CMAKE_MATCH_1} GREATER 7) 181 set(HASWELL_SUPPORTED On) 182 endif() 183 endif() 184 if(NOT HASWELL_SUPPORTED) 185 list(REMOVE_ITEM tmp_var x86_64h) 186 endif() 187 set(${output} ${tmp_var} PARENT_SCOPE) 188endfunction() 189 190# Read and process the exclude file into a list of symbols 191function(darwin_read_list_from_file output_var file) 192 if(EXISTS ${file}) 193 file(READ ${file} EXCLUDES) 194 string(REPLACE "\n" ";" EXCLUDES ${EXCLUDES}) 195 set(${output_var} ${EXCLUDES} PARENT_SCOPE) 196 endif() 197endfunction() 198 199# this function takes an OS, architecture and minimum version and provides a 200# list of builtin functions to exclude 201function(darwin_find_excluded_builtins_list output_var) 202 cmake_parse_arguments(LIB 203 "" 204 "OS;ARCH;MIN_VERSION" 205 "" 206 ${ARGN}) 207 208 if(NOT LIB_OS OR NOT LIB_ARCH) 209 message(FATAL_ERROR "Must specify OS and ARCH to darwin_find_excluded_builtins_list!") 210 endif() 211 212 darwin_read_list_from_file(${LIB_OS}_BUILTINS 213 ${DARWIN_EXCLUDE_DIR}/${LIB_OS}.txt) 214 darwin_read_list_from_file(${LIB_OS}_${LIB_ARCH}_BASE_BUILTINS 215 ${DARWIN_EXCLUDE_DIR}/${LIB_OS}-${LIB_ARCH}.txt) 216 217 if(LIB_MIN_VERSION) 218 file(GLOB builtin_lists ${DARWIN_EXCLUDE_DIR}/${LIB_OS}*-${LIB_ARCH}.txt) 219 foreach(builtin_list ${builtin_lists}) 220 string(REGEX MATCH "${LIB_OS}([0-9\\.]*)-${LIB_ARCH}.txt" VERSION_MATCHED "${builtin_list}") 221 if (VERSION_MATCHED AND NOT CMAKE_MATCH_1 VERSION_LESS LIB_MIN_VERSION) 222 if(NOT smallest_version) 223 set(smallest_version ${CMAKE_MATCH_1}) 224 elseif(CMAKE_MATCH_1 VERSION_LESS smallest_version) 225 set(smallest_version ${CMAKE_MATCH_1}) 226 endif() 227 endif() 228 endforeach() 229 230 if(smallest_version) 231 darwin_read_list_from_file(${LIB_ARCH}_${LIB_OS}_BUILTINS 232 ${DARWIN_EXCLUDE_DIR}/${LIB_OS}${smallest_version}-${LIB_ARCH}.txt) 233 endif() 234 endif() 235 236 set(${output_var} 237 ${${LIB_ARCH}_${LIB_OS}_BUILTINS} 238 ${${LIB_OS}_${LIB_ARCH}_BASE_BUILTINS} 239 ${${LIB_OS}_BUILTINS} PARENT_SCOPE) 240endfunction() 241 242# adds a single builtin library for a single OS & ARCH 243macro(darwin_add_builtin_library name suffix) 244 cmake_parse_arguments(LIB 245 "" 246 "PARENT_TARGET;OS;ARCH" 247 "SOURCES;CFLAGS;DEFS" 248 ${ARGN}) 249 set(libname "${name}.${suffix}_${LIB_ARCH}_${LIB_OS}") 250 add_library(${libname} STATIC ${LIB_SOURCES}) 251 if(DARWIN_${LIB_OS}_SYSROOT) 252 set(sysroot_flag -isysroot ${DARWIN_${LIB_OS}_SYSROOT}) 253 endif() 254 255 # Make a copy of the compilation flags. 256 set(builtin_cflags ${LIB_CFLAGS}) 257 258 # Strip out any inappropriate flags for the target. 259 if("${LIB_ARCH}" MATCHES "^(armv7|armv7k|armv7s)$") 260 set(builtin_cflags "") 261 foreach(cflag "${LIB_CFLAGS}") 262 string(REPLACE "-fomit-frame-pointer" "" cflag "${cflag}") 263 list(APPEND builtin_cflags ${cflag}) 264 endforeach(cflag) 265 endif() 266 267 set_target_compile_flags(${libname} 268 ${sysroot_flag} 269 ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG} 270 ${builtin_cflags}) 271 set_property(TARGET ${libname} APPEND PROPERTY 272 COMPILE_DEFINITIONS ${LIB_DEFS}) 273 set_target_properties(${libname} PROPERTIES 274 OUTPUT_NAME ${libname}${COMPILER_RT_OS_SUFFIX}) 275 set_target_properties(${libname} PROPERTIES 276 OSX_ARCHITECTURES ${LIB_ARCH}) 277 278 if(LIB_PARENT_TARGET) 279 add_dependencies(${LIB_PARENT_TARGET} ${libname}) 280 endif() 281 282 list(APPEND ${LIB_OS}_${suffix}_libs ${libname}) 283 list(APPEND ${LIB_OS}_${suffix}_lipo_flags -arch ${arch} $<TARGET_FILE:${libname}>) 284 set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Libraries") 285endmacro() 286 287function(darwin_lipo_libs name) 288 cmake_parse_arguments(LIB 289 "" 290 "PARENT_TARGET;OUTPUT_DIR;INSTALL_DIR" 291 "LIPO_FLAGS;DEPENDS" 292 ${ARGN}) 293 if(LIB_DEPENDS AND LIB_LIPO_FLAGS) 294 add_custom_command(OUTPUT ${LIB_OUTPUT_DIR}/lib${name}.a 295 COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_OUTPUT_DIR} 296 COMMAND ${CMAKE_LIPO} -output 297 ${LIB_OUTPUT_DIR}/lib${name}.a 298 -create ${LIB_LIPO_FLAGS} 299 DEPENDS ${LIB_DEPENDS} 300 ) 301 add_custom_target(${name} 302 DEPENDS ${LIB_OUTPUT_DIR}/lib${name}.a) 303 set_target_properties(${name} PROPERTIES FOLDER "Compiler-RT Misc") 304 add_dependencies(${LIB_PARENT_TARGET} ${name}) 305 306 if(CMAKE_CONFIGURATION_TYPES) 307 set(install_component ${LIB_PARENT_TARGET}) 308 else() 309 set(install_component ${name}) 310 endif() 311 install(FILES ${LIB_OUTPUT_DIR}/lib${name}.a 312 DESTINATION ${LIB_INSTALL_DIR} 313 COMPONENT ${install_component}) 314 add_compiler_rt_install_targets(${name} PARENT_TARGET ${LIB_PARENT_TARGET}) 315 else() 316 message(WARNING "Not generating lipo target for ${name} because no input libraries exist.") 317 endif() 318endfunction() 319 320# Generates builtin libraries for all operating systems specified in ARGN. Each 321# OS library is constructed by lipo-ing together single-architecture libraries. 322macro(darwin_add_builtin_libraries) 323 set(DARWIN_EXCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Darwin-excludes) 324 325 set(CFLAGS "-fPIC -O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer") 326 set(CMAKE_C_FLAGS "") 327 set(CMAKE_CXX_FLAGS "") 328 set(CMAKE_ASM_FLAGS "") 329 330 set(PROFILE_SOURCES ../profile/InstrProfiling 331 ../profile/InstrProfilingBuffer 332 ../profile/InstrProfilingPlatformDarwin 333 ../profile/InstrProfilingWriter) 334 foreach (os ${ARGN}) 335 list_intersect(DARWIN_BUILTIN_ARCHS DARWIN_${os}_BUILTIN_ARCHS BUILTIN_SUPPORTED_ARCH) 336 foreach (arch ${DARWIN_BUILTIN_ARCHS}) 337 darwin_find_excluded_builtins_list(${arch}_${os}_EXCLUDED_BUILTINS 338 OS ${os} 339 ARCH ${arch} 340 MIN_VERSION ${DARWIN_${os}_BUILTIN_MIN_VER}) 341 342 filter_builtin_sources(filtered_sources 343 EXCLUDE ${arch}_${os}_EXCLUDED_BUILTINS 344 ${${arch}_SOURCES}) 345 346 darwin_add_builtin_library(clang_rt builtins 347 OS ${os} 348 ARCH ${arch} 349 SOURCES ${filtered_sources} 350 CFLAGS ${CFLAGS} -arch ${arch} 351 PARENT_TARGET builtins) 352 endforeach() 353 354 # Don't build cc_kext libraries for simulator platforms 355 if(NOT DARWIN_${os}_SKIP_CC_KEXT) 356 foreach (arch ${DARWIN_BUILTIN_ARCHS}) 357 # By not specifying MIN_VERSION this only reads the OS and OS-arch lists. 358 # We don't want to filter out the builtins that are present in libSystem 359 # because kexts can't link libSystem. 360 darwin_find_excluded_builtins_list(${arch}_${os}_EXCLUDED_BUILTINS 361 OS ${os} 362 ARCH ${arch}) 363 364 filter_builtin_sources(filtered_sources 365 EXCLUDE ${arch}_${os}_EXCLUDED_BUILTINS 366 ${${arch}_SOURCES}) 367 368 # In addition to the builtins cc_kext includes some profile sources 369 darwin_add_builtin_library(clang_rt cc_kext 370 OS ${os} 371 ARCH ${arch} 372 SOURCES ${filtered_sources} ${PROFILE_SOURCES} 373 CFLAGS ${CFLAGS} -arch ${arch} -mkernel 374 DEFS KERNEL_USE 375 PARENT_TARGET builtins) 376 endforeach() 377 set(archive_name clang_rt.cc_kext_${os}) 378 if(${os} STREQUAL "osx") 379 set(archive_name clang_rt.cc_kext) 380 endif() 381 darwin_lipo_libs(${archive_name} 382 PARENT_TARGET builtins 383 LIPO_FLAGS ${${os}_cc_kext_lipo_flags} 384 DEPENDS ${${os}_cc_kext_libs} 385 OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR} 386 INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR}) 387 endif() 388 endforeach() 389 390 # We put the x86 sim slices into the archives for their base OS 391 foreach (os ${ARGN}) 392 if(NOT ${os} MATCHES ".*sim$") 393 darwin_lipo_libs(clang_rt.${os} 394 PARENT_TARGET builtins 395 LIPO_FLAGS ${${os}_builtins_lipo_flags} ${${os}sim_builtins_lipo_flags} 396 DEPENDS ${${os}_builtins_libs} ${${os}sim_builtins_libs} 397 OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR} 398 INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR}) 399 endif() 400 endforeach() 401 darwin_add_embedded_builtin_libraries() 402endmacro() 403 404macro(darwin_add_embedded_builtin_libraries) 405 # this is a hacky opt-out. If you can't target both intel and arm 406 # architectures we bail here. 407 set(DARWIN_SOFT_FLOAT_ARCHS armv6m armv7m armv7em armv7) 408 set(DARWIN_HARD_FLOAT_ARCHS armv7em armv7) 409 if(COMPILER_RT_SUPPORTED_ARCH MATCHES ".*armv.*") 410 list(FIND COMPILER_RT_SUPPORTED_ARCH i386 i386_idx) 411 if(i386_idx GREATER -1) 412 list(APPEND DARWIN_HARD_FLOAT_ARCHS i386) 413 endif() 414 415 list(FIND COMPILER_RT_SUPPORTED_ARCH x86_64 x86_64_idx) 416 if(x86_64_idx GREATER -1) 417 list(APPEND DARWIN_HARD_FLOAT_ARCHS x86_64) 418 endif() 419 420 set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded) 421 422 set(CFLAGS "-Oz -Wall -fomit-frame-pointer -ffreestanding") 423 set(CMAKE_C_FLAGS "") 424 set(CMAKE_CXX_FLAGS "") 425 set(CMAKE_ASM_FLAGS "") 426 427 set(SOFT_FLOAT_FLAG -mfloat-abi=soft) 428 set(HARD_FLOAT_FLAG -mfloat-abi=hard) 429 430 set(ENABLE_PIC Off) 431 set(PIC_FLAG -fPIC) 432 set(STATIC_FLAG -static) 433 434 set(DARWIN_macho_embedded_ARCHS armv6m armv7m armv7em armv7 i386 x86_64) 435 436 set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR 437 ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded) 438 set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR 439 ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded) 440 441 set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi") 442 set(CFLAGS_i386 "-march=pentium") 443 444 darwin_read_list_from_file(common_FUNCTIONS ${MACHO_SYM_DIR}/common.txt) 445 darwin_read_list_from_file(thumb2_FUNCTIONS ${MACHO_SYM_DIR}/thumb2.txt) 446 darwin_read_list_from_file(thumb2_64_FUNCTIONS ${MACHO_SYM_DIR}/thumb2-64.txt) 447 darwin_read_list_from_file(arm_FUNCTIONS ${MACHO_SYM_DIR}/arm.txt) 448 darwin_read_list_from_file(i386_FUNCTIONS ${MACHO_SYM_DIR}/i386.txt) 449 450 451 set(armv6m_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS}) 452 set(armv7m_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS} ${thumb2_FUNCTIONS}) 453 set(armv7em_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS} ${thumb2_FUNCTIONS}) 454 set(armv7_FUNCTIONS ${common_FUNCTIONS} ${arm_FUNCTIONS} ${thumb2_FUNCTIONS} ${thumb2_64_FUNCTIONS}) 455 set(i386_FUNCTIONS ${common_FUNCTIONS} ${i386_FUNCTIONS}) 456 set(x86_64_FUNCTIONS ${common_FUNCTIONS}) 457 458 foreach(arch ${DARWIN_macho_embedded_ARCHS}) 459 filter_builtin_sources(${arch}_filtered_sources 460 INCLUDE ${arch}_FUNCTIONS 461 ${${arch}_SOURCES}) 462 if(NOT ${arch}_filtered_sources) 463 message(WARNING "${arch}_SOURCES: ${${arch}_SOURCES}") 464 message(WARNING "${arch}_FUNCTIONS: ${${arch}_FUNCTIONS}") 465 message(FATAL_ERROR "Empty filtered sources!") 466 endif() 467 endforeach() 468 469 foreach(float_type SOFT HARD) 470 foreach(type PIC STATIC) 471 string(TOLOWER "${float_type}_${type}" lib_suffix) 472 foreach(arch ${DARWIN_${float_type}_FLOAT_ARCHS}) 473 set(DARWIN_macho_embedded_SYSROOT ${DARWIN_osx_SYSROOT}) 474 set(float_flag) 475 if(${arch} MATCHES "^arm") 476 # x86 targets are hard float by default, but the complain about the 477 # float ABI flag, so don't pass it unless we're targeting arm. 478 set(float_flag ${${float_type}_FLOAT_FLAG}) 479 endif() 480 darwin_add_builtin_library(clang_rt ${lib_suffix} 481 OS macho_embedded 482 ARCH ${arch} 483 SOURCES ${${arch}_filtered_sources} 484 CFLAGS ${CFLAGS} -arch ${arch} ${${type}_FLAG} ${float_flag} ${CFLAGS_${arch}} 485 PARENT_TARGET builtins) 486 endforeach() 487 foreach(lib ${macho_embedded_${lib_suffix}_libs}) 488 set_target_properties(${lib} PROPERTIES LINKER_LANGUAGE C) 489 endforeach() 490 darwin_lipo_libs(clang_rt.${lib_suffix} 491 PARENT_TARGET builtins 492 LIPO_FLAGS ${macho_embedded_${lib_suffix}_lipo_flags} 493 DEPENDS ${macho_embedded_${lib_suffix}_libs} 494 OUTPUT_DIR ${DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR} 495 INSTALL_DIR ${DARWIN_macho_embedded_LIBRARY_INSTALL_DIR}) 496 endforeach() 497 endforeach() 498 endif() 499endmacro() 500