Skip to content

Commit

Permalink
Fix CMake LLVM_TARGETS_TO_BUILD "Native" option to work with JIT
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joker-eph committed Feb 2, 2021
1 parent b4106f9 commit bb02129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 0 additions & 4 deletions llvm/CMakeLists.txt
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions llvm/cmake/config-ix.cmake
Expand Up @@ -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)
Expand Down

0 comments on commit bb02129

Please sign in to comment.