[libcxx-commits] [libcxx] d1e0f02 - [libc++abi][ci] Add a from-scratch config for libc++abi on Apple/system

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 13 05:07:54 PDT 2021


Author: Louis Dionne
Date: 2021-10-13T08:07:40-04:00
New Revision: d1e0f02e0ba98cd371749c8d70ee9d153c559e91

URL: https://github.com/llvm/llvm-project/commit/d1e0f02e0ba98cd371749c8d70ee9d153c559e91
DIFF: https://github.com/llvm/llvm-project/commit/d1e0f02e0ba98cd371749c8d70ee9d153c559e91.diff

LOG: [libc++abi][ci] Add a from-scratch config for libc++abi on Apple/system

I came across an issue where since we build the library for Apple with
the install name directory being /usr/lib, which means that if we don't
run the tests with DYLD_LIBRARY_PATH, we'll end up loading the
system-provided libc++abi when running the tests. That wreaks havoc.

Instead of fixing it in the legacy config file, this commit introduces
an Apple libc++abi config file that does the right thing.

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

Added: 
    libcxxabi/test/configs/apple-libc++abi-shared.cfg.in
    libcxxabi/test/configs/cmake-bridge.cfg.in

Modified: 
    libcxx/utils/ci/apple-install-libcxx.sh
    libcxx/utils/ci/run-buildbot
    libcxxabi/CMakeLists.txt
    libcxxabi/test/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/ci/apple-install-libcxx.sh b/libcxx/utils/ci/apple-install-libcxx.sh
index aa5457718687a..54d08b3dee923 100755
--- a/libcxx/utils/ci/apple-install-libcxx.sh
+++ b/libcxx/utils/ci/apple-install-libcxx.sh
@@ -122,7 +122,8 @@ for arch in ${architectures}; do
             -DCMAKE_OSX_ARCHITECTURES="${arch}" \
             -DLIBCXXABI_LIBRARY_VERSION="${version}" \
             -DLIBCXX_INCLUDE_BENCHMARKS=OFF \
-            -DLIBCXX_TEST_CONFIG="apple-libc++-shared.cfg.in"
+            -DLIBCXX_TEST_CONFIG="apple-libc++-shared.cfg.in" \
+            -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-shared.cfg.in"
     )
 
     xcrun --sdk "${sdk}" cmake --build "${build_dir}/${arch}" --target install-cxx install-cxxabi -- -v

diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 1a90a52b7e1c3..0976145b93398 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -373,7 +373,8 @@ generic-no-wide-characters)
 x86_64-apple-system)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
-                   -DLIBCXX_TEST_CONFIG="apple-libc++-shared.cfg.in"
+                   -DLIBCXX_TEST_CONFIG="apple-libc++-shared.cfg.in" \
+                   -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-shared.cfg.in"
     check-runtimes
 ;;
 x86_64-apple-system-backdeployment-*)

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 366dcc9fbaf85..ea6ac11a53a4d 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -178,9 +178,9 @@ option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
 
 set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING
   "The path to the Lit testing configuration to use when running the tests.
-   If a relative path is provided, it is assumed to be relative to '<monorepo>/libcxx/test/configs'.")
+   If a relative path is provided, it is assumed to be relative to '<monorepo>/libcxxabi/test/configs'.")
 if (NOT IS_ABSOLUTE "${LIBCXXABI_TEST_CONFIG}")
-  set(LIBCXXABI_TEST_CONFIG "${LIBCXXABI_LIBCXX_PATH}/test/configs/${LIBCXXABI_TEST_CONFIG}")
+  set(LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXXABI_TEST_CONFIG}")
 endif()
 set(LIBCXXABI_TEST_PARAMS "" CACHE STRING
     "A list of parameters to run the Lit test suite with.")

diff  --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index a8a97aecba47a..ea4d5c4e02856 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -100,6 +100,10 @@ foreach(param IN LISTS LIBCXXABI_TEST_PARAMS)
   serialize_lit_param("${name}" "\"${value}\"")
 endforeach()
 
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
+               "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
+               @ONLY)
+
 configure_lit_site_cfg(
   "${LIBCXXABI_TEST_CONFIG}"
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg

diff  --git a/libcxxabi/test/configs/apple-libc++abi-shared.cfg.in b/libcxxabi/test/configs/apple-libc++abi-shared.cfg.in
new file mode 100644
index 0000000000000..4165d7a9c2493
--- /dev/null
+++ b/libcxxabi/test/configs/apple-libc++abi-shared.cfg.in
@@ -0,0 +1,29 @@
+# Testing configuration for Apple's system libc++abi.
+
+import sys
+
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
+
+config.substitutions.append(('%{flags}',
+    '-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
+))
+config.substitutions.append(('%{compile_flags}',
+    '-nostdinc++ -isystem %{install}/include/c++/v1 -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'
+))
+config.substitutions.append(('%{exec}',
+    '{} %{{libcxx}}/utils/run.py --execdir %T --env DYLD_LIBRARY_PATH=%{{install}}/lib -- '.format(sys.executable)
+))
+
+import os, site
+site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
+import libcxx.test.params, libcxx.test.newconfig, libcxx.test.newconfig
+libcxx.test.newconfig.configure(
+    libcxx.test.params.DEFAULT_PARAMETERS,
+    libcxx.test.features.DEFAULT_FEATURES,
+    config,
+    lit_config
+)

diff  --git a/libcxxabi/test/configs/cmake-bridge.cfg.in b/libcxxabi/test/configs/cmake-bridge.cfg.in
new file mode 100644
index 0000000000000..469872c7060be
--- /dev/null
+++ b/libcxxabi/test/configs/cmake-bridge.cfg.in
@@ -0,0 +1,31 @@
+ at AUTO_GEN_COMMENT@
+
+ at SERIALIZED_LIT_PARAMS@
+
+#
+# This file performs the bridge between the CMake configuration and the Lit
+# configuration files by setting up the LitConfig object and various Lit
+# substitutions from CMake variables.
+#
+# Individual configuration files can take advantage of this bridge by
+# loading the file and then setting up the remaining Lit substitutions.
+#
+
+import os, site
+site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
+site.addsitedir(os.path.join('@LIBCXXABI_SOURCE_DIR@', 'test'))
+import libcxx.test.format
+
+# Basic configuration of the test suite
+config.name = os.path.basename('@LIBCXXABI_TEST_CONFIG@')
+config.test_source_root = os.path.join('@LIBCXXABI_SOURCE_DIR@', 'test')
+config.test_format = libcxx.test.format.CxxStandardLibraryTest()
+config.recursiveExpansionLimit = 10
+config.test_exec_root = '@CMAKE_BINARY_DIR@'
+
+# TODO: This is a non-standard Lit attribute and we should have another way of accessing this.
+config.host_triple = '@LLVM_HOST_TRIPLE@'
+
+config.substitutions.append(('%{cxx}', '@CMAKE_CXX_COMPILER@'))
+config.substitutions.append(('%{libcxx}', '@LIBCXXABI_LIBCXX_PATH@'))
+config.substitutions.append(('%{install}', '@CMAKE_BINARY_DIR@'))


        


More information about the libcxx-commits mailing list