Sarthak-Pandey opened a new pull request, #20610:
URL: https://github.com/apache/nuttx/pull/20610

   ## Summary
   
   Fixes #14426.
   
   When CMake configures multiple languages (e.g., `C`, `CXX`, `ASM`), the 
top-level directory `COMPILE_OPTIONS` property is populated multiple times 
during language initialization. Consequently, `NUTTX_EXTRA_FLAGS` in 
`platform.cmake` accumulates duplicated compilation options.
   
   When using the Ninja generator, these duplicated flags are passed to the 
linker without automatic deduplication (e.g., when linking `final_nuttx` in 
`cmake/nuttx_multiple_link.cmake`), resulting in duplicate CFLAGS 
(`-mcpu=cortex-a7 ... -mcpu=cortex-a7 ...`).
   
   This patch resolves the issue by:
   1. Adding a `list(REMOVE_DUPLICATES NUTTX_EXTRA_FLAGS)` check in 
`platform.cmake` across architectures (`arm`, `risc-v`, `tricore`, `x86_64`, 
`xtensa`).
   2. Deduplicating `NUTTX_EXTRA_FLAGS` in the top-level `CMakeLists.txt` prior 
to invoking `target_link_libraries(nuttx PRIVATE ...)`.
   
   ## Impact
   
   * **Build System:** Clean and concise linker commands without redundant 
duplicate compiler flags.
   * **Compatibility:** Prevents command-line length overflow issues 
(especially on Windows) and ensures consistent behavior between Makefile and 
Ninja backends.
   * **User impact:** None.
   
   ## Testing
   
   * **Host:** Linux / Windows
   * **Target:** `qemu-armv7a:nsh`
   * **Command:**
     ```bash
     cmake -B build -DBOARD_CONFIG=qemu-armv7a:nsh -GNinja
     ninja -C build -v
   


-- 
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