[CMake] Setting the LLVM_TARGET_TRIPLE macro based on the LLVM_DEFAULT_TARGET_TRIPLE

After D137870, LLVM_TARGET_TRIPLE is no longer defined on the runtime
path into compiler-rt. This patch creates a common block of code to set
LLVM_TARGET_TRIPLE equal to the default for both the llvm- and runtime-
paths.

Differential Revision: https://reviews.llvm.org/D138864
This commit is contained in:
Nicole Rabjohn 2022-12-13 19:54:52 -05:00 committed by David Tenty
parent beb3fa2d2e
commit 2ee308ceea
3 changed files with 18 additions and 11 deletions

View File

@ -857,17 +857,8 @@ else()
endif()
endif()
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
"Default target for which LLVM will generate code." )
if (TARGET_TRIPLE)
message(WARNING "TARGET_TRIPLE is deprecated and will be removed in a future release. "
"Please use LLVM_DEFAULT_TARGET_TRIPLE instead.")
set(LLVM_TARGET_TRIPLE "${TARGET_TRIPLE}")
else()
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
endif()
message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
include(SetTargetTriple)
set_llvm_target_triple()
if(WIN32 OR CYGWIN)
if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)

View File

@ -0,0 +1,13 @@
macro(set_llvm_target_triple)
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
"Default target for which LLVM will generate code." )
if (TARGET_TRIPLE)
message(WARNING "TARGET_TRIPLE is deprecated and will be removed in a future release. "
"Please use LLVM_DEFAULT_TARGET_TRIPLE instead.")
set(LLVM_TARGET_TRIPLE "${TARGET_TRIPLE}")
else()
set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
endif()
message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
endmacro()

View File

@ -176,6 +176,9 @@ endif()
# This can be used to detect whether we're in the runtimes build.
set(LLVM_RUNTIMES_BUILD ON)
include(SetTargetTriple)
set_llvm_target_triple()
foreach(entry ${runtimes})
get_filename_component(projName ${entry} NAME)