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

Dominik Wójt via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 18 00:02:39 PST 2023


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

>From 78fb69a9adc53c2ef6d81296051dd94b3f41d85f 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/3] [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 c9d5fc90d99f41c29092fa2b2cb2352217843fc7 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/3] 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

>From 0c883433f95bbc5525346c5e1bb49d5db42dceef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <dominik.wojt at arm.com>
Date: Mon, 18 Dec 2023 08:59:04 +0100
Subject: [PATCH 3/3] avoid separate cache for no-exceptions, update yaml
 config

---
 .../Armv7M-picolibc-no-exceptions.cmake       | 41 -------------------
 libcxx/utils/ci/buildkite-pipeline.yml        |  7 ++++
 libcxx/utils/ci/run-buildbot                  | 21 ++++++----
 3 files changed, 20 insertions(+), 49 deletions(-)
 delete 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
deleted file mode 100644
index 9f8863943444b6..00000000000000
--- a/libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake
+++ /dev/null
@@ -1,41 +0,0 @@
-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/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index c63f6a78b16070..a48f8524ef63c4 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -224,6 +224,13 @@ steps:
       arch: aarch64
     <<: *common
 
+  - label: Armv7-M picolibc -fno-exceptions
+    command: libcxx/utils/ci/run-buildbot armv7m-picolibc-no-exceptions
+    agents:
+      queue: libcxx-builders-linaro-arm
+      arch: aarch64
+    <<: *common
+
 - group: AIX
   steps:
   - label: AIX (32-bit)
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index c180e36147e0f7..672d5cb70ae816 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -222,16 +222,17 @@ function test-armv7m-picolibc() {
         -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}" \
+        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
+        "${@}"
+    generate-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}"
+        -DCMAKE_CXX_FLAGS="${flags}" \
+        "${@}"
 
     ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
     mv "${BUILD_DIR}/install/lib/armv7m-none-eabi"/* "${BUILD_DIR}/install/lib"
@@ -652,12 +653,16 @@ armv7-no-exceptions)
     check-runtimes
 ;;
 armv7m-picolibc)
-    CMAKE_CONFIG="${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
-    test-armv7m-picolibc
+    test-armv7m-picolibc \
+        -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
 ;;
 armv7m-picolibc-no-exceptions)
-    CMAKE_CONFIG="${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc-no-exceptions.cmake"
-    test-armv7m-picolibc
+    test-armv7m-picolibc \
+        -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
+        -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
+        -DLIBCXXABI_ENABLE_STATIC_UNWINDER=OFF \
+        -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
+        -DLIBCXX_ENABLE_RTTI=OFF
 ;;
 clang-cl-dll)
     clean



More information about the libcxx-commits mailing list