apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.83k stars 1.17k forks source link

Toolchain command do not take effect in CMake build after menuconfig settings #11452

Open xuxin930 opened 10 months ago

xuxin930 commented 10 months ago

Here is an example:

Our current Toolchain File overwrite the ARCHIVE command https://github.com/apache/nuttx/blob/992719730f355ed3132c3204153f919822870074/arch/arm/src/cmake/Toolchain.cmake#L92-L94 but <CMAKE_AR> makes different choices depending on whether LTO is enabled or not. https://github.com/apache/nuttx/blob/992719730f355ed3132c3204153f919822870074/arch/arm/src/cmake/Toolchain.cmake#L75-L86 If every Toolchain configs is configured in defconfig, everything will work normally. But if LTO is not enabled in defconfig and I call cmake --build -t menuconfig to open LTO, then the expectation is different from the setting.

Because the execution of CMake is divided into three stages: configure, generate and build. the Toolchain command (such as CMAKE_AR above) is configured in stages configure, generate and is solidified in the generated build file (such as Makefile). so in the end this menuconfig modification will NOT take effect.

How can we improve this to make it work properly?

acassis commented 10 months ago

@pkarashchenko any idea?

xiaoxiang781216 commented 10 months ago

In this case, we should regenerate Makefile?