[libc++][tests] Use CMake provided paths for includes and libdir instead of hardcoding them

In the new-style testing configurations, we were hardcoding paths to the
`include` and `lib` directories, which was incorrect but always went
unnoticed because the hardcoded values always happened to match the
actual value.

When using new-style configs with the bootstrapping build, this falls
appart -- and we never noticed this because the bootstrapping build was
still using old style configs.

This patch removes the %{install} substitution, which makes it too
tempting to hardcode installation paths, and it also switches the
bootstrapping build to actually using new-style configs like we
always intended to do.

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

GitOrigin-RevId: 78669c4185e4f8784308b5e740721cd374052cae
diff --git a/test/configs/apple-libc++abi-backdeployment.cfg.in b/test/configs/apple-libc++abi-backdeployment.cfg.in
index 06dd503..5839b82 100644
--- a/test/configs/apple-libc++abi-backdeployment.cfg.in
+++ b/test/configs/apple-libc++abi-backdeployment.cfg.in
@@ -45,11 +45,11 @@
     '-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
 ))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{install}/include/c++/v1 -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
+    '-nostdinc++ -I %{include} -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
     '-I %{libcxx}/test/support -I %{libcxx}/src'
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib++ -L %{install}/lib -lc++ -lc++abi'
+    '-nostdlib++ -L %{lib} -lc++ -lc++abi'
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %T --env DYLD_LIBRARY_PATH="%{cxx-runtime-root}:%{abi-runtime-root}:%{unwind-runtime-root}" -- '
diff --git a/test/configs/apple-libc++abi-shared.cfg.in b/test/configs/apple-libc++abi-shared.cfg.in
index cf65ce4..17428b9 100644
--- a/test/configs/apple-libc++abi-shared.cfg.in
+++ b/test/configs/apple-libc++abi-shared.cfg.in
@@ -6,14 +6,14 @@
     '-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
 ))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{install}/include/c++/v1 -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
+    '-nostdinc++ -I %{include} -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
     '-I %{libcxx}/test/support -I %{libcxx}/src'
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib++ -L %{install}/lib -lc++ -lc++abi'
+    '-nostdlib++ -L %{lib} -lc++ -lc++abi'
 ))
 config.substitutions.append(('%{exec}',
-    '%{executor} --execdir %T --env DYLD_LIBRARY_PATH=%{install}/lib -- '
+    '%{executor} --execdir %T --env DYLD_LIBRARY_PATH=%{lib} -- '
 ))
 
 import os, site
diff --git a/test/configs/cmake-bridge.cfg.in b/test/configs/cmake-bridge.cfg.in
index f7ede5f..eb3caf0 100644
--- a/test/configs/cmake-bridge.cfg.in
+++ b/test/configs/cmake-bridge.cfg.in
@@ -28,5 +28,7 @@
 
 config.substitutions.append(('%{cxx}', '@CMAKE_CXX_COMPILER@'))
 config.substitutions.append(('%{libcxx}', '@LIBCXXABI_LIBCXX_PATH@'))
-config.substitutions.append(('%{install}', '@CMAKE_BINARY_DIR@'))
+config.substitutions.append(('%{include}', '@LIBCXXABI_HEADER_DIR@/include/c++/v1'))
+config.substitutions.append(('%{target-include}', '@LIBCXXABI_HEADER_DIR@/%{triple}/include/c++/v1'))
+config.substitutions.append(('%{lib}', '@LIBCXXABI_LIBRARY_DIR@'))
 config.substitutions.append(('%{executor}', '@LIBCXXABI_EXECUTOR@'))
diff --git a/test/configs/ibm-libc++abi-shared.cfg.in b/test/configs/ibm-libc++abi-shared.cfg.in
index 64fc4f2..439d250 100644
--- a/test/configs/ibm-libc++abi-shared.cfg.in
+++ b/test/configs/ibm-libc++abi-shared.cfg.in
@@ -4,16 +4,16 @@
 
 config.substitutions.append(('%{flags}',''))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -I %{install}/include/c++/v1 ' +
+    '-nostdinc++ -I %{include} ' +
     '-D__LIBC_NO_CPP_MATH_OVERLOADS__ -DLIBCXXABI_NO_TIMER ' +
     '-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
     '-I %{libcxx}/test/support -I %{libcxx}/src'
 ))
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib++ -L %{install}/lib -lc++ -lc++abi -Wl,-bbigtoc'
+    '-nostdlib++ -L %{lib} -lc++ -lc++abi -Wl,-bbigtoc'
 ))
 config.substitutions.append(('%{exec}',
-    '%{executor} --execdir %T --env LIBPATH=%{install}/lib -- '
+    '%{executor} --execdir %T --env LIBPATH=%{lib} -- '
 ))
 
 import os, site
diff --git a/test/vendor/apple/system-install-properties.sh.cpp b/test/vendor/apple/system-install-properties.sh.cpp
index 791fc67..d4df7b3 100644
--- a/test/vendor/apple/system-install-properties.sh.cpp
+++ b/test/vendor/apple/system-install-properties.sh.cpp
@@ -10,24 +10,22 @@
 
 // This file checks various properties of the installation of libc++abi when built
 // as a system library on Apple platforms.
-//
-// TODO: We should install to `<prefix>/usr` in CMake and check that path instead.
 
 // Make sure we install the libc++abi headers in the right location.
 // TODO: We don't currently install them, but we should.
 //
-// XRUNX: stat "%{install}/include/cxxabi.h"
+// XRUNX: stat "%{include}/cxxabi.h"
 
 // Make sure we install libc++abi.dylib in the right location.
 //
-// RUN: stat "%{install}/lib/libc++abi.dylib"
+// RUN: stat "%{lib}/libc++abi.dylib"
 
 // Make sure we don't install a symlink from libc++abi.dylib to libc++abi.1.dylib,
 // unlike what we do for libc++.dylib.
 // TODO: We currently don't do that correctly in the CMake build.
 //
-// XRUNX: ! readlink "%{install}/lib/libc++abi.dylib"
-// XRUNX: ! stat "%{install}/lib/libc++abi.1.dylib"
+// XRUNX: ! readlink "%{lib}/libc++abi.dylib"
+// XRUNX: ! stat "%{lib}/libc++abi.1.dylib"
 
 // Make sure the install_name is /usr/lib.
 //
@@ -38,11 +36,11 @@
 //
 // TODO: We currently don't do that correctly in the CMake build.
 //
-// XRUNX: otool -L "%{install}/lib/libc++abi.dylib" | grep '/usr/lib/libc++abi.dylib'
-// XRUNX: ! otool -l "%{install}/lib/libc++abi.dylib" | grep -E "LC_RPATH|@loader_path|@rpath"
+// XRUNX: otool -L "%{lib}/libc++abi.dylib" | grep '/usr/lib/libc++abi.dylib'
+// XRUNX: ! otool -l "%{lib}/libc++abi.dylib" | grep -E "LC_RPATH|@loader_path|@rpath"
 
 // Make sure the compatibility_version of libc++abi is 1.0.0. Failure to respect this can result
 // in applications not being able to find libc++abi when they are loaded by dyld, if the
 // compatibility version was bumped.
 //
-// RUN: otool -L "%{install}/lib/libc++abi.dylib" | grep "libc++abi.1.dylib" | grep "compatibility version 1.0.0"
+// RUN: otool -L "%{lib}/libc++abi.dylib" | grep "libc++abi.1.dylib" | grep "compatibility version 1.0.0"