[cmake-developers] Fwd: CheckSymbolExists.cmake

Christopher Sean Morrison brlcad at mac.com
Tue Jun 4 14:47:16 EDT 2013


See the below forwarded message for details on an issue with testing symbols that warrants discussion.  Eike patched CheckSymbolExists last year which changed it from primarily testing declaration to also enforcing linkage (and introducing a ISO C problem in the process).  Even if it fits the documented purpose, the method would still need changing due to the error.  However, the previous form ((void)symbol;) seemed ideal.  Moreover, the optimization/linkage issue that motivated the patch is already covered by CHECK_FUNCTION_EXISTS.

The docs do seem a little vague on the difference between CHECK_FUNCTION_EXISTS, CHECK_SYMBOL_EXISTS, and CHECK_PROTOTYPE_EXISTS in terms of what it means to "exist".

Cheers!
Sean

p.s. CHECK_PROTOTYPE_EXISTS is practically useless as written.  I'd submit a patch to fix it, but the fix would look nearly identical to what CHECK_SYMBOL_EXISTS used to test. 

 

Begin forwarded message:

> From: Rolf Eike Beer <eike at sf-mail.de>
> Date: June 4, 2013 12:54:05 PM EDT
> To: Christopher Sean Morrison <brlcad at mac.com>
> Subject: Re: CheckSymbolExists.cmake
> 
> Am Dienstag, 4. Juni 2013, 01:27:50 schrieb Christopher Sean Morrison:
>> Rolf,
>> 
>> Your commit to CheckSymbolExists.cmake shown here:
>> 
>> http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=813eca64160509465c0e557aa
>> 98c9b0f828e47a9
>> 
>> breaks the symbol test for us.  We want a test that only reports whether a
>> symbol is declared.  We need to be able to distinguish between symbols that
>> are available or not (regardless of declaration, i.e., they link) and
>> symbols that are declared (regardless of linking, i.e., they're in a
>> header).
>> 
>> The CHECK_FUNCTION_EXISTS macro checks whether the symbol links, which your
>> commit seems to try and achieve with CHECK_SYMBOL_EXISTS unnecessarily... 
>> We compile strict and the trick used results in a compile error when we
>> test for the fileno symbol:
>> 
>> error: ISO C forbids conversion of function pointer to object pointer type
>> 
>> In our case, we wanted the prior simple no-op (which is consequently exactly
>> what AC_CHECK_DECL does):
>> 
>> (void)fileno;
>> 
>> That appropriately fails compilation if not declared.  Can the behavior be
>> restored?  There needs to be a simple test that checks if a symbol is
>> declared with current compilation flags and within specified headers.  Even
>> the #ifndef wrapper in the test is unnecessary towards that end.
> 
> Hi Sean,
> 
> please send this question to cmake-developers at cmake.org so this can get 
> broader discussion.
> 
> The main purpose of that patch was to make sure that a clever gcc doesn't 
> completely optimize out the symbol.
> 
> Greetings,
> 
> Eike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20130604/021aa9be/attachment.html>


More information about the cmake-developers mailing list