cmake: Omit default priority ELF symbol. - #19548
Merged
xiaoxiang781216 merged 1 commit intoJul 27, 2026
Merged
Conversation
nuttx_add_application() encoded SCHED_PRIORITY_DEFAULT as a zero-valued nx_priority linker symbol. A zero priority is invalid for a runnable ELF application task. Do not emit nx_priority for the symbolic default. When the symbol is absent, the ELF loader retains its scheduler default. Continue emitting nx_priority for explicit numeric priorities. Companion to apache/nuttx-apps#3667. Assisted-by: Zed:GPT-5.6 Terra Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
Contributor
Author
|
Companion PR: apache/nuttx-apps#3667 fixes the same default-priority ELF encoding in the Make build path. This PR covers the CMake path. |
Contributor
Author
casaroli
marked this pull request as ready for review
July 27, 2026 01:51
xiaoxiang781216
approved these changes
Jul 27, 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
nuttx_add_application()translatesSCHED_PRIORITY_DEFAULTinto a zero-valuednx_prioritylinker symbol for CMake-built ELF applications. Priority zero is invalid for a runnable application task; on assertion-enabled targets, launching such an application triggers the scheduler priority assertion.Do not emit
nx_prioritywhen an application selectsSCHED_PRIORITY_DEFAULT. The ELF loader already uses its scheduler default when the symbol is absent. Explicit numeric priorities continue to be emitted unchanged.This is the CMake companion to apache/nuttx-apps#3667, which makes the corresponding correction for Make-built application ELFs. Together they replace the need for the broader ELF-loader workaround proposed in #19537.
Impact
SCHED_PRIORITY_DEFAULTreceive the existing scheduler default instead of an invalid priority-zero ELF attribute.Testing
Host: Fedora Linux x86_64; CMake 4.3.0; Ninja 1.13.2; xPack
riscv-none-elf-gcc14.2.0.Target configuration:
rv-virt:knsh64(RISC-V 64-bit kernel ELF build).Commands:
After this change, the generated
ostestlink command contains nonx_prioritydefinition:riscv-none-elf-ld ... -o .../bin_debug/ostestThe explicit numeric-priority regression check is retained:
riscv-none-elf-ld ... --defsym nx_priority=50 ... -o .../bin_debug/getprimeA generated-build-tree search found no
--defsym nx_priority=0../tools/checkpatch.sh -f cmake/nuttx_add_application.cmakeandgit diff --checkpass.The full CMake/Ninja
rv-virt:knsh64build could not complete on this host because CMake invokes this xPack toolchain'sriscv-none-elf-ldwith its default 32-bit emulation while the target objects are 64-bit:This is unrelated to the priority change. No physical-hardware runtime validation is available in this workspace, so this PR is marked draft pending that validation.
PR verification self-check
Assisted-byand human sign-off trailers.