[cmake-developers] linked-usage-cleanup regressed automoc
Alexander Neundorf
neundorf at kde.org
Mon Mar 11 17:15:33 EDT 2013
Hi,
On Wednesday 20 February 2013, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > On Wednesday 20 February 2013, Stephen Kelly wrote:
> >> Brad King wrote:
> >> > Please fix and add this case to the tests.
> >>
> >> I've added fix-automoc-linker-language to stage. Alex, could you review
> >> please?
> >
> > If I see it correctly, actually nothing is done to each target between
> > the calls to InitializeMocSourceFile() and the following
> > SetupAutomocTarget(). So instead of running two loops over the targets,
> > shouldn't it be enough to add the source file to the target early on in
> > SetupAutomocTarget(), e.g. before the call to AddUtilityCommand() ?
>
> I tried that too, but the problem is that if two different targets are
> dependent, it seems that the link closure is calculated and cached for the
> dependent target before it gets its source file set.
>
> There are a few ways to deal with that, but I went with this one.
>
> I'll merge it soon. Thanks for reviewing.
Unfortunately this patch creates bug (
http://public.kitware.com/Bug/view.php?id=13999 ) and doesn't fix the actual
problem, the crash is still there.
Before this patch, void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
returned early if no Qt was present, and nothing bad happened in this case.
With this patch, the <target>_automoc.cpp file is added to every target.
Probably this fixes the original problem because now the target
"no_link_language" has a link language, due to its newly attached source file
no_link_language_automoc.cpp.
It then crashes:
CMake Error: CMake can not determine linker language for
target:no_link_language
Program received signal SIGSEGV, Segmentation fault.
0x082d55a3 in std::vector<cmComputeLinkInformation::Item,
std::allocator<cmComputeLinkInformation::Item> >::begin() const ()
(gdb) bt
#0 0x082d55a3 in std::vector<cmComputeLinkInformation::Item,
std::allocator<cmComputeLinkInformation::Item> >::begin() const ()
#1 0x082cc76d in isLinkDependentProperty(cmTarget*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, char const*, char
const*) ()
#2 0x082cc98d in
cmTarget::IsLinkInterfaceDependentBoolProperty(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, char const*) ()
#3 0x083d9b8c in
TargetPropertyNode::Evaluate(std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > const&, cmGeneratorExpressionContext*,
GeneratorExpressionContent const*, cmGeneratorExpressionDAGChecker*) const ()
#4 0x083d6b53 in
GeneratorExpressionContent::Evaluate(cmGeneratorExpressionContext*,
cmGeneratorExpressionDAGChecker*) const ()
#5 0x083de544 in cmCompiledGeneratorExpression::Evaluate(cmMakefile*, char
const*, bool, cmTarget*, cmTarget*, cmGeneratorExpressionDAGChecker*) const ()
#6 0x083de438 in cmCompiledGeneratorExpression::Evaluate(cmMakefile*, char
const*, bool, cmTarget*, cmGeneratorExpressionDAGChecker*) const ()
#7 0x082c4cc1 in processIncludeDirectories(cmTarget*,
std::vector<cmTargetInternals::IncludeDirectoriesEntry*,
std::allocator<cmTargetInternals::IncludeDirectoriesEntry*> > const&,
std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&,
std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char>
>, std::less<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&,
cmGeneratorExpressionDAGChecker*, char const*, bool) ()
#8 0x082c5895 in cmTarget::GetIncludeDirectories(char const*) ()
#9 0x083e0e86 in cmGeneratorTarget::GetIncludeDirectories(char const*) ()
#10 0x08413808 in
cmLocalGenerator::GetIncludeDirectories(std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >&, cmGeneratorTarget*, char const*, char const*,
bool) ()
#11 0x0844b611 in cmQtAutomoc::SetupAutomocTarget(cmTarget*) ()
#12 0x083e66fe in cmGlobalGenerator::CreateAutomocTargets() ()
#13 0x083e5e7f in cmGlobalGenerator::Generate() ()
#14 0x083f8ffe in cmGlobalUnixMakefileGenerator3::Generate() ()
#15 0x082f0cbe in cmake::Generate() ()
#16 0x082f0b01 in cmake::Run(std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > const&, bool) ()
#17 0x08257b41 in do_cmake(int, char**) ()
#18 0x08257099 in main ()
(gdb)
(this is again the backtrace from the earlier, unmodified version).
I think instead of avoiding the case where the code crashes, it should not
crash.
I pushed the branch AutomocFixWithoutQt to stage.
It mostly reverts the previous change.
Additionally it adds a test for the case that there is no Qt, and it adds
handling for the case that a target does not contain any C++ files (it now
does nothing).
The crash can be also reproduced with the attached example, completely without
Qt and/or automoc.
If you want I can enter a ticket for that.
Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no_link_lang_crash.tar.gz
Type: application/x-compressed-tar
Size: 391 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20130311/d87007f1/attachment-0002.bin>
More information about the cmake-developers
mailing list