[llvm] bb02129 - Fix CMake LLVM_TARGETS_TO_BUILD "Native" option to work with JIT

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 2 10:47:34 PST 2021


Author: Mehdi Amini
Date: 2021-02-02T18:47:15Z
New Revision: bb0212929e36732585f0b43f9b0301af51953667

URL: https://github.com/llvm/llvm-project/commit/bb0212929e36732585f0b43f9b0301af51953667
DIFF: https://github.com/llvm/llvm-project/commit/bb0212929e36732585f0b43f9b0301af51953667.diff

LOG: Fix CMake LLVM_TARGETS_TO_BUILD "Native" option to work with JIT

LLVM_TARGETS_TO_BUILD accepts both "host" or "Native" for auto-selecting
the target from the environment. However the way "Native" was plumbed
would lead to the JIT environment being disabled. This patch is making
"Native" works just as "host".

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D95837

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 40be7a855932..1affc289e64b 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -669,10 +669,6 @@ set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
 # first cmake run
 include(config-ix)
 
-string(REPLACE "Native" ${LLVM_NATIVE_ARCH}
-  LLVM_TARGETS_TO_BUILD "${LLVM_TARGETS_TO_BUILD}")
-list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
-
 # By default, we target the host, but this can be overridden at CMake
 # invocation time.
 set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING

diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 818fafbce148..1f4b52df8b65 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -453,13 +453,15 @@ else ()
   message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}")
 endif ()
 
-# If build targets includes "host", then replace with native architecture.
-list(FIND LLVM_TARGETS_TO_BUILD "host" idx)
-if( NOT idx LESS 0 )
-  list(REMOVE_AT LLVM_TARGETS_TO_BUILD ${idx})
-  list(APPEND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH})
-  list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
-endif()
+# If build targets includes "host" or "Native", then replace with native architecture.
+foreach (NATIVE_KEYWORD host Native)
+  list(FIND LLVM_TARGETS_TO_BUILD ${NATIVE_KEYWORD} idx)
+  if( NOT idx LESS 0 )
+    list(REMOVE_AT LLVM_TARGETS_TO_BUILD ${idx})
+    list(APPEND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH})
+    list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
+  endif()
+endforeach()
 
 list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
 if (NATIVE_ARCH_IDX EQUAL -1)


        


More information about the llvm-commits mailing list