[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 1960813..068074c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,16 +88,6 @@
 option(LIBUNWIND_REMEMBER_HEAP_ALLOC "Use heap instead of the stack for .cfi_remember_state." OFF)
 option(LIBUNWIND_INSTALL_HEADERS "Install the libunwind headers." OFF)
 
-if(NOT CMAKE_SYSROOT AND LIBUNWIND_SYSROOT)
-  message(WARNING "LIBUNWIND_SYSROOT is deprecated, please use CMAKE_SYSROOT instead")
-endif()
-if(NOT CMAKE_CXX_COMPILER_TARGET AND LIBUNWIND_TARGET_TRIPLE)
-  message(WARNING "LIBUNWIND_TARGET_TRIPLE is deprecated, please use CMAKE_CXX_COMPILER_TARGET instead")
-endif()
-if(NOT CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN AND LIBUNWIND_GCC_TOOLCHAIN)
-  message(WARNING "LIBUNWIND_GCC_TOOLCHAIN is deprecated, please use CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN instead")
-endif()
-
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
     "Define suffix of library directory name (32/64)")
 option(LIBUNWIND_INSTALL_LIBRARY "Install the libunwind library." ON)
@@ -107,19 +97,16 @@
 cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY
   "Install the shared libunwind library." ON
   "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF)
-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
     "Additional compiler flags for test programs.")
 
+# TODO: Remove this after branching for LLVM 15
+if(LIBUNWIND_SYSROOT OR LIBUNWIND_TARGET_TRIPLE OR LIBUNWIND_GCC_TOOLCHAIN)
+  message(WARNING "LIBUNWIND_SYSROOT, LIBUNWIND_TARGET_TRIPLE and LIBUNWIND_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead")
+endif()
+
 if (LIBUNWIND_ENABLE_SHARED)
   set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared.cfg.in")
 else()
@@ -200,16 +187,6 @@
 # tests here now.
 set(CMAKE_TRY_COMPILE_TARGET_TYPE_ORIG ${CMAKE_TRY_COMPILE_TARGET_TYPE})
 set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
-
-if(LIBUNWIND_TARGET_TRIPLE)
-  add_target_flags_if_supported("--target=${LIBUNWIND_TARGET_TRIPLE}")
-endif()
-if(LIBUNWIND_GCC_TOOLCHAIN)
-  add_target_flags_if_supported("--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}")
-endif()
-if(LIBUNWIND_SYSROOT)
-  add_target_flags_if_supported("--sysroot=${LIBUNWIND_SYSROOT}")
-endif()
 set(CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE_ORIG})
 
 # Configure compiler.
diff --git a/docs/BuildingLibunwind.rst b/docs/BuildingLibunwind.rst
index 99e5276..79166b4 100644
--- a/docs/BuildingLibunwind.rst
+++ b/docs/BuildingLibunwind.rst
@@ -142,18 +142,6 @@
 
   Build libunwind with threading support.
 
-.. option:: LIBUNWIND_TARGET_TRIPLE:STRING
-
-  Target triple for cross compiling
-
-.. option:: LIBUNWIND_GCC_TOOLCHAIN:PATH
-
-  GCC toolchain for cross compiling
-
-.. option:: LIBUNWIND_SYSROOT
-
-  Sysroot for cross compiling
-
 .. option:: LIBUNWIND_INSTALL_LIBRARY_DIR:PATH
 
   **Default**: ``lib${LIBUNWIND_LIBDIR_SUFFIX}``
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7e86d50..736b692 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -36,8 +36,10 @@
   serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
 endif()
 
-if (LIBUNWIND_TARGET_TRIPLE)
-  serialize_lit_param(target_triple "\"${LIBUNWIND_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()
 
 foreach(param IN LISTS LIBUNWIND_TEST_PARAMS)
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index 4fd633f..9fb3240 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -25,8 +25,8 @@
 config.enable_shared            = @LIBCXX_ENABLE_SHARED@
 config.arm_ehabi                = @LIBUNWIND_USES_ARM_EHABI@
 config.host_triple              = "@LLVM_HOST_TRIPLE@"
-config.sysroot                  = "@LIBUNWIND_SYSROOT@"
-config.gcc_toolchain            = "@LIBUNWIND_GCC_TOOLCHAIN@"
+config.sysroot                  = "@CMAKE_SYSROOT@"
+config.gcc_toolchain            = "@CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN@"
 config.cxx_ext_threads          = @LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@
 config.x86_cet                  = @LIBUNWIND_ENABLE_CET@