casaroli opened a new pull request, #20772:
URL: https://github.com/apache/nuttx/pull/20772

   ## Summary
   
   The make build of `stm32l0538-disco:nsh` (`CONFIG_LTO_FULL`, GNU toolchain) 
prints four warnings at the link. This PR fixes their causes, one commit each:
   
   1. `lto-wrapper: warning: Extra option to '-Xassembler': -mthumb, dropping 
all '-Xassembler' and '-Wa' options.`
      The Makefile of a common board directory includes `$(TOPDIR)/Make.defs`, 
and then `board/Make.defs`. The board `Make.defs` of 160 boards included 
`$(TOPDIR)/Make.defs` again, so the files of the common directory got the 
toolchain flags twice. lto-wrapper then saw different assembler options and 
dropped all of them. The commit removes the second include, as the other boards 
of these directories do.
   2. `lto-wrapper: warning: using serial compilation of 2 LTRANS jobs` (and 
its note).
      GCC now gets `-flto=auto`, in the make and in the CMake build.
   3. `ld: warning: nuttx has a LOAD segment with RWX permissions`.
      With LTO, gcc links nuttx. The Makefile gave `-nostdlib` to ld through 
`-Xlinker`, so gcc still added its start files and default libraries. 
`crtbegin.o` puts an entry into `.init_array`, a writable section, in flash. 
gcc now gets `-nostdlib`, as in the CMake build. GNU ld then adds the libgcc 
functions that LTO calls only if the link has an object file outside the 
libraries, so the link gets an empty object, as the CMake build does with 
`empty.c`.
   
   ## Impact
   
   Builds with `CONFIG_LTO_FULL` and the GNU toolchain: no start files of the 
compiler in the image (a few bytes smaller), and the assembler options are kept 
for the files of a common board directory. Other builds do not change, except 
that the files of a common board directory no longer get the toolchain flags 
twice.
   
   ## Testing
   
   GCC 13.2.Rel1 (the CI version) on macOS:
   
   | Build | master | this PR |
   |---|---|---|
   | `stm32l0538-disco:nsh` (make) | 4 warnings, flash segment `RWE` | no 
warning, `R E` |
   | `nucleo-g431rb:nsh` (make, LTO) | RWX warning | no warning |
   | `stm32l0538-disco:nsh` (CMake) | no warning | no warning |
   | `mps2-an500:nsh` with `CONFIG_LTO_FULL` (profiling off), in QEMU | RWX 
warning; boots to NSH | no warning; boots to NSH, `uname -a` works |
   
   Builds of `stm32f4discovery:nsh`, `raspberrypi-pico:nsh`, `nrf52840-dk:nsh`, 
`samv71-xult:nsh`, `nucleo-h743zi:nsh` and `nucleo-l476rg:nsh` (boards from the 
changed common directories) pass, with no new warning.
   
   `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]

Reply via email to