Skip to content

Commit e958952

Browse files
committed
[compiler-rt][CMake] Pass all flags to _Float16 try-compile (llvm#133952)
The try-compile mechanism requires that `CMAKE_REQUIRED_FLAGS` is a space-separated string instead of a list of flags. The original code expanded `BUILTIN_FLAGS` into `CMAKE_REQUIRED_FLAGS` as a space-separated string and then would overwrite `CMAKE_REQUIRED_FLAGS` with `TARGET_${arch}_CFLAGS` prepended to the unexpanded `BUILTIN_CFLAGS_${arch}`. This resulted in the first two arguments being passed into the try-compile invocation, but dropping the other arguments listed in `BUILTIN_CFLAGS_${arch}`. This patch appends `TARGET_${arch}_CFLAGS` and `BUILTIN_CFLAGS_${arch}` to `CMAKE_REQUIRED_FLAGS` before expanding CMAKE_REQUIRED_FLAGS as a space-separated string. This passes any pre-set required flags, in addition to all of the builtin and target flags to the Float16 detection. (cherry picked from commit 0d3f5ec)
1 parent 8b57579 commit e958952

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -849,15 +849,17 @@ else ()
849849
cmake_push_check_state()
850850
# TODO: we should probably make most of the checks in builtin-config depend on the target flags.
851851
set(BUILTIN_CFLAGS_${arch} ${BUILTIN_CFLAGS})
852-
# CMAKE_REQUIRED_FLAGS must be a space separated string but unlike TARGET_${arch}_CFLAGS,
853-
# BUILTIN_CFLAGS_${arch} is a CMake list, so we have to join it to create a valid command line.
854-
list(JOIN BUILTIN_CFLAGS " " CMAKE_REQUIRED_FLAGS)
855-
set(CMAKE_REQUIRED_FLAGS "${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}}")
852+
# CMAKE_REQUIRED_FLAGS must be a space separated string
853+
# Join BUILTIN_CFLAGS_${arch} and TARGET_${arch}_CFLAGS as a
854+
# space-separated string.
855+
list(APPEND CMAKE_REQUIRED_FLAGS
856+
${BUILTIN_CFLAGS_${arch}}
857+
${TARGET_${arch}_CFLAGS})
858+
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS)
856859
message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
857860
# For ARM archs, exclude any VFP builtins if VFP is not supported
858861
if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")
859-
string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")
860-
check_compile_definition(__ARM_FP "${CMAKE_C_FLAGS} ${_TARGET_${arch}_CFLAGS}" COMPILER_RT_HAS_${arch}_VFP)
862+
check_compile_definition(__ARM_FP "${CMAKE_C_FLAGS}" COMPILER_RT_HAS_${arch}_VFP)
861863
if(NOT COMPILER_RT_HAS_${arch}_VFP)
862864
list(REMOVE_ITEM ${arch}_SOURCES ${arm_Thumb1_VFPv2_DP_SOURCES} ${arm_Thumb1_VFPv2_SP_SOURCES} ${arm_Thumb1_SjLj_EH_SOURCES})
863865
else()

0 commit comments

Comments
 (0)