[cmake-developers] ctest not detecting error when clang fails to link

Alexandru Ciobanu alex at rogue-research.com
Thu Mar 8 18:55:16 EST 2012


Hi Brad,

I investigated this issue a bit more. I have two conclusions.

[1]
Clang generates clear error messages, and ctest detects such errors without problem. These errors look like this:
   ld: library not found for -lkaboom
   clang: error: linker command failed with exit code 1 (use -v to see invocation)

So the problem is not clang itself.

[2]
The problem is caused by Xcode that intercepts these type of errors, and instead of printing the original message,  prints something like:
   Command /Developer/usr/bin/clang++ failed with exit code 1

This type of error is not detected by ctest. This is a problem for those who invoke xcodebuild in their ctest scripts, e.g.
    ctest -S BuildMyXcodeProjectAndSendResultsToDashboard.cmake

I created and attached a patch that adds a regexp to match this type of errors. It is based on 36ce6e01f8a1e7f2bdb5604c7776a4a91fa36400.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctest.add.error.regex.patch
Type: application/octet-stream
Size: 770 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120308/bbde6e82/attachment-0002.obj>
-------------- next part --------------


sincerely,
Alex Ciobanu


On 2012-03-08, at 3:38 PM, Brad King wrote:

> On 3/8/2012 3:34 PM, Alexandru Ciobanu wrote:
>> We found a scenario when when ctest does not detect a build error.
>> 
>> This occurs when clang is invoked as a linker and one of the libraries is not found:
>> 
>>     /Developer/usr/bin/clang++ -LDIR1 -LDIR2  -lib1 -lib2 -lib3 [...] -o MyApp
>>     ld: library not found for -lprofile_rt
>>     Command /Developer/usr/bin/clang++ failed with exit code 1
>> 
>> The two lines printed after this invocation are not matched by any of the regular expressions defined in Source/CTest/cmCTestBuildHandler.cxx
>> 
>> So, in our case, we have an incomplete build, and the error is not reported to the dashboard.
>> 
>> I think lines matching "clang\+* failed with exit code" should be considered errors and reported as such.
> 
> Yes.  Please format a patch for cmCTestBuildHandler.cxx to update
> cmCTestErrorMatches accordingly.
> 
> Meanwhile you can probably work around this by adding the regex to
> CTEST_CUSTOM_ERROR_MATCH in CTestCustom at the top of the project.
> 
> Alternatively you should be able to run the dashboards with the
> CTEST_USE_LAUNCHERS option.  For Makefile builds it instruments
> the compiler and linker invocations and checks the return code
> and looks at output on stderr.
> 
> -Brad



More information about the cmake-developers mailing list