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