MantisBT - CMake
View Issue Details
0015457CMake(No Category)public2015-03-18 14:372015-11-02 09:13
Reid Kleckner 
Brad King 
normalminorhave not tried
closedno change required 
Windows7
CMake 3.2.1 
 
0015457: ninja generator relinks all executables after incremental build in LLVM due to extra .lib output file
Old versions of cmake would generate this ninja target:
build bin\opt.exe: CXX_EXECUTABLE_LINKER ...

Recent versions (3.2+) generate this target:
build bin\opt.exe lib\opt.lib: CXX_EXECUTABLE_LINKER_RSP_FILE

Since this is an executable, no .lib file should be generated, right? Why does the linker build rule even list the /implib flag? Maybe this is some functionality I'm unaware of, but so far as I can tell it is extraneous.
No tags attached.
Issue History
2015-03-18 14:37Reid KlecknerNew Issue
2015-03-18 14:48Reid KlecknerNote Added: 0038240
2015-03-18 15:01Brad KingAssigned To => Brad King
2015-03-18 15:01Brad KingStatusnew => assigned
2015-03-18 15:01Brad KingTarget Version => CMake 3.3
2015-03-18 15:07Brad KingNote Added: 0038241
2015-03-18 15:38Reid KlecknerNote Added: 0038244
2015-03-18 15:45Brad KingNote Added: 0038245
2015-03-18 15:51Reid KlecknerNote Added: 0038246
2015-03-18 15:56Brad KingNote Added: 0038247
2015-03-18 15:56Brad KingStatusassigned => resolved
2015-03-18 15:56Brad KingResolutionopen => no change required
2015-03-18 15:56Brad KingTarget VersionCMake 3.3 =>
2015-11-02 09:13Robert MaynardNote Added: 0039737
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038240)
Reid Kleckner   
2015-03-18 14:48   
Locally reverting ef42e57d470db499a41c8bca695391c3e3e5cb86 fixes my problem, FWIW.
(0038241)
Brad King   
2015-03-18 15:07   
Commit ef42e57d4 switched to using proper ninja build rule syntax for rules with multiple outputs. The import library is added for DLLs but also for executables with the ENABLE_EXPORTS property set. See use of cmTarget::HasImportLibrary:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmNinjaNormalTargetGenerator.cxx;hb=v3.2.1#l532 [^]
 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmTarget.cxx;hb=v3.2.1#l585 [^]

Executable targets may set ENABLE_EXPORTS in order to really dllexport some symbols and provide an import library that plugins can link.

In llvm:

$ git grep ENABLE_EXPORTS -- tools
tools/bugpoint/CMakeLists.txt:set_target_properties(bugpoint PROPERTIES ENABLE_EXPORTS 1)
tools/llc/CMakeLists.txt:set_target_properties(llc PROPERTIES ENABLE_EXPORTS 1)
tools/lli/CMakeLists.txt:set_target_properties(lli PROPERTIES ENABLE_EXPORTS 1)
tools/llvm-stress/CMakeLists.txt:set_target_properties(llvm-stress PROPERTIES ENABLE_EXPORTS 1)
tools/opt/CMakeLists.txt:set_target_properties(opt PROPERTIES ENABLE_EXPORTS 1)
(0038244)
Reid Kleckner   
2015-03-18 15:38   
Huh, seems reasonable, but it seems like the linker command isn't generating any .lib anywhere.
(0038245)
Brad King   
2015-03-18 15:45   
Re 0015457:0038244: In order to produce the .lib then some of the executable's object files must have dllexport markup or a module definition file (.def) must be among the sources. It is the project's responsibility to do this or to not set ENABLE_EXPORTS (at least on Windows).
(0038246)
Reid Kleckner   
2015-03-18 15:51   
Sounds right. I have a feeling this stuff was hacked up to work with binutils ld –-export-all-symbols, and not MSVC. We can fix this in LLVM then.
(0038247)
Brad King   
2015-03-18 15:56   
Okay, thanks.
(0039737)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.