View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015439CMakeCMakepublic2015-03-10 16:542015-11-02 09:15
ReporterThomas Herz 
Assigned ToBrad King 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformWin32OSWindowsOS VersionWindows 7
Product VersionCMake 3.2 
Target VersionCMake 3.3Fixed in VersionCMake 3.3 
Summary0015439: ninja: no possibility to control type of path delimiter and line break for linker response file
DescriptionI'm working with the Windriver VxWorks GNU tool chain on Windows host.
   Compiler Version: ccpentium.exe (Wind River VxWorks G++ DWARF-EH 4.1-131) 4.1.2
    --host=i686-mingw32
    --target=i586-wrs-vxworks

I adapted our existing 'unix makefile' project to ninja builder and I'm getting following linker error:

   @CMakeFiles/myLib.rsp: No such file or directory

Finally, I figured out the reason. Actually, there are two of them:

1) The linker response file uses '\' for path delimiters, but this version of GCC can't handle them, even if it is running on Windows host.
It only handles '/' or '\\' correctly. I managed to work around this problem by setting 'CMAKE_COMPILER_IS_MINGW' to '1'. But, I guess, this may have some unwanted side effects. Related bug report: 0015278

2) The linker response file uses Windows style line-breaks (CR-LF) to separate individual object paths. This version of GCC can't handle them. It works fine with Unix style (LF) or without any line breaks and whitespace instead.
The behaviour of ninja generator was changed with commit a55d5ca48179d3be4d8406028c0992d45ada8882. I think, this patch is too 'global'.
According to commit message 'Avoid LNK1170 linker error' this commit should solve Microsoft compiler/linker problems. Furthermore LNK1170 is not listed anymore for VS2010 and above.

Anyhow, for both issues, some kind of automagic with the possibility to change the automagic decision with a particular cmake-variable would be the best solution for such kind of problems.

Tagsbackslash, CMake, linefeed, ninja
Attached Filespatch file icon 0001-Use-always-forward-slashes-in-response-files-when-co.patch [^] (3,080 bytes) 2015-05-07 03:59 [Show Content]
patch file icon 0002-Do-not-use-newlines-in-response-files-when-compiling.patch [^] (1,163 bytes) 2015-05-07 03:59 [Show Content]
patch file icon 0001-ninja-Replaced-last-left-MinGW-check-with-GCCOnWindo.patch [^] (934 bytes) 2015-05-08 10:25 [Show Content]

 Relationships
related to 0015278closed Ninja generator breaks when creating archives with GNU 'ar' in Windows 

  Notes
(0038471)
Brad King (manager)
2015-04-07 16:01

For problem (1), here is a trace back of how CMake decides which kind of slash to use:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalNinjaGenerator.cxx;hb=v3.2.1#l94 [^]
 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalNinjaGenerator.cxx;hb=v3.2.1#l538 [^]
 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeDetermineCCompiler.cmake;hb=v3.2.1#l114 [^]
 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakePlatformId.h.in;hb=v3.2.1#l8 [^]

The "CMAKE_COMPILER_IS_MINGW" variable is an ancient value that pre-dates proper compiler id logic. The Ninja generator should probably learn to make its choice of slash direction based on something else.

For problem (2), the $in_newline was added to produce nicer response files. It is Ninja that actually generates the response files:

 http://martine.github.io/ninja/manual.html#ref_rule [^]

so it is Ninja that would have to be taught what kind of newline to use to fix this.
(0038724)
Thomas Herz (reporter)
2015-05-07 03:58

Brad, sorry for late response.

The code spots you mentioned are mostly the ones I fixed in my local branch. See my attached patch files. Take them as a proposal or inspiration...

In fact, neither CMake nor Ninja has really a bug. The problem is the ancient GNU cross-toolchain we use. We cannot fix this, though so we patched CMake here to get it working.

For the second problem: It was more easy to do this in CMake because CMake has all necessary knowledge to handle it correctly.
The former patch was mainly done for MSVC linker, which tells Ninja manual as well. I guess, it was working before in all environments without newlines except with MSVC.
(0038728)
Brad King (manager)
2015-05-07 15:11

Thanks for the patches. I did some cleanup:

 RC: Simplify selection of resource compiler based on C/C++ toolchain
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=957c2aac [^]

 Ninja: Refactor detection of MinGW tools on Windows
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=378c2a0e [^]

and then applied changes based on the patches:

 Ninja: Use forward slashes for any GCC on Windows
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3de0dfe [^]

 Ninja: Do not use newlines in response files with Windows GNU tools
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=20560e8d [^]

Please try it out as of that last commit.
(0038734)
Brad King (manager)
2015-05-08 09:38

The changes linked in 0015439:0038728 passed nightly testing. I'm marking this resolved. Please comment with the results of testing for your use case.
(0038737)
Thomas Herz (reporter)
2015-05-08 10:30

Brad,
I tested your changes. It looks fine except one thing: I missed one code-change in my previous patch-files. See my additionally attached patch-file for this (last) change. With this change the complete response file is created with forward slashes and without line feeds.
(0038738)
Brad King (manager)
2015-05-08 11:22

Re 0015439:0038737: Thanks. Applied:

 Ninja: Use forward slashes for linking with any GCC on Windows
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca658a45 [^]
(0039807)
Robert Maynard (manager)
2015-11-02 09:15

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-03-10 16:54 Thomas Herz New Issue
2015-03-11 05:21 Thomas Herz Tag Attached: backslash
2015-03-11 05:21 Thomas Herz Tag Attached: CMake
2015-03-11 05:21 Thomas Herz Tag Attached: linefeed
2015-03-11 05:21 Thomas Herz Tag Attached: ninja
2015-03-11 08:27 Brad King Relationship added related to 0015278
2015-04-07 16:01 Brad King Note Added: 0038471
2015-05-07 03:58 Thomas Herz Note Added: 0038724
2015-05-07 03:59 Thomas Herz File Added: 0001-Use-always-forward-slashes-in-response-files-when-co.patch
2015-05-07 03:59 Thomas Herz File Added: 0002-Do-not-use-newlines-in-response-files-when-compiling.patch
2015-05-07 15:11 Brad King Note Added: 0038728
2015-05-07 15:12 Brad King Assigned To => Brad King
2015-05-07 15:12 Brad King Status new => assigned
2015-05-07 15:12 Brad King Target Version => CMake 3.3
2015-05-08 09:38 Brad King Note Added: 0038734
2015-05-08 09:38 Brad King Status assigned => resolved
2015-05-08 09:38 Brad King Resolution open => fixed
2015-05-08 09:38 Brad King Fixed in Version => CMake 3.3
2015-05-08 10:25 Thomas Herz File Added: 0001-ninja-Replaced-last-left-MinGW-check-with-GCCOnWindo.patch
2015-05-08 10:30 Thomas Herz Note Added: 0038737
2015-05-08 11:22 Brad King Note Added: 0038738
2015-11-02 09:15 Robert Maynard Note Added: 0039807
2015-11-02 09:15 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team