[PATCH 1014/1017] improve grouping of ENABLE_HOST_CPU_DEVICES specific tests
authorAndreas Beckmann <anbe@debian.org>
Tue, 15 Mar 2022 09:33:22 +0000 (10:33 +0100)
committerAndreas Beckmann <anbe@debian.org>
Tue, 17 Jan 2023 13:11:18 +0000 (13:11 +0000)
Gbp-Pq: Name 1014-improve-grouping-of-ENABLE_HOST_CPU_DEVICES-specific.patch

CMakeLists.txt
cmake/LLVM.cmake

index 8c8741b684cd7a53e9520a8b979cb0ebb1d354e4..c988941a21ab0f1ff9141618580379ef7907d8f7 100644 (file)
@@ -1966,8 +1966,6 @@ if (ENABLE_LLVM)
   MESSAGE(STATUS "CLANG_HAS_64B_MATH: ${CLANG_HAS_64B_MATH}")
   MESSAGE(STATUS "CLANG_HAS_128B_MATH: ${CLANG_HAS_128B_MATH}")
   MESSAGE(STATUS "CLANG_NEEDS_RTLIB: ${CLANG_NEEDS_RTLIB}")
-  MESSAGE(STATUS "CLANG_MARCH_FLAG: ${CLANG_MARCH_FLAG}")
-  MESSAGE(STATUS "CLANG_TARGET_OPTION: ${CLANG_TARGET_OPTION}")
   MESSAGE(STATUS "LLVM_VERSION: ${LLVM_VERSION}")
   MESSAGE(STATUS "LLVM_LIB_IS_SHARED: ${LLVM_LIB_IS_SHARED}")
   MESSAGE(STATUS "LLVM_HAS_RTTI: ${LLVM_HAS_RTTI}")
@@ -1985,10 +1983,16 @@ if (ENABLE_LLVM)
   MESSAGE(STATUS "LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")
   MESSAGE(STATUS "LLVM_ALL_TARGETS: ${LLVM_ALL_TARGETS}")
   MESSAGE(STATUS "LLVM_HOST_TARGET: ${LLVM_HOST_TARGET}")
+  if(ENABLE_HOST_CPU_DEVICES)
+  MESSAGE(STATUS "CLANG_TARGET_OPTION: ${CLANG_TARGET_OPTION}")
+  MESSAGE(STATUS "CLANG_MARCH_FLAG: ${CLANG_MARCH_FLAG}")
   MESSAGE(STATUS "LLC_TRIPLE: ${LLC_TRIPLE}")
+  MESSAGE(STATUS "LLC_HOST_CPU_AUTO: ${LLC_HOST_CPU_AUTO}")
   MESSAGE(STATUS "LLC_HOST_CPU: ${LLC_HOST_CPU}")
-  MESSAGE(STATUS "")
+  MESSAGE(STATUS "HOST_CPU_FORCED: ${HOST_CPU_FORCED}")
+  endif()
 endif()
+MESSAGE(STATUS "")
 MESSAGE(STATUS "MAX_EXTENDED_ALIGNMENT: ${MAX_EXTENDED_ALIGNMENT}")
 MESSAGE(STATUS "OCL_KERNEL_TARGET: ${OCL_KERNEL_TARGET}")
 MESSAGE(STATUS "OCL_KERNEL_TARGET_CPU: ${OCL_KERNEL_TARGET_CPU}")
index 18138f362dcbbf8cc99928996869ea2a28a94d88..7c455ae1996bdc208c966ba4a7a158e7266279f8 100644 (file)
@@ -458,31 +458,6 @@ endmacro()
 ####################################################################
 ####################################################################
 
-# The option for specifying the target changed; try the modern syntax
-# first, and fall back to the old-style syntax if this failed
-
-if(NOT DEFINED CLANG_TARGET_OPTION AND ENABLE_HOST_CPU_DEVICES)
-
-  custom_try_compile_clangxx("" "return 0;" RES "--target=${LLVM_HOST_TARGET}")
-  if(NOT RES)
-    set(CLANG_TGT "--target=")
-  else()
-    #EXECUTE_PROCESS(COMMAND "${CLANG}" "-target ${LLVM_HOST_TARGET}" "-x" "c" "/dev/null" "-S" RESULT_VARIABLE RES)
-    custom_try_compile_clangxx("" "return 0;" RES "-target ${LLVM_HOST_TARGET}")
-    if(NOT RES)
-      set(CLANG_TGT "-target ")
-    else()
-      message(FATAL_ERROR "Cannot determine Clang option to specify the target")
-    endif()
-  endif()
-
-  set(CLANG_TARGET_OPTION ${CLANG_TGT} CACHE INTERNAL "Clang option used to specify the target" )
-
-endif()
-
-####################################################################
-####################################################################
-
 if(NOT DEFINED CLANG_NEEDS_RTLIB)
 
   set(RT128 OFF)
