diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index c77180172d2d1..6efd14cea0f79 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -5304,6 +5304,15 @@ West: labels: - "area: Audio" +"West project: libstdcxx": + status: maintained + maintainers: + - Keith Packard + files: + - modules/Kconfig.libstdc++ + labels: + - "area: C++" + "West project: littlefs": status: odd fixes files: diff --git a/lib/cpp/Kconfig b/lib/cpp/Kconfig index da309ee3fbcd9..9ab89e668556a 100644 --- a/lib/cpp/Kconfig +++ b/lib/cpp/Kconfig @@ -118,6 +118,25 @@ config GLIBCXX_LIBCPP Build with GNU C++ Standard Library (libstdc++) provided by the GNU Compiler Collection (GCC)-based toolchain. +choice GLIBCXX_LIBCPP_SOURCE + prompt "Source of libstdc++" + depends on GLIBCXX_LIBCPP + default GLIBCXX_LIBCPP_USE_TOOLCHAIN + +config GLIBCXX_LIBCPP_USE_MODULE + bool "libstdc++ from module" + depends on ZEPHYR_LIBSTDCXX_MODULE + help + Use libstdc++ module instead of libstdc++ included with toolchain. + +config GLIBCXX_LIBCPP_USE_TOOLCHAIN + bool "libstdc++ from toolchain" + depends on NEWLIB_LIBC || PICOLIBC_USE_TOOLCHAIN + help + Use libstdc++ included with toolchain. + +endchoice + config LIBCXX_LIBCPP bool "LLVM C++ Standard Library" depends on !NATIVE_APPLICATION diff --git a/lib/libc/Kconfig b/lib/libc/Kconfig index 5d981e4719b0b..88f45a9a17804 100644 --- a/lib/libc/Kconfig +++ b/lib/libc/Kconfig @@ -45,7 +45,7 @@ config NEWLIB_LIBC_SUPPORTED config PICOLIBC_SUPPORTED bool depends on !NATIVE_APPLICATION - depends on ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y") || (ZEPHYR_PICOLIBC_MODULE && !REQUIRES_FULL_LIBCPP) + depends on ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y") || ZEPHYR_PICOLIBC_MODULE default y select FULL_LIBC_SUPPORTED help diff --git a/lib/libc/picolibc/Kconfig b/lib/libc/picolibc/Kconfig index be30e6a8f3a60..f48a69f8aa567 100644 --- a/lib/libc/picolibc/Kconfig +++ b/lib/libc/picolibc/Kconfig @@ -5,13 +5,12 @@ if PICOLIBC choice PICOLIBC_SOURCE prompt "Source of Picolibc" - default PICOLIBC_USE_TOOLCHAIN if REQUIRES_FULL_LIBCPP || "$(TOOLCHAIN_HAS_PICOLIBC)" = "y" + default PICOLIBC_USE_TOOLCHAIN if "$(TOOLCHAIN_HAS_PICOLIBC)" = "y" default PICOLIBC_USE_MODULE config PICOLIBC_USE_MODULE bool "Picolibc from module" depends on ZEPHYR_PICOLIBC_MODULE - depends on !GLIBCXX_LIBCPP help Use picolibc module instead of picolibc included with toolchain. This is enabled by default for toolchains other than the Zephyr @@ -24,7 +23,6 @@ config PICOLIBC_USE_TOOLCHAIN select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE help Use picolibc included with the toolchain. - This is required when using a full C++ standard library (`REQUIRES_FULL_LIBCPP=y`). endchoice # PICOLIBC_SOURCE diff --git a/modules/Kconfig b/modules/Kconfig index 7d32d1ff818ef..e2b7f1da70510 100644 --- a/modules/Kconfig +++ b/modules/Kconfig @@ -49,6 +49,7 @@ source "modules/zcbor/Kconfig" source "modules/Kconfig.mcuboot" source "modules/Kconfig.intel" source "modules/hostap/Kconfig" +source "modules/Kconfig.libstdc++" comment "Unavailable modules, please install those via the project manifest." diff --git a/modules/Kconfig.libstdc++ b/modules/Kconfig.libstdc++ new file mode 100644 index 0000000000000..581b1691c754b --- /dev/null +++ b/modules/Kconfig.libstdc++ @@ -0,0 +1,5 @@ +# Copyright 2024 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +config ZEPHYR_LIBSTDCXX_MODULE + bool diff --git a/tests/lib/cpp/libcxx/testcase.yaml b/tests/lib/cpp/libcxx/testcase.yaml index 566a0d689d3c1..c4a33a724bbfe 100644 --- a/tests/lib/cpp/libcxx/testcase.yaml +++ b/tests/lib/cpp/libcxx/testcase.yaml @@ -11,6 +11,19 @@ tests: - CONFIG_CPP_EXCEPTIONS=y integration_platforms: - mps2/an385 + cpp.libcxx.glibcxx.newlib.module: + filter: TOOLCHAIN_HAS_NEWLIB == 1 + toolchain_exclude: xcc + min_flash: 54 + min_ram: 24 + tags: cpp + extra_configs: + - CONFIG_NEWLIB_LIBC=y + - CONFIG_GLIBCXX_LIBCPP=y + - CONFIG_GLIBCXX_LIBCPP_USE_MODULE=y + - CONFIG_CPP_EXCEPTIONS=y + integration_platforms: + - mps2/an385 cpp.libcxx.glibcxx.newlib_nano: filter: TOOLCHAIN_HAS_NEWLIB == 1 and CONFIG_HAS_NEWLIB_LIBC_NANO toolchain_exclude: xcc @@ -34,6 +47,18 @@ tests: - CONFIG_CPP_EXCEPTIONS=y integration_platforms: - mps2/an385 + cpp.libcxx.glibcxx.picolibc.module: + toolchain_exclude: xcc + platform_exclude: native_sim + tags: cpp + timeout: 60 + extra_configs: + - CONFIG_PICOLIBC=y + - CONFIG_GLIBCXX_LIBCPP=y + - CONFIG_GLIBCXX_LIBCPP_USE_MODULE=y + - CONFIG_CPP_EXCEPTIONS=n + integration_platforms: + - mps2/an385 cpp.libcxx.arcmwdtlib: toolchain_allow: arcmwdt min_flash: 54 diff --git a/west.yml b/west.yml index 1489b3a57f6d6..f7ae609beb45f 100644 --- a/west.yml +++ b/west.yml @@ -23,6 +23,8 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: babblesim url-base: https://github.com/BabbleSim + - name: keithp + url-base: https://github.com/keith-packard group-filter: [-babblesim, -optional] @@ -293,6 +295,11 @@ manifest: path: modules/hal/libmetal groups: - hal + - name: libstdcxx + remote: keithp + repo-path: libstdcxx-module + revision: 9ac70a1eec3bec2bc158eb4b384cdc97631cdd77 + path: modules/lib/libstdcxx - name: littlefs path: modules/fs/littlefs groups: