[runtimes] Remove FOO_TARGET_TRIPLE, FOO_SYSROOT and FOO_GCC_TOOLCHAIN
Instead, folks can use the equivalent variables provided by CMake
to set those. This removal aims to reduce complexity and potential
for confusion when setting the target triple for building the runtimes,
and make it correct when `CMAKE_OSX_ARCHITECTURES` is used (right now
both `-arch` and `--target=` will end up being passed, which is downright
incorrect).
Differential Revision: https://reviews.llvm.org/D112155
NOKEYCHECK=True
GitOrigin-RevId: 3ee0cec88effc88285732c8bec2a8f0e4e37c0b1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c966341..df7a630 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -282,24 +282,10 @@
message(FATAL_ERROR "LIBCXX_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead.")
endif()
-if(NOT CMAKE_SYSROOT AND LIBCXX_SYSROOT)
- message(WARNING "LIBCXX_SYSROOT is deprecated, please use CMAKE_SYSROOT instead")
+# TODO: Remove this after branching for LLVM 15
+if(LIBCXX_SYSROOT OR LIBCXX_TARGET_TRIPLE OR LIBCXX_GCC_TOOLCHAIN)
+ message(WARNING "LIBCXX_SYSROOT, LIBCXX_TARGET_TRIPLE and LIBCXX_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead")
endif()
-if(NOT CMAKE_CXX_COMPILER_TARGET AND LIBCXX_TARGET_TRIPLE)
- message(WARNING "LIBCXX_TARGET_TRIPLE is deprecated, please use CMAKE_CXX_COMPILER_TARGET instead")
-endif()
-if(NOT CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN AND LIBCXX_GCC_TOOLCHAIN)
- message(WARNING "LIBCXX_GCC_TOOLCHAIN is deprecated, please use CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN instead")
-endif()
-
-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)
@@ -494,15 +480,6 @@
if(ZOS)
add_target_flags_if_supported("-fzos-le-char-mode=ebcdic")
endif()
-if(LIBCXX_TARGET_TRIPLE)
- add_target_flags_if_supported("--target=${LIBCXX_TARGET_TRIPLE}")
-endif()
-if(LIBCXX_SYSROOT)
- add_target_flags_if_supported("--sysroot=${LIBCXX_SYSROOT}")
-endif()
-if(LIBCXX_GCC_TOOLCHAIN)
- add_target_flags_if_supported("--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
-endif()
# Configure compiler.
include(config-ix)
diff --git a/docs/BuildingLibcxx.rst b/docs/BuildingLibcxx.rst
index 0e536cc..aa26a22 100644
--- a/docs/BuildingLibcxx.rst
+++ b/docs/BuildingLibcxx.rst
@@ -136,7 +136,7 @@
If you are running in an MSYS2 shell and you have installed the
MSYS2-provided clang package (which defaults to a non-MSVC target), you
-should add e.g. ``-DLIBCXX_TARGET_TRIPLE=x86_64-windows-msvc`` (replacing
+should add e.g. ``-DCMAKE_CXX_COMPILER_TARGET=x86_64-windows-msvc`` (replacing
``x86_64`` with the architecture you're targeting) to the ``cmake`` command
line above. This will instruct ``check-cxx`` to use the right target triple
when invoking ``clang++``.
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 4228067..eb85502 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -79,3 +79,8 @@
- Support for standalone builds have been entirely removed from libc++, libc++abi and
libunwind. Please use :ref:`these instructions <build instructions>` for building
libc++, libc++abi and/or libunwind.
+
+- The ``{LIBCXX,LIBCXXABI,LIBUNWIND}_TARGET_TRIPLE``, ``{LIBCXX,LIBCXXABI,LIBUNWIND}_SYSROOT`` and
+ ``{LIBCXX,LIBCXXABI,LIBUNWIND}_GCC_TOOLCHAIN`` CMake variables have been removed. Instead, please
+ use the ``CMAKE_CXX_COMPILER_TARGET``, ``CMAKE_SYSROOT`` and ``CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN``
+ variables provided by CMake.
diff --git a/lib/abi/CMakeLists.txt b/lib/abi/CMakeLists.txt
index 421600a..a2d41e1 100644
--- a/lib/abi/CMakeLists.txt
+++ b/lib/abi/CMakeLists.txt
@@ -50,8 +50,13 @@
set(${result} "${tmp}" PARENT_SCOPE)
endfunction()
+if (CMAKE_CXX_COMPILER_TARGET)
+ set(triple "${CMAKE_CXX_COMPILER_TARGET}")
+else()
+ set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
+endif()
cxx_abi_list_identifier(abi_list_identifier
- "${LIBCXX_TARGET_TRIPLE}"
+ "${triple}"
"${LIBCXX_CXX_ABI_LIBNAME}"
"${LIBCXX_ABI_VERSION}"
"${LIBCXX_ABI_UNSTABLE}"
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1375bf4..1c9445b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -104,8 +104,10 @@
serialize_lit_param(enable_debug_tests False)
endif()
-if (LIBCXX_TARGET_TRIPLE)
- serialize_lit_param(target_triple "\"${LIBCXX_TARGET_TRIPLE}\"")
+if (CMAKE_CXX_COMPILER_TARGET)
+ serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
+else()
+ serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
endif()
if (LLVM_USE_SANITIZER)
diff --git a/test/configs/legacy.cfg.in b/test/configs/legacy.cfg.in
index a131978..cf36837 100644
--- a/test/configs/legacy.cfg.in
+++ b/test/configs/legacy.cfg.in
@@ -17,8 +17,8 @@
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.configuration_variant = "@LIBCXX_LIT_VARIANT@"
config.host_triple = "@LLVM_HOST_TRIPLE@"
-config.sysroot = "@LIBCXX_SYSROOT@"
-config.gcc_toolchain = "@LIBCXX_GCC_TOOLCHAIN@"
+config.sysroot = "@CMAKE_SYSROOT@"
+config.gcc_toolchain = "@CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN@"
config.generate_coverage = @LIBCXX_GENERATE_COVERAGE@
config.target_info = "@LIBCXX_TARGET_INFO@"
config.test_linker_flags = "@LIBCXX_TEST_LINKER_FLAGS@"