[libcxx-commits] [libcxx] [libcxxabi] [libc++] tests with picolibc: enable exceptions (PR #75462)

Dominik Wójt via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 14 06:16:08 PST 2023


https://github.com/domin144 updated https://github.com/llvm/llvm-project/pull/75462

>From 4d87bac49291c19cc8cf871ac12f7dd252a624a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <dominik.wojt at arm.com>
Date: Fri, 1 Dec 2023 14:31:28 +0100
Subject: [PATCH 1/2] [libc++] tests with picolibc: enable exceptions

---
 libcxx/cmake/caches/Armv7M-picolibc.cmake         | 7 ++++---
 libcxxabi/test/catch_multi_level_pointer.pass.cpp | 4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libcxx/cmake/caches/Armv7M-picolibc.cmake b/libcxx/cmake/caches/Armv7M-picolibc.cmake
index 9f8863943444b6..91cc32fd376e30 100644
--- a/libcxx/cmake/caches/Armv7M-picolibc.cmake
+++ b/libcxx/cmake/caches/Armv7M-picolibc.cmake
@@ -13,17 +13,18 @@ set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
 set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
 set(LIBCXXABI_BAREMETAL ON CACHE BOOL "")
 set(LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_EXCEPTIONS ON CACHE BOOL "")
 set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
 set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_EXCEPTIONS ON CACHE BOOL "")
 set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE STRING "")
 set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
-set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_RTTI ON CACHE BOOL "")
 set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
 set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
diff --git a/libcxxabi/test/catch_multi_level_pointer.pass.cpp b/libcxxabi/test/catch_multi_level_pointer.pass.cpp
index 00ea66da301763..5f0e78a391b14c 100644
--- a/libcxxabi/test/catch_multi_level_pointer.pass.cpp
+++ b/libcxxabi/test/catch_multi_level_pointer.pass.cpp
@@ -11,6 +11,10 @@
 // 1b00fc5d8133 made it in the dylib in macOS 10.11
 // XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10}}
 
+// mps2-an385 machine used for testing of picolibc has just 4 MB of "flash"
+// memory and this test requires almost 5 MB
+// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
+
 #include <cassert>
 #include <cstdio>
 #include <cstdlib>

>From fbf611cb7c21a3dbcbb5031e9668e34aeb41a092 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <dominik.wojt at arm.com>
Date: Thu, 14 Dec 2023 14:29:50 +0100
Subject: [PATCH 2/2] add separate no-exceptions configuration

---
 .../Armv7M-picolibc-no-exceptions.cmake       | 41 ++++++++++
 libcxx/utils/ci/run-buildbot                  | 75 +++++++++++--------
 2 files changed, 83 insertions(+), 33 deletions(-)
 create mode 100644 libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake

diff --git a/libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake b/libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake
new file mode 100644
index 00000000000000..9f8863943444b6
--- /dev/null
+++ b/libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake
@@ -0,0 +1,41 @@
+set(CMAKE_ASM_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
+set(CMAKE_CXX_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
+set(CMAKE_CXX_FLAGS "-mfloat-abi=soft" CACHE STRING "")
+set(CMAKE_C_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
+set(CMAKE_C_FLAGS "-mfloat-abi=soft" CACHE STRING "")
+set(CMAKE_SYSTEM_NAME Generic CACHE STRING "")
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
+set(COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+set(LIBCXXABI_BAREMETAL ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE STRING "")
+set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
+set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
+set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
+# Long tests are prohibitively slow when run via emulation.
+set(LIBCXX_TEST_PARAMS "long_tests=False" CACHE STRING "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "")
+set(LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "")
+set(LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
+set(LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+find_program(QEMU_SYSTEM_ARM qemu-system-arm)
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index ee890fb7669962..c180e36147e0f7 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -203,6 +203,42 @@ function check-cxx-benchmarks() {
     ${NINJA} -vC "${BUILD_DIR}" check-cxx-benchmarks
 }
 
+function test-armv7m-picolibc() {
+    clean
+
+    # To make it easier to get this builder up and running, build picolibc
+    # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.
+    # This could be optimised by building picolibc into the Docker container.
+    ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \
+        --build-dir "${BUILD_DIR}" \
+        --install-dir "${INSTALL_DIR}" \
+        --target armv7m-none-eabi
+
+    echo "--- Generating CMake"
+    flags="--sysroot=${INSTALL_DIR}"
+    ${CMAKE} \
+        -S "${MONOREPO_ROOT}/compiler-rt" \
+        -B "${BUILD_DIR}/compiler-rt" \
+        -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
+        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+        -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
+        -C "${CMAKE_CONFIG}" \
+        -DCMAKE_C_FLAGS="${flags}" \
+        -DCMAKE_CXX_FLAGS="${flags}" \
+        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
+    generate-cmake -C "${CMAKE_CONFIG}" \
+        -DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \
+        -DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \
+        -DLIBUNWIND_TEST_CONFIG="armv7m-picolibc-libunwind.cfg.in" \
+        -DCMAKE_C_FLAGS="${flags}" \
+        -DCMAKE_CXX_FLAGS="${flags}"
+
+    ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
+    mv "${BUILD_DIR}/install/lib/armv7m-none-eabi"/* "${BUILD_DIR}/install/lib"
+
+    check-runtimes
+}
+
 # Print the version of a few tools to aid diagnostics in some cases
 ${CMAKE} --version
 ${NINJA} --version
@@ -616,39 +652,12 @@ armv7-no-exceptions)
     check-runtimes
 ;;
 armv7m-picolibc)
-    clean
-
-    # To make it easier to get this builder up and running, build picolibc
-    # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.
-    # This could be optimised by building picolibc into the Docker container.
-    ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \
-        --build-dir "${BUILD_DIR}" \
-        --install-dir "${INSTALL_DIR}" \
-        --target armv7m-none-eabi
-
-    echo "--- Generating CMake"
-    flags="--sysroot=${INSTALL_DIR}"
-    ${CMAKE} \
-        -S "${MONOREPO_ROOT}/compiler-rt" \
-        -B "${BUILD_DIR}/compiler-rt" \
-        -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
-        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-        -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-        -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
-        -DCMAKE_C_FLAGS="${flags}" \
-        -DCMAKE_CXX_FLAGS="${flags}" \
-        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
-    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
-        -DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \
-        -DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \
-        -DLIBUNWIND_TEST_CONFIG="armv7m-picolibc-libunwind.cfg.in" \
-        -DCMAKE_C_FLAGS="${flags}" \
-        -DCMAKE_CXX_FLAGS="${flags}"
-
-    ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-    mv "${BUILD_DIR}/install/lib/armv7m-none-eabi"/* "${BUILD_DIR}/install/lib"
-
-    check-runtimes
+    CMAKE_CONFIG="${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
+    test-armv7m-picolibc
+;;
+armv7m-picolibc-no-exceptions)
+    CMAKE_CONFIG="${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake"
+    test-armv7m-picolibc
 ;;
 clang-cl-dll)
     clean



More information about the libcxx-commits mailing list