Repository navigation
Conversation
cederom
previously approved these changes
Oct 19, 2026
casaroli
force-pushed
the
module-ldflags-driver
branch
from
October 19, 2026 21:28
61550ca to
af0ef1f
Compare
With CONFIG_LTO_FULL (GCC), LD is the compiler driver, and a loadable module (and a program of a kernel build) is linked with it, because MODULELD defaults to LD. Application.mk gave the program attributes as "--defsym nx_stacksize=...", and gcc stopped with "unrecognized command-line option '--defsym'". Where Application.mk sets MODLDFLAGS, it now also sets MODDEFSYM: "-Wl,--defsym=" when MODULELD is gcc or clang, and "--defsym=" for ld. A link with ld gets "--defsym=sym=value" in place of "--defsym sym value", which GNU ld and ld.lld read the same way. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
module-ldflags-driver
branch
from
October 20, 2026 22:40
af0ef1f to
85fdedd
Compare
casaroli
marked this pull request as draft
October 20, 2026 23:06
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): CI run: https://github.com/apache/nuttx-apps/actions/runs/39509862159 |
xiaoxiang781216
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
CONFIG_LTO_FULL(GCC),LDis the compiler driver, and the Make build links each loadable module (and each program of a kernel build) with it, becauseMODULELDdefaults toLD.Application.mkgives the program attributes as--defsym nx_stacksize=..., and gcc stops withunrecognized command-line option '--defsym'.Where
Application.mksetsMODLDFLAGS, it now also setsMODDEFSYM:-Wl,--defsym=whenMODULELDis gcc or clang, and--defsym=for ld.The other part of the earlier version (
-flinker-output=nolto-reland the module options inMake.defs) moved to NuttX, where the flags are first set, as asked in the review: apache/nuttx#20846. A module with LTO links only with both PRs.depends-on: apache/nuttx/pull/20846
Impact
Only builds with
CONFIG_LTO_FULLand a module or a kernel build: the modules link. A link with ld gets--defsym=sym=valuein place of--defsym sym value, which GNU ld and ld.lld read the same way.Testing
qemu-armv8a:nsh(flat, Arm GNU 14.2, QEMU HVF) withCONFIG_LTO_FULL,CONFIG_ELF,CONFIG_EXECFUNCS_SYSTEM_SYMTABandCONFIG_EXAMPLES_HELLO=m, rebased on apps master: the link ofhellohas-Wl,--defsym=nx_stacksize=...and-Wl,--defsym=nx_priority=...and builds; with apache/nuttx#20846helloloads and printsHello, World!!(on nuttx master the module keeps LTO data only and fails withexec failed: 22). The earlier version ran the TLS tests and aLibrary.mkshared library with LTO onqemu-armv8a:nshandmps2-an500:nsh, and the same programs without LTO (--defsym=with ld).tools/checkpatch.sh -c -u -m -gpasses.