[compiler-rt] Fix detecting _Float16 support for secondary targets (#117813) 74/315874/1 accepted/tizen_base_dev accepted/tizen_base_x_asan accepted/tizen/base/20241210.211437 accepted/tizen/base/dev/20250313.233703 accepted/tizen/base/toolchain/20250112.233401 accepted/tizen/base/toolchain/20250410.112230 accepted/tizen/base/toolchain/20250417.112033 accepted/tizen/base/x/20241217.210911 accepted/tizen/base/x/asan/20241217.042712 accepted/tizen/base/x/asan/20241217.042754
authorAlexander Richardson <alexrichardson@google.com>
Thu, 28 Nov 2024 18:42:47 +0000 (10:42 -0800)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 5 Dec 2024 09:44:15 +0000 (18:44 +0900)
It turns out we were not passing -m32 to the check_c_source_compiles()
invocation since CMAKE_REQUIRE_FLAGS needs to be string separated list
and
we were passing a ;-separated CMake list which appears to be parsed by
CMake as 'ignore all arguments beyond the first'.
Fix this by transforming the list to a command line first.

With this change, Clang 17 no longer claims to support _Float16 for
i386.

(cherry-picked from commit a4c8ef0f401d86040594cc6f01bcdad9392e8ee2)

Change-Id: Ic2f851969dc9d641f07288e9eda61aa36999d5e6

compiler-rt/lib/builtins/CMakeLists.txt

index e0b2d08c207754bc5dbf12e3640feafaa7cb8e07..5499a8726207b7aea14ca6e1e299560493007764 100644 (file)
@@ -846,9 +846,12 @@ else ()
     if (CAN_TARGET_${arch})
       cmake_push_check_state()
       # TODO: we should probably make most of the checks in builtin-config depend on the target flags.
-      message(STATUS "Performing additional configure checks with target flags: ${TARGET_${arch}_CFLAGS}")
       set(BUILTIN_CFLAGS_${arch} ${BUILTIN_CFLAGS})
-      list(APPEND CMAKE_REQUIRED_FLAGS ${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}})
+      # CMAKE_REQUIRED_FLAGS must be a space separated string but unlike TARGET_${arch}_CFLAGS,
+      # BUILTIN_CFLAGS_${arch} is a CMake list, so we have to join it to create a valid command line.
+      list(JOIN BUILTIN_CFLAGS " " CMAKE_REQUIRED_FLAGS)
+      set(CMAKE_REQUIRED_FLAGS "${TARGET_${arch}_CFLAGS} ${BUILTIN_CFLAGS_${arch}}")
+      message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
       # For ARM archs, exclude any VFP builtins if VFP is not supported
       if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")
         string(REPLACE ";" " " _TARGET_${arch}_CFLAGS "${TARGET_${arch}_CFLAGS}")