Skip to content

boards: Remove the ELF and module flags that replace the arch values. - #20844

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
casaroli:board-elf-flags
Oct 22, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
casaroli:board-elf-flags

Conversation

@casaroli

Copy link
Copy Markdown
Contributor

Summary

The arch Toolchain.defs sets CELFFLAGS, CXXELFFLAGS, LDELFFLAGS, CMODULEFLAGS and LDMODULEFLAGS. 22 boards set them again with = after they include it, with old copies of these values.

  • 14 boards link an ELF program with a linker script that does not exist (binfmt/elf/gnu-elf.ld or binfmt/libelf/gnu-elf.ld), so CONFIG_ELF does not build on them.
  • Their ELF programs link without crt0.o, with the entry point main and without -fvisibility=hidden, and they do not get the options that the arch adds for CONFIG_PIC, CONFIG_FDPIC and CONFIG_BINFMT_ELF_EXECUTABLE.
  • The module lines repeat the arch values without -fvisibility=hidden and with -e module_initialize. The entry point has no effect: libelf_insert() calls a module through its init_array.

This PR removes these lines, so the boards use the arch values. esp32c6-devkitc and esp32c6-xiao keep -melf32lriscv with +=, as esp32c6-devkitm does. esp32c3-legacy-devkit-rust-1 set LDMODULEFLAGS = -melf32lriscv, which removed -r and the linker script; it now uses +=.

After this PR, an option that the arch Toolchain.defs adds reaches every board of the arch (asked for in apache/nuttx-apps#3882, apache/nuttx-apps#3884 and apache/nuttx-apps#3886).

The second commit updates the notes of the elf, posix_spawn, module and sotest examples. They told the board to set these flags with =, with the entry point main and with linker scripts that do not exist.

Impact

  • The 22 boards get the same ELF and module flags as the other boards of their arch.
  • No CI defconfig of these boards uses the changed lines with CONFIG_ELF or CONFIG_MODULE (sama5d3-xplained:knsh has its own configs/knsh/Make.defs, samv71-xult:module uses scripts/Make.defs, which this PR does not change).
  • sim and the rx65n boards keep their lines: their arch has no Toolchain.defs, so the board file is the only definition.
  • No code change. The documentation is updated in this PR.

Testing

For each of the 22 boards, one defconfig, configured on master and on this branch, with the six variables printed from the configured Make.defs:

master this PR
14 boards: linker script in LDELFFLAGS binfmt/elf/gnu-elf.ld or binfmt/libelf/gnu-elf.ld, missing libs/libc/elf/gnu-elf.ld
all 22 boards old copies (no crt0.o, -e main, no -fvisibility=hidden) the same values as a board of the same arch without these lines (nucleo-h743zi:nsh, esp32s3-devkit:nsh, esp32c6-devkitm:nsh)

Build with ELF programs: openh743i:nsh plus the ELF options of nucleo-h743zi:elf (CONFIG_ELF, CONFIG_EXAMPLES_ELF, CONFIG_FS_ROMFS, CONFIG_NSH_FILE_APPS, the symbol table options), Arm GNU 15.3:

master this PR
make arm-none-eabi-ld: cannot open linker script file .../binfmt/elf/gnu-elf.ld: No such file or directory builds without warnings; the 10 test programs link with crt0.o -e _start -T .../libs/libc/elf/gnu-elf.ld

tools/checkpatch.sh -c -u -m -g passes.

The arch Toolchain.defs sets CELFFLAGS, CXXELFFLAGS, LDELFFLAGS,
CMODULEFLAGS and LDMODULEFLAGS.  22 boards set them again with "="
after they include it, with old values:

- 14 boards link an ELF program with a linker script that does not
  exist (binfmt/elf/gnu-elf.ld or binfmt/libelf/gnu-elf.ld).
- The ELF programs link without crt0.o, with the entry point main and
  without -fvisibility=hidden, and they do not get the options that
  the arch adds for CONFIG_PIC, CONFIG_FDPIC and
  CONFIG_BINFMT_ELF_EXECUTABLE.
- The module lines repeat the arch values without -fvisibility=hidden
  and with "-e module_initialize".  The entry point has no effect: the
  loader calls a module through its init_array.

Remove these lines, so that the boards use the arch values.
esp32c6-devkitc and esp32c6-xiao keep -melf32lriscv with "+=", as
esp32c6-devkitm does.  esp32c3-legacy-devkit-rust-1 set LDMODULEFLAGS
to -melf32lriscv with "=", which removed -r and the linker script; it
now adds the option with "+=".

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
The notes of the elf, posix_spawn, module and sotest examples told the
board to set CELFFLAGS, LDELFFLAGS, CMODULEFLAGS and LDMODULEFLAGS
with "=", with the entry point main and with linker scripts that do
not exist.  The arch Toolchain.defs sets these flags.  Say that a board
can add an option with "+=", and that it must not set them again.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@casaroli casaroli closed this Oct 21, 2026
@casaroli casaroli reopened this Oct 21, 2026
@xiaoxiang781216
xiaoxiang781216 merged commit a46119d into apache:master Oct 22, 2026
85 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Board: arm Board: arm64 Board: risc-v Board: xtensa Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants