[CMake] Use LLVM_TARGET_TRIPLE in runtimes

This variable is derived from LLVM_DEFAULT_TARGET_TRIPLE by default,
but using a separate variable allows additional normalization to be
performed if needed.

Differential Revision: https://reviews.llvm.org/D137451
This commit is contained in:
Petr Hosek 2022-02-15 22:59:08 -08:00
parent eb7e2998d1
commit bec8a372fc
13 changed files with 23 additions and 23 deletions

View File

@ -693,8 +693,8 @@ else()
set(CAN_SYMBOLIZE 1)
endif()
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold DOC "GNU gold")
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
find_program(GOLD_EXECUTABLE NAMES ${LLVM_TARGET_TRIPLE}-ld.gold ld.gold DOC "GNU gold")
if(COMPILER_RT_SUPPORTED_ARCH)
list(REMOVE_DUPLICATES COMPILER_RT_SUPPORTED_ARCH)

View File

@ -10,7 +10,7 @@ set_target_properties(
)
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE})
else()
set(LIBC_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX})
endif()

View File

@ -413,12 +413,12 @@ set(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared lib
set(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.")
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_TARGET_TRIPLE})
set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1")
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_TARGET_TRIPLE}/c++/v1")
set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE} CACHE PATH
"Path where built libc++ libraries should be installed.")
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_TARGET_TRIPLE}/c++/v1" CACHE PATH
"Path where target-specific libc++ headers should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR})

View File

@ -281,7 +281,7 @@ libc++ specific options
.. option:: LIBCXX_INSTALL_INCLUDE_TARGET_DIR:PATH
**Default**: ``include/c++/v1`` or
``include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1``
``include/${LLVM_TARGET_TRIPLE}/c++/v1``
Path where target-specific libc++ headers should be installed. If a relative
path, relative to ``CMAKE_INSTALL_PREFIX``.

View File

@ -43,7 +43,7 @@ endfunction()
if (CMAKE_CXX_COMPILER_TARGET)
set(triple "${CMAKE_CXX_COMPILER_TARGET}")
else()
set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
set(triple "${LLVM_TARGET_TRIPLE}")
endif()
cxx_abi_list_identifier(abi_list_identifier
"${triple}"

View File

@ -29,7 +29,7 @@ endif()
if (CMAKE_CXX_COMPILER_TARGET)
serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
else()
serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
serialize_lit_param(target_triple "\"${LLVM_TARGET_TRIPLE}\"")
endif()
if (LLVM_USE_SANITIZER)

View File

@ -189,8 +189,8 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR})
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_TARGET_TRIPLE})
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE} CACHE PATH
"Path where built libc++abi libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})

View File

@ -50,7 +50,7 @@ endif()
if (CMAKE_CXX_COMPILER_TARGET)
serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
else()
serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
serialize_lit_param(target_triple "\"${LLVM_TARGET_TRIPLE}\"")
endif()
foreach(param IN LISTS LIBCXXABI_TEST_PARAMS)

View File

@ -115,8 +115,8 @@ set(LIBUNWIND_SHARED_OUTPUT_NAME "unwind" CACHE STRING "Output name for the shar
set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind" CACHE STRING "Output name for the static libunwind runtime library.")
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH
set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_TARGET_TRIPLE})
set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_TARGET_TRIPLE} CACHE PATH
"Path where built libunwind libraries should be installed.")
if(LIBCXX_LIBDIR_SUBDIR)
string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR})

View File

@ -29,7 +29,7 @@ endif()
if (CMAKE_CXX_COMPILER_TARGET)
serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
else()
serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
serialize_lit_param(target_triple "\"${LLVM_TARGET_TRIPLE}\"")
endif()
foreach(param IN LISTS LIBUNWIND_TEST_PARAMS)

View File

@ -78,7 +78,7 @@ function(llvm_ExternalProject_Add name source_dir)
endif()
if(NOT ARG_TARGET_TRIPLE)
set(target_triple ${LLVM_DEFAULT_TARGET_TRIPLE})
set(target_triple ${LLVM_TARGET_TRIPLE})
else()
set(target_triple ${ARG_TARGET_TRIPLE})
endif()

View File

@ -74,7 +74,7 @@ function(builtin_default_target compiler_rt_path)
DEPENDS ${ARG_DEPENDS}
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
-DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
-DLLVM_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
@ -108,7 +108,7 @@ function(builtin_register_target compiler_rt_path target)
DEPENDS ${ARG_DEPENDS}
CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
-DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-DLLVM_TARGET_TRIPLE=${target}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-DCMAKE_C_COMPILER_WORKS=ON
-DCMAKE_ASM_COMPILER_WORKS=ON
@ -228,7 +228,7 @@ function(runtime_default_target)
# Builtins were built separately above
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
-DLLVM_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
-DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
@ -337,7 +337,7 @@ function(runtime_register_target name target)
# Builtins were built separately above
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DLLVM_DEFAULT_TARGET_TRIPLE=${target}
-DLLVM_TARGET_TRIPLE=${target}
-DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-DCMAKE_C_COMPILER_WORKS=ON

View File

@ -154,8 +154,8 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter)
# Host triple is used by tests to check if they are running natively.
include(GetHostTriple)
get_host_triple(LLVM_HOST_TRIPLE)
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
"Default target for which the runtimes will be built.")
set(LLVM_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
"Target for which the runtimes will be built.")
option(LLVM_INCLUDE_TESTS "Generate build targets for the runtimes unit tests." ON)
option(LLVM_INCLUDE_DOCS "Generate build targets for the runtimes documentation." ON)