[cmake-developers] [CMake 0015729]: ninja: TARGET_OBJECTS not working, ObjectDirectory and ObjectPathMax used before they are set

Mantis Bug Tracker mantis at public.kitware.com
Sun Sep 6 04:36:23 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=15729 
====================================================================== 
Reported By:                Stefan Bühler
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15729
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-09-06 04:36 EDT
Last Modified:              2015-09-06 04:36 EDT
====================================================================== 
Summary:                    ninja: TARGET_OBJECTS not working, ObjectDirectory
and ObjectPathMax used before they are set
Description: 
I converted a project to Qt5, and TARGET_OBJECTS are not working across
directories anymore with ninja; traditional make is still working.

I pulled cmake from git (master 9e64fda6a77b49b394835dadba0e2951580eb86b), and
got even stranger errors (but not everytime) that CMAKE_OBJECT_PATH_MAX was 0
and the "Object file ... cannot be safely placed under this directory.".

I added some debugging and got a backtrace like this:

https://public.kitware.com/Bug/view.php?id=0 
cmLocalGenerator::CreateSafeUniqueObjectFileName (this=0x12f2010, sin=...,
dir_max=...) at ../Source/cmLocalGenerator.cxx:2660
https://public.kitware.com/Bug/view.php?id=1  0x0000000000aeab84 in
cmLocalGenerator::GetObjectFileNameWithoutTarget (this=0x12f2010, source=...,
dir_max=..., hasSourceExtension=0x0) at ../Source/cmLocalGenerator.cxx:2810
https://public.kitware.com/Bug/view.php?id=2  0x00000000009223a5 in
cmLocalNinjaGenerator::ComputeObjectFilenames (this=0x12f2010, mapping=...,
gt=0x13ea920) at ../Source/cmLocalNinjaGenerator.cxx:269
https://public.kitware.com/Bug/view.php?id=3  0x0000000000a5ddec in
cmGeneratorTarget::GetObjectSources (this=0x13ea920, data=..., config=...) at
../Source/cmGeneratorTarget.cxx:480
https://public.kitware.com/Bug/view.php?id=4  0x0000000000a4b820 in
TargetObjectsNode::Evaluate (this=0xfdd3c0 <targetObjectsNode>, parameters=...,
context=0x7fffffffb010, content=0x131d850) at
../Source/cmGeneratorExpressionNode.cxx:1285
https://public.kitware.com/Bug/view.php?id=5  0x0000000000a413f6 in
GeneratorExpressionContent::Evaluate[abi:cxx11](cmGeneratorExpressionContext*,
cmGeneratorExpressionDAGChecker*) const (this=0x131d850, context=0x7fffffffb010,
dagChecker=0x7fffffffb720) at ../Source/cmGeneratorExpressionEvaluator.cxx:154
https://public.kitware.com/Bug/view.php?id=6  0x0000000000a5856c in
cmCompiledGeneratorExpression::EvaluateWithContext (this=0x132cff0, context=...,
dagChecker=0x7fffffffb720) at ../Source/cmGeneratorExpression.cxx:101
https://public.kitware.com/Bug/view.php?id=7  0x0000000000a58474 in
cmCompiledGeneratorExpression::Evaluate (this=0x132cff0, mf=0x130f300,
config=..., quiet=false, headTarget=0x1333028, currentTarget=0x1333028,
dagChecker=0x7fffffffb720, language=...) at
../Source/cmGeneratorExpression.cxx:79
https://public.kitware.com/Bug/view.php?id=8  0x00000000008d140d in
processSources (tgt=0x1333028, entries=..., srcs=..., uniqueSrcs=...,
dagChecker=0x7fffffffb720, config=..., debugSources=false) at
../Source/cmTarget.cxx:557
https://public.kitware.com/Bug/view.php?id=9  0x00000000008d21b7 in
cmTarget::GetSourceFiles (this=0x1333028, files=..., config=...) at
../Source/cmTarget.cxx:700
https://public.kitware.com/Bug/view.php?id=10 0x00000000008d25e8 in
cmTarget::GetSourceFiles (this=0x1333028, files=..., config=...) at
../Source/cmTarget.cxx:750
https://public.kitware.com/Bug/view.php?id=11 0x0000000000a70b8a in
cmGeneratorTarget::GetConfigCommonSourceFiles (this=0x13f0240, files=...) at
../Source/cmGeneratorTarget.cxx:4431
https://public.kitware.com/Bug/view.php?id=12 0x0000000000888ecd in
cmQtAutoGenerators::InitializeAutogenTarget (this=0x7fffffffc6d0, lg=0x1312970,
target=0x1333028) at ../Source/cmQtAutoGenerators.cxx:408
https://public.kitware.com/Bug/view.php?id=13 0x0000000000a99924 in
cmGlobalGenerator::CreateQtAutoGeneratorsTargets (this=0x101ad40, autogens=...)
at ../Source/cmGlobalGenerator.cxx:1465
https://public.kitware.com/Bug/view.php?id=14 0x0000000000a986c3 in
cmGlobalGenerator::Compute (this=0x101ad40) at
../Source/cmGlobalGenerator.cxx:1272
https://public.kitware.com/Bug/view.php?id=15 0x0000000000900927 in
cmake::Generate (this=0x7fffffffd7f0) at ../Source/cmake.cxx:1770
https://public.kitware.com/Bug/view.php?id=16 0x0000000000900783 in cmake::Run
(this=0x7fffffffd7f0, args=..., noconfigure=false) at ../Source/cmake.cxx:1757
https://public.kitware.com/Bug/view.php?id=17 0x00000000008197d5 in do_cmake
(ac=4, av=0x10111f0) at ../Source/cmakemain.cxx:330
https://public.kitware.com/Bug/view.php?id=18 0x0000000000818d8a in main (ac=4,
av=0x10111f0) at ../Source/cmakemain.cxx:190

CreateQtAutoGeneratorsTargets gets called before ComputeObjectMaxPath in
cmGlobalGenerator::Compute, and ObjectPathMax is not initialized, i.e. has a
random value at that point (for me 0 or 1).

Also it turned out gt->ObjectDirectory is empty when TargetObjectsNode::Evaluate
is called in a similar backtrace from CreateQtAutoGeneratorsTargets, which is
why newer cmake version can't find the object files (older cmake versions simply
drop the object, leading to undefined symbols during linking).

Moving the call to CreateQtAutoGeneratorsTargets below InitGeneratorTargets
fixes it; calling ComputeTargetObjectDirectory and ComputeObjectMaxPath on
demand and initializing ObjectPathMax to 0 fixes it too.

Steps to Reproduce: 
git clone -b v0.6.0 https://github.com/dosnut/nut
cd nut
mkdir build
cd build
cmake -G Ninja ..
ninja cnut

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-09-06 04:36 Stefan Bühler  New Issue                                    
======================================================================



More information about the cmake-developers mailing list