View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013897CMakeCMakepublic2013-02-07 16:212016-06-10 14:31
ReporterEric Gross 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformWindows cross compiling to LinuxOSWindows OS Version7 x64
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0013897: Cross-compiling from Windows with a Linux-GCC toolchain exceeds max command line length during linking
DescriptionWhen compiling using GCC on Windows as a non-cross-compile, CMake has code in the platform files for using a response file to pass the objects to GCC's linker. When cross-compiling to a Linux toolchain, this workaround is not used. I was hitting this issue at around the 200-300 file count.

It seems that GCC supports the usage of response files across all OSes. Additionally, it seems that there are some cases that on certain Linux configurations (compiling natively) that they can run into the same issue as Windows. I believe CMake should use response files under the situation I am seeing (cross-compiling on Windows) and perhaps more universally.

Steps To ReproduceI cross-compiled the GenICam GenAPI reference implementation from Windows to an ARM/Linux target. GenApi's source includes components Xerces and Xalan, both which have hundreds of files and hit this error. The error shown is an unterminated string in sh.exe because the line is truncated.

Additional InformationTo work around this I added the following into the macro section of Linux-GNU.cmake (copied from the Windows version of that file):

    set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
    set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)


  # We prefer "@" for response files but it is not supported by gcc 3.
  execute_process(COMMAND ${CMAKE_${lang}_COMPILER} --version OUTPUT_VARIABLE _ver ERROR_VARIABLE _ver)
  if("${_ver}" MATCHES "\\(GCC\\) 3\\.")
    if("${lang}" STREQUAL "Fortran")
      # The GNU Fortran compiler reports an error:
      # no input files; unwilling to write output files
      # when the response file is passed with "-Wl,@".
      set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 0)
    else()
      # Use "-Wl,@" to pass the response file to the linker.
      set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@")
    endif()
    # The GNU 3.x compilers do not support response files (only linkers).
    set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0)
  elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS)
    # Use "@" to pass the response file to the front-end.
    set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@")
  endif()
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0032217)
Eric Gross (reporter)
2013-02-07 16:22

GenApi reference implementation (builds with CMake) is here: http://www.emva.org/cms/index.php?idcatart=76&client=1&lang=1 [^]
(0032223)
Brad King (manager)
2013-02-08 09:43

Rather than duplicating it between Platform/Linux-GNU.cmake and Platform/Windows-GNU.cmake, try putting it in Compiler/GNU.cmake in a relevant location.

I've never seen response files needed other than on Windows hosts. Perhaps the new block can be conditioned in if(WIN32).
(0032224)
Eric Gross (reporter)
2013-02-08 09:52

On some Unix environments, there are hard limits in argument length or limits due to stack space. Google seems to say that Linux <=2.6 had such limits. I think these restrictions are typically less of an issue than Windows, but I suspect you will still likely run into them on some platforms. If GCC supports response files across the board and CMake has common internally for using it, it seems like this functionality should be exposed in a manner that can be easily enabled when needed without having to modify your locally installed platform files. To me it might make sense to just always use them...
(0032227)
Eric Gross (reporter)
2013-02-08 11:12

Brad, how does CMake differentiate between the build platform and the target platform to be cross-compiled to? Wouldn't "If(WIN32)" not be true if I am cross-compiling to Linux?
(0032232)
Brad King (manager)
2013-02-08 13:56

Re 0013897:0032227: Right. Use the CMAKE_HOST_SYSTEM_NAME variable:

 http://www.cmake.org/cmake/help/v2.8.10/cmake.html#variable:CMAKE_HOST_SYSTEM_NAME [^]

if it is set and otherwise CMAKE_SYSTEM_NAME.
(0042219)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-02-07 16:21 Eric Gross New Issue
2013-02-07 16:22 Eric Gross Note Added: 0032217
2013-02-08 09:43 Brad King Note Added: 0032223
2013-02-08 09:52 Eric Gross Note Added: 0032224
2013-02-08 11:12 Eric Gross Note Added: 0032227
2013-02-08 13:56 Brad King Note Added: 0032232
2016-06-10 14:28 Kitware Robot Note Added: 0042219
2016-06-10 14:28 Kitware Robot Status new => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team