Skip to content

Build libstdc++ as a module #80762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions lib/cpp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/libc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/libc/picolibc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions modules/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
5 changes: 5 additions & 0 deletions modules/Kconfig.libstdc++
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 Google LLC
# SPDX-License-Identifier: Apache-2.0

config ZEPHYR_LIBSTDCXX_MODULE
bool
25 changes: 25 additions & 0 deletions tests/lib/cpp/libcxx/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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:
Expand Down
Loading