Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

This patch adds a CMake cache, and the testing configs to build libc++
and run the tests against LLVM libc.

Created using spr 1.3.7
@boomanaiden154 boomanaiden154 requested review from a team as code owners October 25, 2025 22:04
@llvmbot llvmbot added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc++abi libc++abi C++ Runtime Library. Not libc++. labels Oct 25, 2025
@boomanaiden154 boomanaiden154 marked this pull request as draft October 25, 2025 22:04
@llvmbot
Copy link
Member

llvmbot commented Oct 25, 2025

@llvm/pr-subscribers-libcxxabi

@llvm/pr-subscribers-libcxx

Author: Aiden Grossman (boomanaiden154)

Changes

This patch adds a CMake cache, and the testing configs to build libc++
and run the tests against LLVM libc.


Full diff: https://github.com/llvm/llvm-project/pull/165120.diff

3 Files Affected:

  • (added) libcxx/cmake/caches/Generic-llvm-libc.cmake (+65)
  • (added) libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in (+27)
  • (added) libcxxabi/test/configs/llvm-libc++abi-llvm-libc.cfg.in (+27)
diff --git a/libcxx/cmake/caches/Generic-llvm-libc.cmake b/libcxx/cmake/caches/Generic-llvm-libc.cmake
new file mode 100644
index 0000000000000..88440bb7966bd
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-llvm-libc.cmake
@@ -0,0 +1,65 @@
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY ON CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(COMPILER_RT_CXX_LIBRARY "libcxx" CACHE STRING "")
+
+set(COMPILER_RT_USE_LLVM_UNWINDER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_BUILTINS ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_CRT ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC OFF CACHE BOOL "")
+set(COMPILER_RT_HAS_FNO_BUILTIN_FLAG ON CACHE BOOL "")
+set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS ON CACHE BOOL "")
+set(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_MEMPROF OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_ORC OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_DEBUG OFF CACHE BOOL "")
+set(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY ON CACHE BOOL "")
+
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
+
+set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
+set(LIBCXX_INSTALL_LIBRARY ON CACHE BOOL "")
+set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
+
+# confirmed not available in libc
+set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
+
+# missing at least `<sys/statvfs.h>` and `utimes`
+set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+
+# missing at least `ioctl`
+set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
+
+# unclear what this is missing
+set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
+
+# requires LIBCXX_ENABLE_MONOTONIC_CLOCK=ON
+set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
+
+# these are fine
+set(LIBCXX_ENABLE_UNICODE ON CACHE BOOL "")
+set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
+set(RUNTIMES_USE_LIBC "llvm-libc" CACHE STRING "")
+
+set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libc;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+set(LLVM_LIBC_INCLUDE_SCUDO ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_GWP_ASAN OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC ON CACHE BOOL "")
+
+#set(CMAKE_SYSROOT "/home/gha/libc-sysroot" CACHE STRING "")
diff --git a/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in b/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
new file mode 100644
index 0000000000000..051d131ab78cd
--- /dev/null
+++ b/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
@@ -0,0 +1,27 @@
+# This testing configuration handles running the test suite against LLVM's libc++
+# using a static library.
+
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
+
+config.substitutions.append(('%{flags}',
+    '-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
+))
+config.substitutions.append(('%{compile_flags}',
+    '-nostdinc++ -I %{include-dir} -I %{target-include-dir} -I /home/gha/llvm-project/build-runtimes/libc/include -I %{libcxx-dir}/test/support'
+))
+config.substitutions.append(('%{link_flags}',
+    '-nodefaultlibs -nostartfiles -L %{lib-dir} -lc++ -lc++abi /home/gha/llvm-project/build-runtimes/libc/startup/linux/crt1.o /home/gha/llvm-project/build-runtimes/libc/lib/libc.a /home/gha/llvm-project/build-runtimes/libc/lib/libm.a -static -fno-use-cxa-atexit /home/gha/llvm-project/build-runtimes/compiler-rt/lib/linux/libclang_rt.builtins-x86_64.a'
+))
+config.substitutions.append(('%{exec}',
+    '%{executor} --execdir %{temp} -- '
+))
+
+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/libcxxabi/test/configs/llvm-libc++abi-llvm-libc.cfg.in b/libcxxabi/test/configs/llvm-libc++abi-llvm-libc.cfg.in
new file mode 100644
index 0000000000000..db261875b2270
--- /dev/null
+++ b/libcxxabi/test/configs/llvm-libc++abi-llvm-libc.cfg.in
@@ -0,0 +1,27 @@
+# This testing configuration handles running the test suite against LLVM's libc++abi
+# using a static library.
+
+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++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
+))
+config.substitutions.append(('%{link_flags}',
+    '-nodefaultlibs -nostartfiles -L %{lib} -lc++ -lc++abi -pthread /home/gha/llvm-project/build-runtimes/libc/startup/linux/crt1.o /home/gha/llvm-project/build-runtimes/libc/lib/libc.a -static -fno-use-cxa-atexit'
+))
+config.substitutions.append(('%{exec}',
+    '%{executor} --execdir %{temp} -- '
+))
+
+import os, site
+site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', '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
+)

@boomanaiden154
Copy link
Contributor Author

This still needs some work. Then there is still quite a bit of functionality needed in libc to get the tests passing for check-cxx (check-cxxabi already works). But once this is ready, I think landing it would probably make sense so there is a central configuration for people to hack on to get things working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++abi libc++abi C++ Runtime Library. Not libc++. libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants