diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake --- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake +++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake @@ -100,7 +100,7 @@ message(WARNING "Detecting supported architectures from 'ld -v' failed. Returning default set.") set(ARCHES "i386;x86_64;armv7;armv7s;arm64") endif() - + set(${output_var} ${ARCHES} PARENT_SCOPE) endfunction() @@ -135,7 +135,7 @@ endif() endif() - # The simple program will build for x86_64h on the simulator because it is + # The simple program will build for x86_64h on the simulator because it is # compatible with x86_64 libraries (mostly), but since x86_64h isn't actually # a valid or useful architecture for the iOS simulator we should drop it. if(${os} MATCHES "^(iossim|tvossim|watchossim)$") @@ -144,7 +144,7 @@ set(working_archs) foreach(arch ${archs}) - + set(arch_linker_flags "-arch ${arch} ${os_linker_flags}") if(TEST_COMPILE_ONLY) # `-w` is used to surpress compiler warnings which `try_compile_only()` treats as an error. @@ -257,7 +257,7 @@ ${DARWIN_EXCLUDE_DIR}/${LIB_OS}${smallest_version}-${LIB_ARCH}.txt) endif() endif() - + set(${output_var} ${${LIB_ARCH}_${LIB_OS}_BUILTINS} ${${LIB_OS}_${LIB_ARCH}_BASE_BUILTINS} @@ -416,9 +416,20 @@ EXCLUDE ${arch}_${os}_EXCLUDED_BUILTINS ${${arch}_SOURCES}) + if("${arch}" MATCHES "^(arm64|arm64e)$") + add_custom_target( + lse_builtin_symlinks + BYPRODUCTS ${lse_builtins} + ${arm64_lse_commands} + ) + + set(deps_${arch} lse_builtin_symlinks) + endif() + darwin_add_builtin_library(clang_rt builtins OS ${os} ARCH ${arch} + DEPS ${deps_${arch}} SOURCES ${filtered_sources} CFLAGS ${CFLAGS} -arch ${arch} PARENT_TARGET builtins) @@ -509,7 +520,7 @@ ${COMPILER_RT_OUTPUT_LIBRARY_DIR}/macho_embedded) set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR ${COMPILER_RT_INSTALL_LIBRARY_DIR}/macho_embedded) - + set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi") set(CFLAGS_i386 "-march=pentium") diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -531,10 +531,8 @@ foreach(model 1 2 3 4) if(pat STREQUAL "cas" OR NOT size STREQUAL "16") set(helper_asm "${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S") - add_custom_command( - OUTPUT ${helper_asm} - COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}" - ) + list(APPEND lse_builtins "${helper_asm}") + list(APPEND arm64_lse_commands COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}") set_source_files_properties("${helper_asm}" PROPERTIES COMPILE_DEFINITIONS "L_${pat};SIZE=${size};MODEL=${model}" @@ -741,9 +739,20 @@ list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128) endif() + if("${arch}" STREQUAL "aarch64") + add_custom_target( + lse_builtin_symlinks + BYPRODUCTS ${lse_builtins} + ${arm64_lse_commands} + ) + + set(deps_${arch} lse_builtin_symlinks) + endif() + add_compiler_rt_runtime(clang_rt.builtins STATIC ARCHS ${arch} + DEPS ${deps_${arch}} SOURCES ${${arch}_SOURCES} DEFS ${BUILTIN_DEFS} CFLAGS ${BUILTIN_CFLAGS_${arch}}