Skip to content

arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y#19116

Merged
xiaoxiang781216 merged 3 commits into
apache:masterfrom
tiiuae:fix_compilation_errors_with_partial_signals
Jun 16, 2026
Merged

arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y#19116
xiaoxiang781216 merged 3 commits into
apache:masterfrom
tiiuae:fix_compilation_errors_with_partial_signals

Conversation

@jlaitine

@jlaitine jlaitine commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Correct build errors when CONFIG_ENABLE_ALL_SIGNALS is not defined

The current master doesn't compile for CONFIG_BUILD_PROTECTED with the following setup:

#
# Signal Configuration
#
# CONFIG_ENABLE_ALL_SIGNALS is not set
CONFIG_ENABLE_PARTIAL_SIGNALS=y
# CONFIG_DISABLE_ALL_SIGNALS is not set

The first errors occur from the svcall:

In file included from armv7-m/arm_svcall.c:32:
armv7-m/arm_svcall.c: In function 'arm_svcall':
armv7-m/arm_svcall.c:250:32: error: 'struct xcptcontext' has no member named 'sigreturn'
  250 |           DEBUGASSERT(rtcb->xcp.sigreturn == 0);
      |                                ^
armv7-m/arm_svcall.c:251:20: error: 'struct xcptcontext' has no member named 'sigreturn'
  251 |           rtcb->xcp.sigreturn  = regs[REG_PC];
      |                    ^
armv7-m/arm_svcall.c:257:53: error: 'struct userspace_s' has no member named 'signal_handler'
  257 |           regs[REG_PC]         = (uint32_t)USERSPACE->signal_handler & ~1;
      |                                                     ^~
armv7-m/arm_svcall.c:292:32: error: 'struct xcptcontext' has no member named 'sigreturn'
  292 |           DEBUGASSERT(rtcb->xcp.sigreturn != 0);
      |                                ^
armv7-m/arm_svcall.c:294:43: error: 'struct xcptcontext' has no member named 'sigreturn'
  294 |           regs[REG_PC]         = rtcb->xcp.sigreturn & ~1;
      |                                           ^
armv7-m/arm_svcall.c:300:20: error: 'struct xcptcontext' has no member named 'sigreturn'
  300 |           rtcb->xcp.sigreturn  = 0;
      |                    ^
make[1]: *** [Makefile:179: arm_svcall.o] Error 1

Fixing that, leads to linker errors with undefined symbols with "nxsig_unmask_pendingsignal" etc.

There are reasons why it compiles for CONFIG_BUILD_FLAT (partially by luck, perhaps partially by design):

  • Some of the offending code is behind CONFIG_LIB_SYSCALL, which is defined only in memory protected builds
  • Some of the offending code is behind CONFIG_BUILD_PROTECTED in signal handler
  • When the nuttx is compiled first into archives and later linked together, the call to nxsig_unmask_pendingsignal is only pulled in in case user calls ppoll, pselect, sigsuspend or such from the code (signal.o is not used in linking)

The two commits in this PR fix the compilation, and also correct the functionality in CONFIG_ENABLE_PARTIAL_SIGNALS. With that flag, signal actions are now disabled, but simple signal delivery and wakeup works.

Impact

No impact on any of the current boards; the ENABLE_FULL_SIGNALS is enabled on !DEFAULT_SMALL, and for all the DEFAULT_SMALL boards currently in mainline, the full signals are enabled explicitly in defconfig.

Testing

Tested the compilation and partial signals using a custom application, with the partial signal configuration, with protected and flat builds. With the fixes, the code builds and runs properly. Without the fix, the build and link errors mentioned in the description, occur on protected build.

The ENABLE_FULL_SIGNALS, ENABLE_PARTIAL_SIGNALS and DISABLE_ALL_SIGNALS configurations have been tested on ostest on qemu-armv8a, together with PR apache/nuttx-apps#3538. The logs are in that PR.

Here is an ostest logfile from stm32f7 real hw, using ENABLE_PARTIAL_SIGNALS
ostest_pixhawk4_partial_signals.txt

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Area: OS Components OS Components issues Size: S The size of the change in this PR is small labels Jun 11, 2026
Comment thread sched/signal/sig_suspend.c
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from dd35b7a to f876eff Compare June 12, 2026 07:29
@github-actions github-actions Bot added Size: M The size of the change in this PR is medium and removed Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: S The size of the change in this PR is small labels Jun 12, 2026
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from f876eff to 9a98865 Compare June 12, 2026 08:49
@jlaitine

