[libcxx-commits] [libcxx] 0e8208e - [libc++] Run the Lit test suite against an installed version of the library (#96910)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 28 06:23:03 PDT 2024
Author: Louis Dionne
Date: 2024-08-28T09:23:00-04:00
New Revision: 0e8208eca1c316b7302de7803ab0d85a1dd77076
URL: https://github.com/llvm/llvm-project/commit/0e8208eca1c316b7302de7803ab0d85a1dd77076
DIFF: https://github.com/llvm/llvm-project/commit/0e8208eca1c316b7302de7803ab0d85a1dd77076.diff
LOG: [libc++] Run the Lit test suite against an installed version of the library (#96910)
We always strive to test libc++ as close as possible to the way we are
actually shipping it. This was approximated reasonably well by setting
up the minimal driver flags when running the test suite, however we were
running the test suite against the library located in the build
directory.
This patch improves the situation by installing the library (the
headers, the built library, modules, etc) into a fake location and then
running the test suite against that fake "installation root".
This should open the door to getting rid of the temporary copy of the
headers we make during the build process, however this is left for a
future improvement.
Note that this adds quite a bit of verbosity whenever running the test
suite because we install the headers beforehand every time. We should be
able to override this to silence it, however CMake doesn't currently
give us a way to do that, see https://gitlab.kitware.com/cmake/cmake/-/issues/26085.
Added:
libcxx/test/configs/llvm-libc++-shared-mingw.cfg.in
libcxx/test/configs/llvm-libc++-static-mingw.cfg.in
Modified:
libcxx/CMakeLists.txt
libcxx/cmake/caches/Apple.cmake
libcxx/modules/CMakeLists.txt
libcxx/src/CMakeLists.txt
libcxx/test/CMakeLists.txt
libcxx/test/configs/cmake-bridge.cfg.in
libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp
libcxx/utils/ci/apple-install-libcxx.sh
libcxx/utils/ci/run-buildbot
Removed:
libcxx/test/configs/llvm-libc++-mingw.cfg.in
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 75c926f5432aea..f1942e963ccc31 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -131,7 +131,11 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in")
elseif(MINGW)
- set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-mingw.cfg.in")
+ if (LIBCXX_ENABLE_SHARED)
+ set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-mingw.cfg.in")
+ else()
+ set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static-mingw.cfg.in")
+ endif()
elseif(WIN32) # clang-cl
if (LIBCXX_ENABLE_SHARED)
set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-clangcl.cfg.in")
diff --git a/libcxx/cmake/caches/Apple.cmake b/libcxx/cmake/caches/Apple.cmake
index 8768653e620add..7dbe90fb351a9e 100644
--- a/libcxx/cmake/caches/Apple.cmake
+++ b/libcxx/cmake/caches/Apple.cmake
@@ -1,4 +1,5 @@
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "")
+set(CMAKE_INSTALL_NAME_DIR "/usr/lib" CACHE STRING "")
set(CMAKE_POSITION_INDEPENDENT_CODE OFF CACHE BOOL "")
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 82cd7b66beb7a9..d47d19a4755317 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -202,7 +202,6 @@ add_custom_target(generate-cxx-modules
ALL DEPENDS
${_all_modules}
)
-add_dependencies(cxx-test-depends generate-cxx-modules)
# Configure the modules manifest.
# Use the relative path between the installation and the module in the json
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index fe9d2666fa4caa..48c5111a0acbf6 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -309,7 +309,6 @@ endif()
# Add a meta-target for both libraries.
add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
-add_dependencies(cxx-test-depends cxx)
set(LIBCXX_EXPERIMENTAL_SOURCES
experimental/keep.cpp
@@ -357,7 +356,6 @@ set_target_properties(cxx_experimental
)
cxx_add_common_build_flags(cxx_experimental)
target_compile_options(cxx_experimental PUBLIC -D_LIBCPP_ENABLE_EXPERIMENTAL)
-add_dependencies(cxx-test-depends cxx_experimental)
if (LIBCXX_INSTALL_SHARED_LIBRARY)
install(TARGETS cxx_shared
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index b25712b0e363b3..aa49979affedfa 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -5,6 +5,62 @@ if (LIBCXX_INCLUDE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
+# Install the library at a fake location so we can run the test suite against it.
+# This ensures that we run the test suite against a setup that matches what we ship
+# in production as closely as possible (in terms of file paths, rpaths, etc).
+set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
+if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
+ add_custom_target(install-cxxabi-test-suite-prefix
+ DEPENDS cxxabi-headers
+ cxxabi
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxxabi-headers
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxxabi
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ add_dependencies(cxx-test-depends install-cxxabi-test-suite-prefix)
+endif()
+
+if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
+ add_custom_target(install-unwind-test-suite-prefix
+ DEPENDS unwind-headers
+ unwind
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=unwind-headers
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=unwind
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ add_dependencies(cxx-test-depends install-unwind-test-suite-prefix)
+endif()
+
+add_custom_target(install-cxx-test-suite-prefix
+ DEPENDS cxx-headers
+ cxx
+ cxx_experimental
+ cxx-modules
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx-headers
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx-modules
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx
+ -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
+ -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
+add_dependencies(cxx-test-depends install-cxx-test-suite-prefix)
+
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in
index 78d0cb5a257488..bc9bb0e03911d4 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -24,8 +24,9 @@ config.test_exec_root = os.path.join('@CMAKE_BINARY_DIR@', 'test')
# Add substitutions for bootstrapping the test suite configuration
config.substitutions.append(('%{libcxx-dir}', '@LIBCXX_SOURCE_DIR@'))
-config.substitutions.append(('%{include-dir}', '@LIBCXX_GENERATED_INCLUDE_DIR@'))
-config.substitutions.append(('%{target-include-dir}', '@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@'))
-config.substitutions.append(('%{lib-dir}', '@LIBCXX_LIBRARY_DIR@'))
-config.substitutions.append(('%{module-dir}', '@LIBCXX_GENERATED_MODULE_DIR@'))
+config.substitutions.append(('%{install-prefix}', '@LIBCXX_TESTING_INSTALL_PREFIX@'))
+config.substitutions.append(('%{include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_DIR@'))
+config.substitutions.append(('%{target-include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_TARGET_DIR@'))
+config.substitutions.append(('%{lib-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_LIBRARY_DIR@'))
+config.substitutions.append(('%{module-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_MODULES_DIR@'))
config.substitutions.append(('%{test-tools-dir}', '@LIBCXX_TEST_TOOLS_PATH@'))
diff --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
index cffe895f653e33..5fa99bc697d622 100644
--- a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
@@ -25,7 +25,7 @@ config.substitutions.append(('%{link_flags}',
'-nostdlib -L %{lib-dir} -lc++ -l' + cxx_lib
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T --prepend_env PATH=%{lib-dir} -- '
+ '%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- '
))
import os, site
diff --git a/libcxx/test/configs/llvm-libc++-shared-mingw.cfg.in b/libcxx/test/configs/llvm-libc++-shared-mingw.cfg.in
new file mode 100644
index 00000000000000..01c4d58ca05f96
--- /dev/null
+++ b/libcxx/test/configs/llvm-libc++-shared-mingw.cfg.in
@@ -0,0 +1,25 @@
+# This testing configuration handles running the test suite against LLVM's libc++
+# using either a DLL or a static library, with MinGW/Clang on Windows.
+
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
+
+config.substitutions.append(('%{flags}', ''))
+config.substitutions.append(('%{compile_flags}',
+ '-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I %{libcxx-dir}/test/support'
+))
+config.substitutions.append(('%{link_flags}',
+ '-nostdlib++ -L %{lib-dir} -lc++'
+))
+config.substitutions.append(('%{exec}',
+ '%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- '
+))
+
+import os, site
+site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
+import libcxx.test.params, libcxx.test.config
+libcxx.test.config.configure(
+ libcxx.test.params.DEFAULT_PARAMETERS,
+ libcxx.test.features.DEFAULT_FEATURES,
+ config,
+ lit_config
+)
diff --git a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
index 80c7c0ee669ae2..e95999d52653d9 100644
--- a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
@@ -26,7 +26,7 @@ config.substitutions.append(('%{link_flags}',
'-nostdlib -L %{lib-dir} -lc++ -l' + cxx_lib
))
config.substitutions.append(('%{exec}',
- '%{executor} --execdir %T --prepend_env PATH=%{lib-dir} -- '
+ '%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- '
))
import os, site
diff --git a/libcxx/test/configs/llvm-libc++-mingw.cfg.in b/libcxx/test/configs/llvm-libc++-static-mingw.cfg.in
similarity index 100%
rename from libcxx/test/configs/llvm-libc++-mingw.cfg.in
rename to libcxx/test/configs/llvm-libc++-static-mingw.cfg.in
diff --git a/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp b/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp
index 4ea27401e35d4d..eeae4fc0a3c003 100644
--- a/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp
+++ b/libcxx/test/libcxx/vendor/apple/system-install-properties.sh.cpp
@@ -32,10 +32,8 @@
// various tools like dyld and ld64 will treat us specially if they recognize us as being a
// system library.
//
-// TODO: We currently don't do that correctly in the CMake build.
-//
-// XRUNX: otool -L "%{lib-dir}/libc++.1.dylib" | grep '/usr/lib/libc++.1.dylib'
-// XRUNX: ! otool -l "%{lib-dir}/libc++.1.dylib" | grep -E "LC_RPATH|@loader_path|@rpath"
+// RUN: otool -L "%{lib-dir}/libc++.1.dylib" | grep '/usr/lib/libc++.1.dylib'
+// RUN: otool -l "%{lib-dir}/libc++.1.dylib" | grep -vE "LC_RPATH|@loader_path|@rpath"
// Make sure the compatibility_version of libc++ is 1.0.0.
// Failure to respect this can result in applications not being able to find libc++
diff --git a/libcxx/utils/ci/apple-install-libcxx.sh b/libcxx/utils/ci/apple-install-libcxx.sh
index 4872253a266a86..1ef52b11b70bdc 100755
--- a/libcxx/utils/ci/apple-install-libcxx.sh
+++ b/libcxx/utils/ci/apple-install-libcxx.sh
@@ -129,7 +129,6 @@ for arch in ${architectures}; do
-C "${llvm_root}/libcxx/cmake/caches/Apple.cmake" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
-DCMAKE_INSTALL_PREFIX="${build_dir}/${arch}-install" \
- -DCMAKE_INSTALL_NAME_DIR="/usr/lib" \
-DCMAKE_OSX_ARCHITECTURES="${arch}" \
-DLIBCXXABI_LIBRARY_VERSION="${version}" \
-DLIBCXX_LIBRARY_VERSION="${version}" \
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 1c7085d90f0afc..102f1669e63b84 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -154,19 +154,6 @@ function check-runtimes() {
echo "+++ Running the libunwind tests"
${NINJA} -vC "${BUILD_DIR}" check-unwind
-
- # TODO: On macOS 13.5, the linker seems to have an issue where it will pick up
- # a library if it exists inside a -L search path, even if we don't link
- # against that library. This happens with libunwind.dylib if it is built
- # at the point when we run the libc++ tests, which causes issues cause we
- # are also linking against the system unwinder.
- #
- # I believe this is a linker regression and I reported it as rdar://115842730.
- # It should be possible to move this installation step back to the top once
- # that issue has been resolved, but in the meantime it doesn't really hurt to
- # have it here.
- echo "--- Installing libc++, libc++abi and libunwind to a fake location"
- ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi install-unwind
}
# TODO: The goal is to test this against all configurations. We should also move
More information about the libcxx-commits
mailing list