casaroli opened a new pull request, #3972:
URL: https://github.com/apache/nuttx-apps/pull/3972
## Summary
In a kernel build, `import/Make.defs` adds `-lm` only when
`CONFIG_LIBM_NONE` is set. The condition is inverted. Commit 877509762 ("Use
libm from the export package when defined") meant the opposite. This PR adds
`-lm` when a math library other than the one of the toolchain is selected.
## Impact
- Kernel builds only: the line is inside `ifeq ($(CONFIG_BUILD_KERNEL),y)`.
Flat and protected builds do not use it.
- `CONFIG_LIBM`: the export package has `libm.a`, but programs do not link
it. A program that calls a math function keeps undefined symbols. Its link
fails on rv-virt:knsh64. On qemu-armv8a:knsh the link gives no error, and
`exec()` fails: NSH prints "command not found".
- `CONFIG_LIBM_NONE`: the export package has no `libm.a`, so `make import`
fails with "cannot find -lm" for every program. This PR fixes this too.
- `CONFIG_LIBM_TOOLCHAIN`: no change.
- `tools/KernelLibs.mk` puts `libm.a` in the export package for every other
choice (`CONFIG_LIBM`, `CONFIG_LIBM_NEWLIB`, `CONFIG_LIBM_LIBMCS`,
`CONFIG_LIBM_OPENLIBM`).
- The import build is a make build only, so there is no CMake change. No
documentation change: Documentation/ does not describe this link.
## Testing
Test program `libmuse.c`: a program of the apps tree that `make import`
builds, and that calls `cbrt()` and `frexp()`. nuttx 39a1f27900c.
| configuration | master | this PR |
| --- | --- | --- |
| qemu-armv8a:knsh (`CONFIG_LIBM`, QEMU with HVF) | undefined `cbrt`,
`frexp`; "command not found" | no undefined symbols; PASS: `cbrt(27)` = 3,
`frexp(8)` = 0.5, exponent 4 |
| rv-virt:knsh64 (`CONFIG_LIBM`, QEMU TCG) | `make import` fails: undefined
reference to `cbrt`, `frexp` | no undefined symbols; PASS, same values |
| qemu-armv8a:knsh with `CONFIG_LIBM_NONE`, without the test program | `make
import` fails: "cannot find -lm" | `make import` OK, 6 programs (master: 0) |
ostest exits with status 0 on qemu-armv8a:knsh on master and with this PR.
No test in CI checks this: no citest configuration is a kernel build.
The tests ran on apps master 2a452d453; the branch is rebased on f04aee6015c
(no change in the touched files).
`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]