[runtimes] Simplify how we set the target triple

Instead of using TARGET_TRIPLE, which is always set to LLVM_DEFAULT_TARGET_TRIPLE,
use that variable directly to populate the various XXXX_TARGET_TRIPLE
variables in the runtimes.

This re-applies 77396bbc98 and 5099e01568, which were reverted in
850b57c5fbe because they broke the build.

Differential Revision: https://reviews.llvm.org/D106009

GitOrigin-RevId: 395271ad11b8c233db1a4e0e6a76aa52e93e5aec
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c21fc3..9fb3586 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,7 +111,7 @@
 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 "" CACHE STRING "Target triple for cross compiling.")
+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.")
 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
@@ -273,10 +273,6 @@
   set(LIBCXXABI_SYSROOT "${CMAKE_SYSROOT}")
 endif()
 
-if (LIBCXXABI_TARGET_TRIPLE)
-  set(TARGET_TRIPLE "${LIBCXXABI_TARGET_TRIPLE}")
-endif()
-
 # Configure compiler. Must happen after setting the target flags.
 include(config-ix)
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 526e852..a8a97ae 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -86,8 +86,8 @@
   serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
 endif()
 
-if (TARGET_TRIPLE)
-  serialize_lit_param(target_triple "\"${TARGET_TRIPLE}\"")
+if (LIBCXXABI_TARGET_TRIPLE)
+  serialize_lit_param(target_triple "\"${LIBCXXABI_TARGET_TRIPLE}\"")
 endif()
 
 if (LIBCXXABI_BUILD_32_BITS)