This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 63cf672a68a libs/libc/stdlib: Default LIBC_MAX_EXITFUNS to 1 with ELF
and C++.
63cf672a68a is described below
commit 63cf672a68a4c399e51ab468d2997480a36c24bb
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Nov 4 05:25:58 2026 +0100
libs/libc/stdlib: Default LIBC_MAX_EXITFUNS to 1 with ELF and C++.
A C++ ELF program is built with -fno-use-cxa-atexit, so a static object
with a destructor calls atexit(): with GCC a static object in a function,
with Clang every static object. atexit() is not built with
CONFIG_LIBC_MAX_EXITFUNS=0, so the nucleo-h743zi:elf configuration fails
to link with Clang:
ld.lld: error: undefined symbol: atexit
>>> referenced by test_symtab.c
Make 1 the default when both ELF and HAVE_CXX are enabled, so that these
programs link and their destructors run. A configuration can still set 0
when its ELF programs have no static objects.
sim:loadable already had this value, so its defconfig drops the line.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
Documentation/reference/user/03_task_control.rst | 5 +++--
boards/sim/sim/sim/configs/loadable/defconfig | 1 -
libs/libc/stdlib/Kconfig | 8 +++++---
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Documentation/reference/user/03_task_control.rst
b/Documentation/reference/user/03_task_control.rst
index b133e3f68e6..fb8dd1a620a 100644
--- a/Documentation/reference/user/03_task_control.rst
+++ b/Documentation/reference/user/03_task_control.rst
@@ -422,8 +422,9 @@ Functions
.. note:: ``CONFIG_LIBC_MAX_EXITFUNS`` must be larger than 0 to build
``atexit()``, ``on_exit()`` and ``at_quick_exit()``. A C++ ELF
- program (built with ``-fno-use-cxa-atexit``) with a static object in
- a function calls ``atexit()`` too.
+ program (built with ``-fno-use-cxa-atexit``) with a static object
+ calls ``atexit()`` too, so the default is 1 when both ``CONFIG_ELF``
+ and ``CONFIG_HAVE_CXX`` are enabled.
The number of functions is limited only by memory: the first
``CONFIG_LIBC_MAX_EXITFUNS`` entries are in the task information, the
diff --git a/boards/sim/sim/sim/configs/loadable/defconfig
b/boards/sim/sim/sim/configs/loadable/defconfig
index d0da2b6eb15..8b6919da7b4 100644
--- a/boards/sim/sim/sim/configs/loadable/defconfig
+++ b/boards/sim/sim/sim/configs/loadable/defconfig
@@ -34,7 +34,6 @@ CONFIG_INIT_MOUNT_SOURCE=""
CONFIG_INIT_MOUNT_TARGET="/system"
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
-CONFIG_LIBC_MAX_EXITFUNS=1
CONFIG_LINE_MAX=128
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILE_APPS=y
diff --git a/libs/libc/stdlib/Kconfig b/libs/libc/stdlib/Kconfig
index a3433fd55a7..bf8c6567a10 100644
--- a/libs/libc/stdlib/Kconfig
+++ b/libs/libc/stdlib/Kconfig
@@ -32,6 +32,7 @@ config LIBC_MAX_TMPFILE
config LIBC_MAX_EXITFUNS
int "Number of preallocated exit functions"
+ default 1 if ELF && HAVE_CXX
default 0
---help---
The number of exit functions (atexit(), on_exit(),
at_quick_exit()
@@ -43,9 +44,10 @@ config LIBC_MAX_EXITFUNS
With 0, there are no exit functions: atexit(), on_exit() and
at_quick_exit() are not built, so a program that calls them does
not link, and __cxa_atexit() registers nothing (the destructors
- of static C++ objects do not run). A C++ ELF program (built
with
- -fno-use-cxa-atexit) with a static object in a function calls
- atexit(), so it needs a value larger than 0.
+ of static C++ objects do not run). A C++ ELF program is built
with
+ -fno-use-cxa-atexit, so a static object calls atexit() (GCC: a
+ static object in a function, Clang: every static object). That
is
+ why the default is 1 when both ELF and C++ are enabled.
config LIBC_DISABLE_HEXSTR_TO_FLOAT
bool "Disable hex-string to float/double conversions"