mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 05:40:09 +00:00
[runtimes] Properly handle the sysroot/triple/gcc-toolchain
In395271a
, I simplified how we handled the target triple for the runtimes. However, in doing so, we stopped considering the default in CMAKE_CXX_COMPILER_TARGET, so we'd use the LLVM_DEFAULT_TARGET_TRIPLE (which is the host triple) even if CMAKE_CXX_COMPILER_TARGET was specified. This commit fixes that problem and also refactors the code so that it's easy to see what the default value is. The fact that nobody seems to have been broken by this makes me think that perhaps nobody is using CMAKE_CXX_COMPILER_TARGET to specify the triple -- but it should still work. Differential Revision: https://reviews.llvm.org/D111672 (cherry picked from commit72117f2ffe
)
This commit is contained in:
parent
a797306b77
commit
30c05f43b6
@ -256,9 +256,15 @@ option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
|
||||
|
||||
# Target options --------------------------------------------------------------
|
||||
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
|
||||
set(LIBCXX_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Use alternate target triple.")
|
||||
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
|
||||
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_TARGET)
|
||||
set(LIBCXX_DEFAULT_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
else()
|
||||
set(LIBCXX_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
|
||||
endif()
|
||||
set(LIBCXX_TARGET_TRIPLE "${LIBCXX_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Use alternate target triple.")
|
||||
set(LIBCXX_SYSROOT "${CMAKE_SYSROOT}" CACHE STRING "Use alternate sysroot.")
|
||||
set(LIBCXX_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}" CACHE STRING "Use alternate GCC toolchain.")
|
||||
|
||||
# Feature options -------------------------------------------------------------
|
||||
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
|
||||
@ -468,21 +474,14 @@ include(HandleLibcxxFlags)
|
||||
# 'config-ix' use them during feature checks. It also adds them to both
|
||||
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
|
||||
add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32")
|
||||
|
||||
if(LIBCXX_TARGET_TRIPLE)
|
||||
add_target_flags_if_supported("--target=${LIBCXX_TARGET_TRIPLE}")
|
||||
elseif(CMAKE_CXX_COMPILER_TARGET)
|
||||
set(LIBCXX_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
endif()
|
||||
if(LIBCXX_SYSROOT)
|
||||
add_target_flags_if_supported("--sysroot=${LIBCXX_SYSROOT}")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
set(LIBCXX_SYSROOT "${CMAKE_SYSROOT}")
|
||||
endif()
|
||||
if(LIBCXX_GCC_TOOLCHAIN)
|
||||
add_target_flags_if_supported("--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
|
||||
elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
||||
set(LIBCXX_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
# Configure compiler.
|
||||
|
@ -111,9 +111,16 @@ option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit te
|
||||
set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
||||
"Define suffix of library directory name (32/64)")
|
||||
option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON)
|
||||
set(LIBCXXABI_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling.")
|
||||
set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
|
||||
set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_TARGET)
|
||||
set(LIBCXXABI_DEFAULT_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
else()
|
||||
set(LIBCXXABI_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
|
||||
endif()
|
||||
set(LIBCXXABI_TARGET_TRIPLE "${LIBCXXABI_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling.")
|
||||
set(LIBCXXABI_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}" CACHE PATH "GCC toolchain for cross compiling.")
|
||||
set(LIBCXXABI_SYSROOT "${CMAKE_SYSROOT}" CACHE PATH "Sysroot for cross compiling.")
|
||||
|
||||
set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
|
||||
set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
|
||||
"Version of libc++abi. This will be reflected in the name of the shared \
|
||||
@ -259,18 +266,12 @@ add_target_flags_if(LIBCXXABI_BUILD_32_BITS "-m32")
|
||||
|
||||
if(LIBCXXABI_TARGET_TRIPLE)
|
||||
add_target_flags_if_supported("--target=${LIBCXXABI_TARGET_TRIPLE}")
|
||||
elseif(CMAKE_CXX_COMPILER_TARGET)
|
||||
set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
endif()
|
||||
if(LIBCXX_GCC_TOOLCHAIN)
|
||||
if(LIBCXXABI_GCC_TOOLCHAIN)
|
||||
add_target_flags_if_supported("--gcc-toolchain=${LIBCXXABI_GCC_TOOLCHAIN}")
|
||||
elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
||||
set(LIBCXXABI_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
|
||||
endif()
|
||||
if(LIBCXXABI_SYSROOT)
|
||||
add_target_flags_if_supported("--sysroot=${LIBCXXABI_SYSROOT}")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
set(LIBCXXABI_SYSROOT "${CMAKE_SYSROOT}")
|
||||
endif()
|
||||
|
||||
# Configure compiler. Must happen after setting the target flags.
|
||||
|
@ -77,9 +77,14 @@ cmake_dependent_option(LIBUNWIND_INSTALL_STATIC_LIBRARY
|
||||
cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY
|
||||
"Install the shared libunwind library." ON
|
||||
"LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF)
|
||||
set(LIBUNWIND_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling.")
|
||||
set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
|
||||
set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
|
||||
if(CMAKE_CXX_COMPILER_TARGET)
|
||||
set(LIBUNWIND_DEFAULT_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
else()
|
||||
set(LIBUNWIND_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
|
||||
endif()
|
||||
set(LIBUNWIND_TARGET_TRIPLE "${LIBUNWIND_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling.")
|
||||
set(LIBUNWIND_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}" CACHE PATH "GCC toolchain for cross compiling.")
|
||||
set(LIBUNWIND_SYSROOT "${CMAKE_SYSROOT}" CACHE PATH "Sysroot for cross compiling.")
|
||||
set(LIBUNWIND_TEST_LINKER_FLAGS "" CACHE STRING
|
||||
"Additional linker flags for test programs.")
|
||||
set(LIBUNWIND_TEST_COMPILER_FLAGS "" CACHE STRING
|
||||
@ -153,18 +158,12 @@ add_target_flags_if(LIBUNWIND_BUILD_32_BITS "-m32")
|
||||
|
||||
if(LIBUNWIND_TARGET_TRIPLE)
|
||||
add_target_flags_if_supported("--target=${LIBUNWIND_TARGET_TRIPLE}")
|
||||
elseif(CMAKE_CXX_COMPILER_TARGET)
|
||||
set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
||||
endif()
|
||||
if(LIBUNWIND_GCC_TOOLCHAIN)
|
||||
add_target_flags_if_supported("--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}")
|
||||
elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
||||
set(LIBUNWIND_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
|
||||
endif()
|
||||
if(LIBUNWIND_SYSROOT)
|
||||
add_target_flags_if_supported("--sysroot=${LIBUNWIND_SYSROOT}")
|
||||
elseif(CMAKE_SYSROOT)
|
||||
set(LIBUNWIND_SYSROOT "${CMAKE_SYSROOT}")
|
||||
endif()
|
||||
|
||||
# Configure compiler.
|
||||
|
Loading…
Reference in New Issue
Block a user