View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015596CMake(No Category)public2015-05-29 13:472016-02-01 09:10
ReporterReid Kleckner 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionCMake 3.4Fixed in VersionCMake 3.4 
Summary0015596: CMakeClDeps.cmake doesn't work if CC contains arguments
DescriptionI am attempting to do a 32-bit self-host of clang on Windows with a 64-bit clang-cl binary. By default, the 64-bit binary generates 64-bit code, so I need to pass the -m32 flag to override that. I figured the most robust way to do this is something like setting CC="clang-cl -m32" and running cmake.

This *almost* worked, but CMakeCLDeps.cmake runs CMAKE_C_COMPILER without the flags present in CC, and the link failed. It's regex then matched the error message from LINK, and I got this in rules.ninja:

msvc_deps_prefix = LINK : error LNK2001:

CMakeClDeps.cmake doesn't actually need to do a link, so one easy workaround would be to add /c to command line there. That's probably a good tweak in general, since it saves an invocation of link.exe, and cuts down on moving parts. :)

Aside from the workaround, is there a more canonical way that CMakeClDeps should be invoking the compiler that includes flags from the CC env var?
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0038823)
Brad King (manager)
2015-05-29 13:56

In general only the compiler should go in CC. The flags should go in CFLAGS.
(0038824)
Reid Kleckner (reporter)
2015-05-29 13:57

I attempted to use CC plus -DCMAKE_C_FLAGS, and this didn't seem to get everywhere it needed to go. Will CFLAGS fare any better?
(0038825)
Reid Kleckner (reporter)
2015-05-29 14:10

In any case, the same problem still exists. CMakeClDeps doesn't incorporate CFLAGS or CMAKE_C_FLAGS in any way, leading to a failed link.
(0038867)
Brad King (manager)
2015-06-01 09:50

For reference, cmcldeps is needed only for the MS resource compiler (rc) since this commit:

 Ninja: use deps = gcc/msvc feature
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eeb4aece [^]

I'm not particularly familiar with CMakeClDeps, but its activation in the MSVC_C_ARCHITECTURE_ID condition looks sub-optimal. I think some refactoring may be needed to clean this up.
(0038868)
Brad King (manager)
2015-06-01 09:52

Re 0015596:0038867: If use of CMakeClDeps is cleaned up to be enabled along with the resource compiler then it could use CMAKE_RC_COMPILER instead of CMAKE_C_COMPILER and not need the C flags to be carried through.
(0039440)
Brad King (manager)
2015-09-18 10:10

These commits should fix this:

 Ninja: Refactor lookup of cmcldeps location
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=828c05b9 [^]

 Ninja: Detect MSVC /showIncludes prefix with compiler flags
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=109a7a24 [^]
(0040413)
Robert Maynard (manager)
2016-02-01 09:10

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

 Issue History
Date Modified Username Field Change
2015-05-29 13:47 Reid Kleckner New Issue
2015-05-29 13:56 Brad King Note Added: 0038823
2015-05-29 13:57 Reid Kleckner Note Added: 0038824
2015-05-29 14:10 Reid Kleckner Note Added: 0038825
2015-06-01 09:50 Brad King Note Added: 0038867
2015-06-01 09:52 Brad King Note Added: 0038868
2015-09-18 09:59 Brad King Assigned To => Brad King
2015-09-18 09:59 Brad King Status new => assigned
2015-09-18 09:59 Brad King Target Version => CMake 3.4
2015-09-18 10:10 Brad King Note Added: 0039440
2015-09-21 09:19 Brad King Status assigned => resolved
2015-09-21 09:19 Brad King Resolution open => fixed
2015-09-21 09:19 Brad King Fixed in Version => CMake 3.4
2016-02-01 09:10 Robert Maynard Note Added: 0040413
2016-02-01 09:10 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team