Skip to content

Commit 17cbb1b

Browse files
committed
libc/picolibc: Use libc-level PICOLIBC_MODULE to control picolibc mode
C++ is supported with picolibc only when the toolchain version of picolibc is use -- libstdc++ must be built with picolibc support and libstdc++ is included with the toolchain. That creates a circular dependency if the control of whether to use the module is placed under the picolibc configuration block (as PICOLIBC_USE_MODULE is). Make an explicit PICOLIBC_MODULE variable at the libc level to be the user-visible control for this feature and make code depending on whether the picolibc module should be used depend on both PICOLIBC and PICOLIBC_MODULE. Change PICOLIBC_USE_MODULE to be a hidden configuration variable that the picolibc module cmake files can use to determine whether to include the picolibc module sources in the zephyr application build. This symbol can be removed when the picolibc module is updated to use PICOLIBC AND PICOLIBC_MODULE instead Signed-off-by: Keith Packard <[email protected]>
1 parent 04870f5 commit 17cbb1b

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ add_custom_command(
695695
# Make sure Picolibc is built before the rest of the system; there's no explicit
696696
# reference to any of the files as they're all picked up by various compiler
697697
# settings
698-
if(CONFIG_PICOLIBC_USE_MODULE)
698+
if(CONFIG_PICOLIBC AND CONFIG_PICOLIBC_MODULE)
699699
set(picolibc_dependency PicolibcBuild)
700700
endif()
701701

cmake/compiler/gcc/compiler_flags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ set_compiler_property(PROPERTY warning_error_coding_guideline
104104
set_compiler_property(PROPERTY cstd -std=)
105105

106106
if (NOT CONFIG_NEWLIB_LIBC AND
107-
NOT (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_USE_MODULE) AND
107+
NOT (CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_MODULE) AND
108108
NOT COMPILER STREQUAL "xcc" AND
109109
NOT CONFIG_HAS_ESPRESSIF_HAL AND
110110
NOT CONFIG_NATIVE_APPLICATION)

lib/libc/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ config EXTERNAL_LIBC
6868

6969
endchoice # LIBC_IMPLEMENTATION
7070

71+
config PICOLIBC_MODULE
72+
bool "Use picolibc module"
73+
default y if !CPLUSPLUS
74+
help
75+
Use picolibc module instead of picolibc included with toolchain
76+
7177
config HAS_NEWLIB_LIBC_NANO
7278
bool
7379

lib/libc/picolibc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ zephyr_library_sources(libc-hooks.c)
77
# used by the network stack
88
zephyr_compile_definitions(__LINUX_ERRNO_EXTENSIONS__)
99

10-
if(NOT CONFIG_PICOLIBC_USE_MODULE)
10+
if(CONFIG_PICOLIBC AND NOT CONFIG_PICOLIBC_MODULE)
1111

1212
# Use picolibc provided with the toolchain
1313

lib/libc/picolibc/Kconfig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33

44
if PICOLIBC
55

6-
config PICOLIBC_USE_MODULE
7-
bool "Use picolibc module"
8-
default y
9-
select PICOLIBC_MODULE
10-
help
11-
Use picolibc module instead of picolibc included with toolchain
12-
136
config PICOLIBC_HEAP_SIZE
147
int "Picolibc heap size (bytes)"
158
default 16384 if MMU
@@ -40,7 +33,14 @@ config PICOLIBC_IO_FLOAT
4033
help
4134
Include floating point support in printf/scanf functions.
4235

43-
if PICOLIBC_USE_MODULE
36+
if PICOLIBC_MODULE
37+
38+
config PICOLIBC_USE_MODULE
39+
bool
40+
default y
41+
help
42+
Hidden option that tells the picolibc module
43+
whether to build picolibc or to skip it.
4444

4545
choice PICOLIBC_OPTIMIZATIONS
4646
prompt "Optimization level"
@@ -148,6 +148,6 @@ config PICOLIBC_GLOBAL_ERRNO
148148
which can be used to avoid TLS variable usage by the library if
149149
necessary.
150150

151-
endif # PICOLIBC_USE_MODULE
151+
endif # PICOLIBC_MODULE
152152

153153
endif # PICOLIBC

0 commit comments

Comments
 (0)