MantisBT - CMake
View Issue Details
0014577CMakeCMakepublic2013-11-18 03:322014-10-06 10:32
Soeren Textor 
Brad King 
urgentmajoralways
closedfixed 
PCWindows7 x64
CMake 2.8.12 
CMake 3.0CMake 3.0 
0014577: Need to map /Fd to ProgramDataBaseFileName in VS 7,8,9
Since 2.8.12.0 there is no more

<ProgramDataBaseFileName>/MyBinPath/dev/$(Configuration)/MtuX.pdb</ProgramDataBaseFileName>

inside

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

in the generated visual studio files.

Thus it falls back to the default what is

$(IntDir)vc$(PlatformToolsetVersion).pdb

for VS 2012 and it's not the same...
Just build a VS2012 project and open the vcxproj file.
You won't find any and <ProgramDataBaseFileName>.

We added the /Zi compilerflag before (for vs projects)
-
No tags attached.
related to 0011899closed Brad King Put compiler's program database files into intermediate directory rather than output one for VS 2005 
related to 0014062closed Brad King Setting Compiler and Linker PDB to the same path in Visual Studio is unsupported. 
related to 0014600closed Brad King Document PDB behavior w.r.t. static libraries 
related to 0014763closed Brad King Add target properties to specify MS compiler PDB files 
patch 0001-VS-Map-Fd-to-ProgramDataBaseFileName-for-VS-7-8-9-14.patch (1,329) 2013-11-18 11:49
https://public.kitware.com/Bug/file/4953/0001-VS-Map-Fd-to-ProgramDataBaseFileName-for-VS-7-8-9-14.patch
Issue History
2013-11-18 03:32Soeren TextorNew Issue
2013-11-18 08:35Brad KingRelationship addedrelated to 0011899
2013-11-18 08:35Brad KingRelationship addedrelated to 0014062
2013-11-18 08:36Brad KingNote Added: 0034458
2013-11-18 10:37Mats ForsNote Added: 0034464
2013-11-18 10:46Mats ForsNote Edited: 0034464bug_revision_view_page.php?bugnote_id=34464#r1316
2013-11-18 10:47Brad KingNote Added: 0034466
2013-11-18 10:53Brad KingNote Added: 0034467
2013-11-18 10:57Mats ForsNote Added: 0034468
2013-11-18 11:28Brad KingNote Added: 0034470
2013-11-18 11:49Brad KingFile Added: 0001-VS-Map-Fd-to-ProgramDataBaseFileName-for-VS-7-8-9-14.patch
2013-11-18 11:50Brad KingNote Added: 0034473
2013-11-19 04:03Soeren TextorNote Added: 0034476
2013-11-19 08:53Brad KingNote Added: 0034478
2013-11-19 08:54Brad KingAssigned To => Brad King
2013-11-19 08:54Brad KingStatusnew => resolved
2013-11-19 08:54Brad KingResolutionopen => fixed
2013-11-19 08:54Brad KingFixed in Version => CMake 3.0
2013-11-19 08:54Brad KingTarget Version => CMake 3.0
2013-11-19 08:54Brad KingSummary<ProgramDataBaseFileName> tag is missing in VS XXXX vc(x)proj files since 2.8.12.x => Need to map /Fd to ProgramDataBaseFileName in VS 7,8,9
2013-11-27 10:31Brad KingRelationship addedrelated to 0014600
2014-02-18 09:59Brad KingRelationship addedrelated to 0014763
2014-02-26 09:44Brad KingNote Added: 0035209
2014-10-06 10:32Robert MaynardNote Added: 0036917
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0034458)
Brad King   
2013-11-18 08:36   
As reported in 0014062 setting the compiler's PDB file to the same as the linker's is incorrect. This was fixed here:

 VS: Separate compiler and linker PDB files
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42ba1b08 [^]
(0034464)
Mats Fors   
2013-11-18 10:37   
(edited on: 2013-11-18 10:46)
A use case that has been missed in the discussion about pdb files is that they can be used to contain debug info for a static library. That succinctly is linked into an executable later on. The linker will then use the debug info from the pdb file for the library to build a pdb file for the executable.

Each object file in the library contains an absolute path to its pdb file. The linker will search that path and use that pdb file, if found. Else, if not found, it will look if there is a pdb file, with the name used in the absolute path, in the directory the library resides in.

This worked in cmake until the ProgramDataBaseFileName got decopuled. A remedy would be to allow the compiler /Fd option to set it.

(0034466)
Brad King   
2013-11-18 10:47   
Re 0014577:0034464: I brought static libraries up in 0014062:0032761 and the response was 0014062:0032762. The interaction of pdb files and static libraries has been a source of disagreement and confusion for everyone. The two issues I linked from here are not the only ones. You can follow the issue relationships back further from those linked here. The reporter of 0008060:0014062 was the first to cite actual MS documentation on the issue (and a response from MS), so I went with that recommendation.

If "Each object file in the library contains an absolute path to its pdb file" then why can't the linker collect debug symbols from wherever cl puts them?
(0034467)
Brad King   
2013-11-18 10:53   
With 2.8.12.1, adding /Fd to the compile flags should map to ProgramDataBaseFileName in the .vcxproj file:

http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmVS12CLFlagTable.h;hb=v2.8.12.1#l287 [^]

However, with any Makefile generator with MSVC tools use of /Fd is hard-coded:

http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Windows-MSVC.cmake;hb=v2.8.12.1#l234 [^]

so one would have to modify the CMAKE_(C|CXX)_COMPILE_OBJECT rule explicitly to change the flag. This may work but it is an internal CMake variable so changing it in project code may not continue to work in future versions.
(0034468)
Mats Fors   
2013-11-18 10:57   
The absolute path to the pdb file in the object file doesn't necessarily point to the pdb file. Not, if the linkage of the executable is on another host that has another directory structure.

I tried 2.8.12.1 with the studio 2009 generator and I didn't get it to generate the ProgramDataBaseFileName from the /Fd compiler option. Will try one more time tomorrow.
(0034470)
Brad King   
2013-11-18 11:28   
Re 0014577:0034468: The /Fd mapping may only work for VS >= 10 (2010). It can be added for older versions if it does not work already.
(0034473)
Brad King   
2013-11-18 11:50   
Re 0014577:0034470: Try attached 0001-VS-Map-Fd-to-ProgramDataBaseFileName-for-VS-7-8-9-14.patch to enable the mapping on VS 7, 8, and 9.
(0034476)
Soeren Textor   
2013-11-19 04:03   
Thanks @all. The Link explaining the difference between linker and compiler pdb helps a lot. We just switched and are using the linker pdb only. That works fine for us...
(0034478)
Brad King   
2013-11-19 08:53   
Re 0014577:0034473: I've applied the patch:

 VS: Map /Fd to ProgramDataBaseFileName for VS 7,8,9
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bf1db496 [^]
(0035209)
Brad King   
2014-02-26 09:44   
See 0014763:0035208 for addition of support for COMPILE_PDB_NAME and COMPILE_PDB_OUTPUT_DIRECTORY properties to configure /Fd.
(0036917)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.