Skip to content

Commit 0ccbc74

Browse files
committed
lib/cpp: Add support for building libstdc++ as a module
Provide a mechanism to build libstdc++ as a module, instead of requiring that it be included in the toolchain. Signed-off-by: Keith Packard <[email protected]>
1 parent 6a0efa1 commit 0ccbc74

File tree

7 files changed

+42
-5
lines changed

7 files changed

+42
-5
lines changed

MAINTAINERS.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5190,6 +5190,15 @@ West:
51905190
labels:
51915191
- "area: Audio"
51925192

5193+
"West project: libstdcxx":
5194+
status: maintained
5195+
maintainers:
5196+
- Keith Packard
5197+
files:
5198+
- modules/Kconfig.libstdc++
5199+
labels:
5200+
- "area: C++"
5201+
51935202
"West project: littlefs":
51945203
status: odd fixes
51955204
files:

lib/cpp/Kconfig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,29 @@ config MINIMAL_LIBCPP
112112
config GLIBCXX_LIBCPP
113113
bool "GNU C++ Standard Library"
114114
depends on !NATIVE_APPLICATION
115-
depends on NEWLIB_LIBC || PICOLIBC
116115
select FULL_LIBCPP_SUPPORTED
117116
help
118117
Build with GNU C++ Standard Library (libstdc++) provided by the GNU
119118
Compiler Collection (GCC)-based toolchain.
120119

120+
choice GLIBCXX_LIBCPP_SOURCE
121+
prompt "Source of libstdc++"
122+
default GLIBCXX_LIBCPP_USE_TOOLCHAIN
123+
124+
config GLIBCXX_LIBCPP_USE_MODULE
125+
bool "libstdc++ from module"
126+
depends on ZEPHYR_LIBSTDCXX_MODULE
127+
help
128+
Use libstdc++ module instead of libstdc++ included with toolchain.
129+
130+
config GLIBCXX_LIBCPP_USE_TOOLCHAIN
131+
bool "libstdc++ from toolchain"
132+
depends on NEWLIB_LIBC || PICOLIBC_USE_TOOLCHAIN
133+
help
134+
Use libstdc++ included with toolchain.
135+
136+
endchoice
137+
121138
config LIBCXX_LIBCPP
122139
bool "LLVM C++ Standard Library"
123140
depends on !NATIVE_APPLICATION

lib/libc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ config NEWLIB_LIBC_SUPPORTED
4545
config PICOLIBC_SUPPORTED
4646
bool
4747
depends on !NATIVE_APPLICATION
48-
depends on ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y") || (ZEPHYR_PICOLIBC_MODULE && !REQUIRES_FULL_LIBCPP)
48+
depends on ("$(TOOLCHAIN_HAS_PICOLIBC)" = "y") || ZEPHYR_PICOLIBC_MODULE
4949
default y
5050
select FULL_LIBC_SUPPORTED
5151
help

lib/libc/picolibc/Kconfig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ if PICOLIBC
55

66
choice PICOLIBC_SOURCE
77
prompt "Source of Picolibc"
8-
default PICOLIBC_USE_TOOLCHAIN if REQUIRES_FULL_LIBCPP || "$(TOOLCHAIN_HAS_PICOLIBC)" = "y"
8+
default PICOLIBC_USE_TOOLCHAIN if "$(TOOLCHAIN_HAS_PICOLIBC)" = "y"
99
default PICOLIBC_USE_MODULE
1010

1111
config PICOLIBC_USE_MODULE
1212
bool "Picolibc from module"
1313
depends on ZEPHYR_PICOLIBC_MODULE
14-
depends on !GLIBCXX_LIBCPP
1514
help
1615
Use picolibc module instead of picolibc included with toolchain.
1716
This is enabled by default for toolchains other than the Zephyr
@@ -24,7 +23,6 @@ config PICOLIBC_USE_TOOLCHAIN
2423
select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE && TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE
2524
help
2625
Use picolibc included with the toolchain.
27-
This is required when using a full C++ standard library (`REQUIRES_FULL_LIBCPP=y`).
2826

2927
endchoice # PICOLIBC_SOURCE
3028

modules/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ source "modules/zcbor/Kconfig"
5252
source "modules/Kconfig.mcuboot"
5353
source "modules/Kconfig.intel"
5454
source "modules/hostap/Kconfig"
55+
source "modules/Kconfig.libstdc++"
5556

5657
comment "Unavailable modules, please install those via the project manifest."
5758

modules/Kconfig.libstdc++

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2024 Google LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config ZEPHYR_LIBSTDCXX_MODULE
5+
bool

west.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ manifest:
2323
url-base: https://github.com/zephyrproject-rtos
2424
- name: babblesim
2525
url-base: https://github.com/BabbleSim
26+
- name: keithp
27+
url-base: https://github.com/keith-packard
2628

2729
group-filter: [-babblesim, -optional]
2830

@@ -286,6 +288,11 @@ manifest:
286288
path: modules/hal/libmetal
287289
groups:
288290
- hal
291+
- name: libstdcxx
292+
remote: keithp
293+
repo-path: libstdcxx-module
294+
revision: 62c6a8d025abaa8f69740d66b5052ebf9e93ff6a
295+
path: modules/lib/libstdcxx
289296
- name: littlefs
290297
path: modules/fs/littlefs
291298
groups:

0 commit comments

Comments
 (0)