casaroli opened a new pull request, #21567: URL: https://github.com/apache/nuttx/pull/21567
## Summary A build with `CONFIG_SYSLOG_TO_SCHED_NOTE=y` and `CONFIG_DRIVERS_NOTE_STRIP_FORMAT=y` fails on master. There are four causes, one commit each: - `libc/syslog`: with `CONFIG_SYSLOG_TO_SCHED_NOTE`, `syslog()` and `vsyslog()` are only macros, so code that takes the address of `syslog` does not build. `METAL_INIT_DEFAULTS` of libmetal does this, and `drivers/virtio/virtio.c`, `drivers/rpmsg/rpmsg.c` and `drivers/vhost/vhost.c` fail with `'syslog' undeclared`. This cause does not need `CONFIG_DRIVERS_NOTE_STRIP_FORMAT`. The fix declares the functions in all configurations and adds `lib_syslog_note.c`, which sends the message to `sched_note_vprintf()`. Direct calls still use the macros. `vsyslog()` passes a copy of its `va_list`, because `sched_note_vprintf()` takes the address of its `va_list` and on x86_64 `va_list` is an array type. - `sched_note`: with `CONFIG_DRIVERS_NOTE_STRIP_FORMAT`, `sched_note_printf()` encodes the type of each argument in a 32-bit tag, which has room for 14 arguments. A static assertion stops the build for a call with more, for example the task dump in `sched/misc/assert.c` (up to 19 arguments). A call with more than 14 arguments now keeps its format string and gives type 0, as `sched_note_printf()` does without `CONFIG_DRIVERS_NOTE_STRIP_FORMAT`. The note driver then reads the arguments from the format. - `sched_note`: the type detection uses `_Generic`, which C++ does not have, so `libs/libxx` fails (`'_Generic' was not declared in this scope`). C++ calls now keep their format string and give type 0. - `sched_note`: the type detection uses `(arg) + 0`, which is not allowed for a pointer to an incomplete type. `drivers/rptun/rptun.c` and `net/tcp/tcp_dump.c` fail with `invalid use of undefined type`. The fix uses `(0 ? 0 : (arg))`, which gives the same type for integers, floating types, arrays and pointers, and accepts any pointer. ## Impact - Only configurations with `CONFIG_SYSLOG_TO_SCHED_NOTE` (first commit) or `CONFIG_DRIVERS_NOTE_STRIP_FORMAT` (other commits). Other configurations do not change. - `syslog()` and `vsyslog()` now exist as functions with `CONFIG_SYSLOG_TO_SCHED_NOTE`. A call through a pointer goes to the note driver, as a direct call does. - With `CONFIG_DRIVERS_NOTE_STRIP_FORMAT`, C calls with 14 arguments or fewer do not change. C calls with more arguments and all C++ calls keep their format string in the image. - The code is the same in flat, protected and kernel builds, on every architecture. Make and CMake both build the new file. No documentation describes these options, so there is no documentation change. ## Testing Options added to each configuration: `CONFIG_SCHED_INSTRUMENTATION`, `CONFIG_SCHED_INSTRUMENTATION_DUMP`, `CONFIG_DRIVERS_NOTE`, `CONFIG_SYSLOG_TO_SCHED_NOTE` (instead of `CONFIG_SYSLOG`), `CONFIG_DRIVERS_NOTE_STRIP_FORMAT`. | Configuration | Build | master | this PR | |---|---|---|---| | `qemu-armv8a:knsh` + virtio (kernel, arm64) | make | fails: virtio.c, assert.c, libxx_new.cxx, libxx_newa.cxx | builds; ostest status 0 | | `qemu-armv8a:nsh` + virtio (flat, arm64) | make | not run | builds; ostest status 0 | | `rv-virt:netnsh` (flat, rv32) | make | fails: virtio.c, assert.c | builds | | `rv-virt:knetnsh64` (kernel, rv64) | make | not run | builds | | `qemu-armv7a:rpserver` (flat, armv7-a, rpmsg) | make | fails: rpmsg.c, rptun.c, virtio.c, assert.c | builds | | `qemu-armv8a:netnsh` (flat, arm64) | CMake | not run | builds | | `mps2-an500:knsh` (protected, Cortex-M7) | make | not run | builds | | `qemu-intel64:nsh` (flat, x86_64, x86_64-elf-gcc 16.2) | make | builds (none of the four causes is in this configuration) | builds | `qemu-armv8a:knsh` also ran a test program (user space, kernel build) that calls `syslog()` through a function pointer and calls `syslog()` with 16 arguments: it returns normally (PASS). checkpatch: `tools/checkpatch.sh -c -u -m -g` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
