casaroli opened a new pull request, #3884: URL: https://github.com/apache/nuttx-apps/pull/3884
## Summary With `CONFIG_LTO_FULL` (GCC), `LD` is the compiler driver, and the Make build links each loadable module (and each program of a kernel build) with it, because `MODULELD` defaults to `LD`. Two parts of that link are wrong, so no module can be built or loaded: - `Application.mk` gives the program attributes as `--defsym nx_stacksize=...`. gcc stops with `unrecognized command-line option '--defsym'`. - The partial link (`-r`) of LTO objects keeps LTO data only. The loader cannot use it: `Failed to execute program 'hello': -22`. `nm` says `plugin needed to handle lto object`. This PR uses `-Wl,--defsym=` when `MODULELD` is the driver, and `--defsym=` for ld. For a partial link through the gcc driver, `Application.mk` and `Library.mk` add `-flinker-output=nolto-rel` and the compile options of the module. The link then compiles the objects to machine code with the options of the module (`-mthumb`, `-mlong-calls`, ...). Without the options, the arm-none-eabi assembler stopped with `invalid constant (3e8) after fixup`. `-Werror` is left out, because crt0 declares `main()` with the environment argument and LTO warns that the declarations do not match. ## Impact Only builds with `CONFIG_LTO_FULL` and a module or a kernel build: the modules link and load. A link with ld gets `--defsym=sym=value` in place of `--defsym sym value`, which GNU ld and ld.lld read the same way. ## Testing `MODULE = m` programs (TLS tests, `hello`) and a `Library.mk` shared library, loaded at run time, with `CONFIG_LTO_FULL`: | Board | master | this PR | |---|---|---| | `qemu-armv8a:nsh` (Arm GNU 14.2, QEMU HVF) | build fails: `unrecognized command-line option '--defsym'`; with only the `-Wl,` part: every program fails with `-22` (LTO data) | all programs PASS | | `mps2-an500:nsh` (arm-none-eabi 13.2, QEMU TCG) | not run on master (the same `--defsym` line); with only the `-Wl,` and `nolto-rel` parts: `invalid constant after fixup` | all programs PASS | The same programs without LTO (`--defsym=` with ld) still PASS on both boards. The tests ran with nuttx apache/nuttx#20723 and #20807 and with apache/nuttx-apps#3882 (the TLS programs need it); `hello` needs only #20807. `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]
