MantisBT - CMake
View Issue Details
0010913CMakeCMakepublic2010-06-30 04:462010-09-10 00:06
Ivar Gaitan 
Brad King 
normalminoralways
closedfixed 
CMake-2-8 
CMake 2.8.3CMake 2.8.3 
0010913: Try_compile fails when generating MinGW Makefiles
Response files (i.e. -Wl,@ option) in MinGW does not work with version 2.16 of ld.exe. When switching to ld.exe version 2.20, everything works ok.


Specifically, the following line fails:

C:\...\CMakeTmp>gcc.exe -Wl,@CMakeFiles\cmTryCompileExec.dir\objects1.rsp -o cmTryCompileExec.exe -Wl,--out-implib,libcmTryCompileExec.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
ld.exe: @CMakeFiles\cmTryCompileExec.dir\objects1.rsp: No such file: No such file or directory
collect2: ld returned 1 exit status
No tags attached.
Issue History
2010-06-30 04:46Ivar GaitanNew Issue
2010-06-30 04:51Ivar GaitanNote Added: 0021193
2010-07-13 09:22Bill HoffmanStatusnew => assigned
2010-07-13 09:22Bill HoffmanAssigned To => Brad King
2010-07-13 10:01Brad KingNote Added: 0021383
2010-08-05 10:11Ivar GaitanNote Added: 0021662
2010-08-05 10:32Brad KingNote Added: 0021664
2010-08-05 10:34Ivar GaitanNote Added: 0021665
2010-08-05 10:50Brad KingNote Added: 0021666
2010-08-06 05:58Ivar GaitanNote Added: 0021685
2010-08-06 09:42Brad KingNote Added: 0021686
2010-08-06 09:42Brad KingStatusassigned => closed
2010-08-06 09:42Brad KingResolutionopen => fixed
2010-09-10 00:06David ColeFixed in Version => CMake 2.8.3
2010-09-10 00:06David ColeTarget Version => CMake 2.8.3

Notes
(0021193)
Ivar Gaitan   
2010-06-30 04:51   
This is related to issue 0010401
(0021383)
Brad King   
2010-07-13 10:01   
What "--help" output does each version of ld provide? Does the output also appear through "gcc --help" or "gcc -v --help"? Perhaps we can detect whether the response file syntax is supported.
(0021662)
Ivar Gaitan   
2010-08-05 10:11   
With respect to '@FILE' they give identical outputs.

"gcc --help" doesn't mention it and "gcc -v --help" just echos the ld.exe help output.


======
C:\...\mingw\mingw32\bin>ld_2.16.exe --help
Usage: ld_2.16.exe [options] file...
Options:
  [...]
  @FILE Read options from FILE


C:\...\mingw\mingw32\bin>ld_2.20.exe --help
Usage: ld_2.20.exe [options] file...
Options:
  [...]
  @FILE Read options from FILE
(0021664)
Brad King   
2010-08-05 10:32   
So the ld 2.16 help says that the option is supported, but it does not work?
(0021665)
Ivar Gaitan   
2010-08-05 10:34   
Yes, just double checked.


C:\...\mingw\mingw32\bin>ld_2.16.exe -v
GNU ld version 2.16.91 20060119
(0021666)
Brad King   
2010-08-05 10:50   
Okay, take a look at Modules/Platform/Windows-GNU.cmake for the code

  set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
  set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@")

Try adding this:

  execute_process(
    COMMAND ld -v
    OUTPUT_VARIABLE _help
    ERROR_VARIABLE _help
    )
  if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]")
    set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 0)
  endif()
(0021685)
Ivar Gaitan   
2010-08-06 05:58   
That does the trick!
(0021686)
Brad King   
2010-08-06 09:42   
Great, thanks for testing it. I've published a similar fix:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b03f4ec0 [^]