This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new d16de91e39 [MSYS2] CMake+Ninja Fix arm-none-eabi-ar: Argument list too 
long
d16de91e39 is described below

commit d16de91e3919bad71a9319c8b3e7749d8ff9be03
Author: simbit18 <101105604+simbi...@users.noreply.github.com>
AuthorDate: Mon Nov 18 17:38:07 2024 +0100

    [MSYS2] CMake+Ninja Fix arm-none-eabi-ar: Argument list too long
    
    This issue is related to the Arm toolchain for Windows which is available 
for x86 host architecture only (compatible with x86_64)
    
    Windows (mingw-w64-i686) hosted cross toolchains
    AArch32 bare-metal target (arm-none-eabi)
    
    Issue
    /bin/sh: line 1: 
/home/nuttx/nuttxnew/tools/gcc-arm-none-eabi/bin/arm-none-eabi-ar: Argument 
list too long
    
    On Windows, arm-none-eabi-ar can only accept strings up to a maximum length 
of 32,768 characters.
    
    We could suppress the 32K include string limitation by setting the CMake 
variable CMAKE_NINJA_FORCE_RESPONSE_FILE to ON.
    
    This is unfortunately not enough!!! ): In the build phase this error comes 
out
    
    $ cmake --build build
    [2/1025] Building ASM object 
arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj
    FAILED: arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj
    /home/nuttx/nuttxnew/tools/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe 
@arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj.rsp -MD -MT 
arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj -MF 
arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj.d -o 
arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj -c 
/home/nuttx/nxninja/nuttx/arch/arm/src/armv7-m/arm_exception.S
    
C:/msys64/home/nuttx/nxninja/nuttx/arch/arm/src/armv7-m/arm_exception.S:42:10: 
fatal error: nuttx/config.h: No such file or directory
       42 | #include <nuttx/config.h>
          |          ^~~~~~~~~~~~~~~~
    compilation terminated.
    
    The Workround I found to solve this problem is to overwrite
    the responsible file flag CMAKE_${lang}_RESPONSE_FILE_FLAG with $DEFINES 
$INCLUDES $FLAGS
    
    Maybe there is a better solution but this one it works. :)
---
 .github/workflows/build.yml  |  2 +-
 CMakeLists.txt               | 10 ++++++++--
 arch/arm/src/cmake/gcc.cmake |  8 ++++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 443ad46db3..4bae1382c1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -328,7 +328,7 @@ jobs:
           git config --global --add safe.directory 
/github/workspace/sources/nuttx
           git config --global --add safe.directory 
/github/workspace/sources/apps
           cd sources/nuttx/tools/ci
-          ./cibuild.sh -g -i -A -C -R testlist/${{matrix.boards}}.dat
+          ./cibuild.sh -g -i -A -C -N -R testlist/${{matrix.boards}}.dat
 
       - uses: actions/upload-artifact@v4
         with:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ef56adfab..ff7f55fcd9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -337,13 +337,19 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT 
"${NUTTX_DEFCONFIG}" STREQUAL
       CACHE INTERNAL "Saved defconfig path" FORCE)
 
   # Print configuration choices
-  message(STATUS "  CMake   ${CMAKE_VERSION}")
+  message(STATUS "  CMake:  ${CMAKE_VERSION}")
   if(CMAKE_GENERATOR MATCHES "Ninja")
     execute_process(
       COMMAND ninja --version
       OUTPUT_VARIABLE ninja_version
       OUTPUT_STRIP_TRAILING_WHITESPACE)
-    message(STATUS "  Ninja   ${ninja_version}")
+    message(STATUS "  Ninja:  ${ninja_version}")
+
+    # Ninja generator does not yet know how to build archives in pieces, so
+    # response files must be used to deal with very long linker command lines.
+    set(CMAKE_NINJA_FORCE_RESPONSE_FILE
+        1
+        CACHE INTERNAL "")
   endif()
   message(STATUS "  Board:  ${NUTTX_BOARD}")
   message(STATUS "  Config: ${NUTTX_CONFIG}")
diff --git a/arch/arm/src/cmake/gcc.cmake b/arch/arm/src/cmake/gcc.cmake
index 58e388968a..f0adea0456 100644
--- a/arch/arm/src/cmake/gcc.cmake
+++ b/arch/arm/src/cmake/gcc.cmake
@@ -73,6 +73,14 @@ if(CONFIG_ARCH_TOOLCHAIN_GNU AND NOT 
CONFIG_ARCH_TOOLCHAIN_CLANG)
   endif()
 endif()
 
+# override the responsible file flag
+
+if(CMAKE_GENERATOR MATCHES "Ninja")
+  set(CMAKE_C_RESPONSE_FILE_FLAG "$DEFINES $INCLUDES $FLAGS @")
+  set(CMAKE_CXX_RESPONSE_FILE_FLAG "$DEFINES $INCLUDES $FLAGS @")
+  set(CMAKE_ASM_RESPONSE_FILE_FLAG "$DEFINES $INCLUDES $FLAGS @")
+endif()
+
 # override the ARCHIVE command
 
 set(CMAKE_ARCHIVE_COMMAND "<CMAKE_AR> rcs <TARGET> <LINK_FLAGS> <OBJECTS>")

Reply via email to