casaroli commented on code in PR #3884: URL: https://github.com/apache/nuttx-apps/pull/3884#discussion_r4329029180
########## Make.defs: ########## @@ -72,6 +72,21 @@ BINDIR_DEBUG ?= $(APPDIR)$(DELIM)bin_debug BUILD_SHARED_LIBRARY ?= $(APPDIR)$(DELIM)Library.mk +# With CONFIG_LTO_FULL the gcc driver links a module. A partial link (-r) +# must compile the LTO objects to machine code, with the module options +# (-mthumb, -mlong-calls, ...): the loader cannot use LTO data. + +ifneq ($(filter %gcc,$(firstword $(MODULELD))),) + ifneq ($(filter -r,$(LDMODULEFLAGS)),) + LDMODULEFLAGS += -flinker-output=nolto-rel \ Review Comment: I checked this again on master. `tools/Config.mk` is included before the arch `Toolchain.defs`, so it cannot add to these variables. The arch `Toolchain.defs` sets them first (the gcc driver links with LTO on arm, arm64 and risc-v), but 18 board `Make.defs` files of these arches set them again with `=` after they include it, for example `boards/arm/stm32h7/openh743i/scripts/Make.defs:49` (`LDELFFLAGS`), `boards/arm/imxrt/imxrt1170-evk/scripts/Make.defs:48` (`LDMODULEFLAGS`), `boards/arm64/imx9/imx95-a55-evk/scripts/Make.defs:45` and `boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs:58,70`. `tools/mkexport.sh:243` then sets `LDMODULEFLAGS="-r"` for the export, and `tools/mkexport.sh:239` removes everything from `-T` to the last `ld` in `LDELFFLAGS`, so options after `-T` are lost when one of them contains `ld` (the module options contain include paths, for example a path with `build`). So a change in NuttX must go into the three `Toolchain.defs` files, the 18 board files and `mkexport.sh`. Most of these board lines only repeat the arch values, and some point to linker scripts that are gone (`binfmt/elf/gnu-elf.ld`), so I can first remove them in a separate NuttX PR and then set the options in `Toolchain.defs`. Do you want this? Else apps `Make.defs` is the first place that comes after all of them. -- 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]
