No RSP_FILE if generating in a path that contains "@"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

No RSP_FILE if generating in a path that contains "@"

Gerhard Olsson
The following occurs with CMake on Windows, crosscompiling with ARMCC.

If the path contains "@", CMake ignores response file in the toolchain file:
SET( CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1 ) 

 The linker command is too long and fails.

The command is run in Jenkins, I have not seen a way to avoid generating @ in the path
A workaround could be to patch rules.ninja to add the rsp_file handling if missing.

Any configuration changes that resolves the problem?
Any hints how to debug and fix CMake for this?

/Gerhard

---------------------------------------
Run in Cygwin, using Windows binary (to use with Windows compiler)

 "c:/Tools/CMake/3.11.2/bin/cmake" -G "Ninja" --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake .

Note that the WindRiver compiler is OK, a difference is that CMAKE_C_RESPONSE_FILE_LINK_FLAG is "@" by default, no need to override to "--via" as for armcc.

--------------------------------------------
From rules.ninja, where the path contains a "@"
rule C_EXECUTABLE_LINKER__FBLZYNQ
  command = cmd.exe /C "$PRE_LINK && C:\Tools\ARM_Compiler_5\5.0.4.82\bin64\
armlink.exe $LINK_FLAGS $LINK_PATH $LINK_LIBRARIES $in -o $TARGET_FILE && $POST_
BUILD"
  description = Linking C executable $TARGET_FILE
  restat = $RESTAT


From rules.ninja, where the path has no "@" 
  rule C_EXECUTABLE_LINKER__FBLZYNQ
  command = cmd.exe /C "$PRE_LINK && C:\Tools\ARM_Compiler_5\5.0.4.82\bin64\
armlink.exe $LINK_FLAGS  --via=$RSP_FILE -o $TARGET_FILE && $POST_BUILD"
  description = Linking C executable $TARGET_FILE
  rspfile = $RSP_FILE
  rspfile_content = $in_newline $LINK_PATH $LINK_LIBRARIES
  restat = $RESTAT


--------------------------------------------
toolchain.cmake:
SET( CMAKE_SYSTEM_NAME Generic )

# specify the cross compiler
SET( CMAKE_C_COMPILER "c:/Tools/ARM_Compiler_5/5.0.4.82/bin64/armcc.exe" )
SET( CMAKE_CXX_COMPILER "c:/Tools/ARM_Compiler_5/5.0.4.82/bin64/armcc.exe" )

#Disable some CMake checks - may be useful when updating the environment
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)

#skip ABI checks
SET (CMAKE_DETERMINE_C_ABI_COMPILED 1)
SET (CMAKE_DETERMINE_CXX_ABI_COMPILED 1)
SET (CMAKE_DETERMINE_ASM_ABI_COMPILED 1)

# where is the target environment
SET( CMAKE_FIND_ROOT_PATH "c:/Tools/ARM_Compiler_5/5.0.4.82" )

# search for programs in the build host directories
SET( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )

# for libraries and headers in the target directories
SET( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
SET( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

#Too long commandline in Windows (benefit in Linux too)
SET( CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1 )
SET( CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1 )

SET( CMAKE_ASM_COMPILER "c:/Tools/ARM_Compiler_5/5.0.4.82/bin64/armasm.exe"
)

SET( CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> <DEFINES> <FLAGS> -
o <OBJECT>" )

SET( CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <LINK_LIBRARIES> <OBJE
CTS> -o <TARGET>" )

SET( CMAKE_C_RESPONSE_FILE_LINK_FLAG "--via=" )

SET( CMAKE_DEPFILE_FLAGS_ASM "--depend=<OBJECT>.d --depend_format=unix" )

SET( CMAKE_DEPFILE_FLAGS_C "--depend=<OBJECT>.d --depend_format=unix --depend_si
ngle_line" )


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: No RSP_FILE if generating in a path that contains "@"

Gerhard Olsson
Some attempts, trying to decipher the Ninja generator code.

I believe the core problem is in IsIdentChar() that do not recognize '@' (as well as =,% and others?). The Ninja generator then uses EncodeIdent() to encode the filenames like $identNN. This would be OK if not the command line length calculation calculated the length of without expansion, which happens to be below 8192 bytes on Windows(CMD limitation). The problem is therefore not related to ARMCC (other compilers worked, the command line were longer than 8192 still).

A response file should be used if the command is considered longer than the limit but operates on arguments after encoding (need to get the expanded size).


--
It is possible to force response files
SET( CMAKE_NINJA_FORCE_RESPONSE_FILE 1 )

There are two problems with this approach:
 * The file flag is incorrect, the following variables are not picked up:
SET( CMAKE_C_RESPONSE_FILE_FLAG "--via=" )
SET( CMAKE_ASM_RESPONSE_FILE_FLAG "--via=" )

 * The contents in the response file includes definitions (hardcoded in Ninja generator), should not be included for armasm
no <DEFINES> in:
set(CMAKE_ASM_COMPILE_OBJECT       "<CMAKE_ASM_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")

--
Patching the generated Ninja files seem to be the easiest way forward.


/Gerhard

2018-06-05 16:31 GMT+02:00 Gerhard Olsson <[hidden email]>:
The following occurs with CMake on Windows, crosscompiling with ARMCC.

If the path contains "@", CMake ignores response file in the toolchain file:
SET( CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1 ) 

 The linker command is too long and fails.

The command is run in Jenkins, I have not seen a way to avoid generating @ in the path
A workaround could be to patch rules.ninja to add the rsp_file handling if missing.

Any configuration changes that resolves the problem?
Any hints how to debug and fix CMake for this?

/Gerhard


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake