Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -258,6 +258,7 @@ set(X86_64 x86_64 x86_64h) endif() +set(ALL_BUILTIN_SUPPORTED_ARCH i386 ${X86_64} ${ARM32} ${ARM64}) set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86_64} i386 i686 powerpc64 powerpc64le ${ARM32} ${ARM64} mips mips64 mipsel mips64el) set(ALL_ASAN_SUPPORTED_ARCH ${X86_64} i386 i686 powerpc64 powerpc64le ${ARM32} @@ -380,6 +381,8 @@ # for list_union include(CompilerRTUtils) + list_union(BUILTIN_SUPPORTED_ARCH ALL_BUILTIN_SUPPORTED_ARCH toolchain_arches) + list_union(SANITIZER_COMMON_SUPPORTED_ARCH ALL_SANITIZER_COMMON_SUPPORTED_ARCH COMPILER_RT_SUPPORTED_ARCH @@ -414,6 +417,8 @@ else() # Architectures supported by compiler-rt libraries. filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH + ${ALL_BUILTIN_SUPPORTED_ARCH}) + filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH ${ALL_SANITIZER_COMMON_SUPPORTED_ARCH}) # LSan and UBSan common files should be available on all architectures # supported by other sanitizers (even if they build into dummy object files). Index: lib/builtins/CMakeLists.txt =================================================================== --- lib/builtins/CMakeLists.txt +++ lib/builtins/CMakeLists.txt @@ -159,6 +159,7 @@ x86_64/floatundisf.S x86_64/floatundixf.S ${GENERIC_SOURCES}) +set(x86_64h_SOURCES ${x86_64_SOURCES}) if(WIN32) set(x86_64_SOURCES @@ -301,14 +302,51 @@ trunctfsf2.c ${GENERIC_SOURCES}) +set(armv7_SOURCES ${arm_SOURCES}) +set(armv7s_SOURCES ${arm_SOURCES}) +set(arm64_SOURCES ${aarch64_SOURCES}) + add_custom_target(builtins) -if(APPLE) - set(OS_OPTION OS osx) -endif() +if (APPLE) + foreach (os osx) + list_union(DARWIN_BUILTIN_ARCHS DARWIN_${os}_ARCHS BUILTIN_SUPPORTED_ARCH) + set(${os}_builtin_libs) + set(${os}_builtin_lipo_flags) + foreach (arch ${DARWIN_BUILTIN_ARCHS}) + # Filter out generic versions of routines that are re-implemented in + # architecture specific manner. This prevents multiple definitions of the + # same symbols, making the symbol selection non-deterministic. + foreach (_file ${${arch}_SOURCES}) + if (${_file} MATCHES ${arch}/*) + get_filename_component(_name ${_file} NAME) + string(REPLACE ".S" ".c" _cname "${_name}") + list(REMOVE_ITEM ${arch}_SOURCES ${_cname}) + endif () + endforeach () + + add_compiler_rt_runtime(clang_rt.builtins_${arch} STATIC + OS ${os} + ARCHS ${arch} + SOURCES ${${arch}_SOURCES} + CFLAGS "-std=c99" ${DARWIN_${os}_CFLAGS} -arch ${arch} + PARENT_TARGET builtins) + list(APPEND ${os}_builtin_libs clang_rt.builtins_${arch}_${os}) + set(${os}_builtin_lipo_flags ${${os}_builtin_lipo_flags} -arch ${arch} ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/libclang_rt.builtins_${arch}_${os}.a) + endforeach() -if (NOT WIN32 OR MINGW) - foreach (arch x86_64 i386 i686 arm aarch64) + if(${os}_builtin_libs) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.builtins_${os}.a + COMMAND lipo -output ${COMPILER_RT_LIBRARY_OUTPUT_DIR}/clang_rt.builtins_${os}.a -create ${${os}_builtin_lipo_flags} + DEPENDS ${${os}_builtin_libs} + ) + add_custom_target(clang_rt.builtins_${os} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.builtins_${os}.a) + add_dependencies(builtins clang_rt.builtins_${os}) + endif() + endforeach() +elseif (NOT WIN32 OR MINGW) + foreach (arch ${BUILTIN_SUPPORTED_ARCH}) if (CAN_TARGET_${arch}) # Filter out generic versions of routines that are re-implemented in # architecture specific manner. This prevents multiple definitions of the @@ -323,8 +361,7 @@ add_compiler_rt_runtime(clang_rt.builtins STATIC - ARCH ${arch} - ${OS_OPTION} + ARCHS ${arch} SOURCES ${${arch}_SOURCES} CFLAGS "-std=c99" PARENT_TARGET builtins)