@@ -617,6 +592,31 @@ endif()
 
 ####################################################################
 
+if(ENABLE_HOST_CPU_DEVICES)
+
+# The option for specifying the target changed; try the modern syntax
+# first, and fall back to the old-style syntax if this failed
+
+if(NOT DEFINED CLANG_TARGET_OPTION)
+
+  custom_try_compile_clangxx("" "return 0;" RES "--target=${LLVM_HOST_TARGET}")
+  if(NOT RES)
+    set(CLANG_TGT "--target=")
+  else()
+    #EXECUTE_PROCESS(COMMAND "${CLANG}" "-target ${LLVM_HOST_TARGET}" "-x" "c" "/dev/null" "-S" RESULT_VARIABLE RES)
+    custom_try_compile_clangxx("" "return 0;" RES "-target ${LLVM_HOST_TARGET}")
+    if(NOT RES)
+      set(CLANG_TGT "-target ")
+    else()
+      message(FATAL_ERROR "Cannot determine Clang option to specify the target")
+    endif()
+  endif()
+
+  set(CLANG_TARGET_OPTION ${CLANG_TGT} CACHE INTERNAL "Clang option used to specify the target" )
+
+endif()
+
+
 # TODO: We need to set both target-triple and cpu-type when
 # building, since the ABI depends on both. We can either add flags
 # to all the scripts, or set the respective flags here in
@@ -631,8 +631,7 @@ endif()
 # depending on whether they are generated via clang or directly
 # via llc.
 
-
-if(ENABLE_HOST_CPU_DEVICES AND NOT DEFINED LLC_TRIPLE)
+if(NOT DEFINED LLC_TRIPLE)
   message(STATUS "Find out LLC target triple (for host ${LLVM_HOST_TARGET})")
   set(_EMPTY_C_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/tripletfind.c")
   file(WRITE "${_EMPTY_C_FILE}" "")
@@ -651,7 +650,6 @@ if(ENABLE_HOST_CPU_DEVICES AND NOT DEFINED LLC_TRIPLE)
   string(REPLACE "armv7l-" "armv7-" LLC_TRIPLE "${LLC_TRIPLE}")
 
   set(LLC_TRIPLE "${LLC_TRIPLE}" CACHE INTERNAL "LLC_TRIPLE")
-
 endif()
 
 
@@ -659,7 +657,7 @@ endif()
 # targeted if you pass -mcpu=native to llc, so we could replace this auto-detection
 # with just: set(LLC_HOST_CPU "native"), however, we can't do this at the moment
 # because of the work-around for arm1176jz-s.
-if(ENABLE_HOST_CPU_DEVICES AND NOT DEFINED LLC_HOST_CPU_AUTO)
+if(NOT DEFINED LLC_HOST_CPU_AUTO)
   message(STATUS "Find out LLC host CPU with ${LLVM_LLC}")
   execute_process(COMMAND ${LLVM_LLC} "--version" RESULT_VARIABLE RES_VAR OUTPUT_VARIABLE OUTPUT_VAR)
   if(RES_VAR)
@@ -679,8 +677,6 @@ if(ENABLE_HOST_CPU_DEVICES AND NOT DEFINED LLC_HOST_CPU_AUTO)
   endif()
 endif()
 
-
-
 if((LLC_HOST_CPU_AUTO MATCHES "unknown") AND (NOT LLC_HOST_CPU))
   message(FATAL_ERROR "LLVM could not recognize your CPU model automatically. Please run CMake with -DLLC_HOST_CPU=<cpu> (you can find valid names with: llc -mcpu=help)")
 else()
@@ -696,9 +692,7 @@ else()
 endif()
 
 
-####################################################################
 # Some architectures have -march and -mcpu reversed
-
 if(NOT DEFINED CLANG_MARCH_FLAG)
   message(STATUS "Checking clang -march vs. -mcpu flag")
   custom_try_compile_clang_silent("" "return 0;" RES ${CLANG_TARGET_OPTION}${LLC_TRIPLE} -march=${LLC_HOST_CPU})
@@ -717,6 +711,8 @@ if(NOT DEFINED CLANG_MARCH_FLAG)
   set(CLANG_MARCH_FLAG ${CLANG_MARCH_FLAG} CACHE INTERNAL "Clang option used to specify the target cpu")
 endif()
 
+endif(ENABLE_HOST_CPU_DEVICES)
+
 ####################################################################
 
 # This tests that we can actually link to the llvm libraries.