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
commit e369db1b9212180add660d999a1edeba5042f68a Author: Marco Casaroli <[email protected]> AuthorDate: Sat Oct 17 19:43:25 2026 +0200 tools/mkexport.sh: Add empty pthread, rt and dl libraries. In a kernel build, libc has the POSIX threads, real-time and dynamic loading functions, but a program that links with -lpthread, -lrt or -ldl failed: the export package had no such library. The export of a kernel build now has an empty libpthread.a, librt.a and libdl.a, like the C library of other systems that put these functions in libc. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- Documentation/components/tools/nuttx-cc.rst | 3 +++ tools/mkexport.sh | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/components/tools/nuttx-cc.rst b/Documentation/components/tools/nuttx-cc.rst index ec037b2e43b..545651a5ccc 100644 --- a/Documentation/components/tools/nuttx-cc.rst +++ b/Documentation/components/tools/nuttx-cc.rst @@ -45,6 +45,9 @@ What the wrapper does - When it links, it adds ``startup/crt0.o``, ``scripts/gnu-elf.ld`` and, in a kernel build (``CONFIG_BUILD_KERNEL``), the user-space libraries of the package. +- In a kernel build, the package also has an empty ``libpthread.a``, + ``librt.a`` and ``libdl.a``, so that ``-lpthread``, ``-lrt`` and ``-ldl`` + link: libc has these functions. - In a kernel build, a link with an undefined symbol fails. A kernel-build program is a relocatable (``-r``) ELF, and a relocatable link does not report undefined symbols by itself. Without this check, every configure diff --git a/tools/mkexport.sh b/tools/mkexport.sh index 9eb436c6670..894b55d0dc3 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -606,6 +606,16 @@ if [ "${NUTTX_BUILD}" = "kernel" ]; then CCLIBS="${CCLIBS} m" fi CCLIBS="${CCLIBS} gcc" + + # libc has the POSIX threads, real-time and dynamic loading functions. + # Empty libraries let programs link with -lpthread, -lrt and -ldl, as + # they do on other systems. + + for lib in pthread rt dl; do + if [ ! -f "${EXPORTDIR}/libs/lib${lib}${LIBEXT}" ]; then + printf '!<arch>\n' >"${EXPORTDIR}/libs/lib${lib}${LIBEXT}" + fi + done fi CCLDSCRIPT=
