[cmake-developers] CheckSymbolExists is unreliable

Rolf Eike Beer eike at sf-mail.de
Mon Jan 2 17:24:09 EST 2012


In case anyone has a deja-vu: yes, it's true. This problem came up when I 
tried to fix bug 11333. Once a fix for that was out a user found out that his 
pthreads library was no longer detected. The root cause for this is that the 
CheckSymbolExists and CheckCXXSymbolExists macros do not work if you use 
gcc/g++ and -O3.

It looks like gcc simply optimizes out any reference to the tested symbol. 
Given the fact that we don't really ever use that symbol anywhere it is even 
correct to do so. Just that this is not what we want.

I pushed a topic test-symbol-exists to stage that verifies that this is indeed 
a problem in Check{,CXX}SymbolExists, it iterates through all build 
configurations (were this problem does _not_ happen) and later explicitely 
adds a -O3 test if it is gcc/g++ which then _does_ fail.

So, there are 3 points that I need advise:

-what should happen with this topic? Should I merge it to next? Then we will 
get a ton of failures on at least everything that is using GNU compilers.

-which other compilers can be tested this way, I mean using -O3? From what I 
know Clang does understand this and even -O4, what is about the Intel one?

-how  to fix this thing at the end? I was thinking about just doing

#include <stdio.h>
printf("%s is at %p\n", ${SYMBOL}, &${SYMBOL}));

Is anyone aware of some place where this wouldn't work? Or should I just put 
this in and try out?

Greetings,

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120102/230d66e4/attachment.sig>


More information about the cmake-developers mailing list