Skip to content

Commit ac4e25c

Browse files
committed
[compiler-rt][CMake] Pass all flags to try-compile
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} to the list, and then joins the elements with spaces, resulting in all arguments passed via CMAKE_REQUIRED_FLAGS being space-separated and being used in the try-compile when detecting Float16.
1 parent 75242a8 commit ac4e25c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,12 @@ else ()
854854
cmake_push_check_state()
855855
# TODO: we should probably make most of the checks in builtin-config depend on the target flags.
856856
set(BUILTIN_CFLAGS_${arch} ${BUILTIN_CFLAGS})
857-
# CMAKE_REQUIRED_FLAGS must be a space separated string but unlike TARGET_${arch}_CFLAGS,
858-
# BUILTIN_CFLAGS_${arch} is a CMake list, so we have to join it to create a valid command line.
859-
list(JOIN BUILTIN_CFLAGS " " CMAKE_REQUIRED_FLAGS)
860-
set(CMAKE_REQUIRED_FLAGS "${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}}")
857+
# CMAKE_REQUIRED_FLAGS must be a space separated string
858+
# Join BUILTIN_CFLAGS_${arch} and TARGET_${arch}_CFLAGS as a
859+
# space-separated string.
860+
set(CMAKE_REQUIRED_FLAGS ${BUILTIN_CFLAGS_${arch}})
861+
list(APPEND CMAKE_REQUIRED_FLAGS ${TARGET_${arch}_CFLAGS})
862+
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS)
861863
message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
862864
# For ARM archs, exclude any VFP builtins if VFP is not supported
863865
if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")

0 commit comments

Comments
 (0)