jlaitine commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 : I believe all the options are now properly working (ENABLE_ALL_SIGNALS, ENABLE_PARTIAL_SIGNALS and DISABLE_ALL_SIGNALS). I have been running these on qemu and stm32f7 real hw. The signal wakeup path didn't work with PARTIAL_SIGNALS at all, also there were build errors in DISABLE_ALL_SIGNALS. So hopefully it is more proper now... All signal actions (signal handlers) have been disabled in CONFIG_ENABLE_PARTIAL_SIGNALS, but basic signal delivery & wakeup works.

I also made a PR in apps/ostest, so that it is actually possible to test these different signal configurations.

@jlaitine

jlaitine commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

There was incomplete flagging for CONFIG_DISABLE_ALL_SIGNALS in the button driver, added that into this same PR. I also disabled the signals support from the one FOC board, where flash was overflowing. The signals are not used in foc demo, it only reads (samples) the buttons, so this is fine. And the signals didn't work in CONFIG_ENABLE_PARTIAL_SIGNALS (default for CONFIG_DEFAULT_SMALL) anyways before this commit, so nothing actually changed.

Comment thread libs/libc/pthread/pthread_mutex_consistent.c
jlaitine added 2 commits June 13, 2026 15:36
This small board doesn't use the signals, so it is safe to disable them to save flash.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
…_SIGNALS

The optional signal delivery should be disabled when signals support is
disabled for the board.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from d249031 to da6ad52 Compare June 13, 2026 13:04
Comment thread syscall/syscall.csv Outdated
Comment thread sched/signal/signal.h Outdated
Comment thread sched/signal/signal.h Outdated
Comment thread include/sys/syscall_lookup.h Outdated
Comment thread sched/signal/sig_initialize.c Outdated
Comment thread sched/signal/sig_initialize.c
Comment thread sched/signal/sig_dispatch.c Outdated
Comment thread sched/signal/sig_dispatch.c
@xiaoxiang781216

xiaoxiang781216 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@jlaitine please squash the last three patches into one, and remove the check of CONFIG_DISABLE_ALL_SIGNALS from nuttx/libs/libc/pthread/pthread_mutex_destroy.c

Comment thread syscall/syscall.csv
Comment thread libs/libc/pthread/pthread_kill.c Outdated
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from da6ad52 to fd0219c Compare June 14, 2026 10:23
@jlaitine jlaitine requested a review from xiaoxiang781216 June 14, 2026 10:45
Comment thread sched/signal/sig_dispatch.c
Comment thread sched/signal/sig_kill.c
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch 4 times, most recently from 76c4ac7 to 0cb3262 Compare June 14, 2026 11:11
@jlaitine

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 : I addressed your review requests, thank you for thorough reviews. Current version is now re-tested with qemu armv8 in all signal configuration modes, and the original compilation issues are fixed in protected mode as well.

@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from 0cb3262 to 2f91b55 Compare June 14, 2026 14:34
@github-actions github-actions Bot added the Arch: arm64 Issues related to ARM64 (64-bit) architecture label Jun 14, 2026
Comment thread sched/Kconfig Outdated
Comment thread sched/Kconfig
Comment thread sched/Kconfig Outdated
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from 2f91b55 to 86cb0b7 Compare June 15, 2026 05:16
Comment thread sched/Kconfig Outdated
Correct build errors when CONFIG_ENABLE_ALL_SIGNALS is not defined

- sched makefiles: Move pending-signal helpers from the ENABLE_ALL_SIGNALS-only
  list to the !DISABLE_ALL_SIGNALS list so signal dispatch is available in
  PARTIAL builds sched: make SIG_PREALLOC_ACTIONS, SIG_ALLOC_ACTIONS and
  SIG_DEFAULT depend on ENABLE_ALL_SIGNALS
- sched: fix ifdefs around pending-signal queue access and signal-mask for
  PARTIAL/DISABLE modes
- arch: gate SYS_signal_handler / _return calls and SYSCALL_LOOKUP(signal)
  with ENABLE_ALL_SIGNALS

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
@jlaitine jlaitine force-pushed the fix_compilation_errors_with_partial_signals branch from 86cb0b7 to d8e54e0 Compare June 15, 2026 06:21
@xiaoxiang781216 xiaoxiang781216 merged commit 7f8f800 into apache:master Jun 16, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: arm64 Issues related to ARM64 (64-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Area: Drivers Drivers issues Board: arm 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