[cmake-developers] CheckSymbolExists is unreliable

Rolf Eike Beer eike at sf-mail.de
Mon Jan 9 09:19:57 EST 2012


> On 1/7/2012 6:12 AM, Rolf Eike Beer wrote:
>> This has changed. It fails now for vs11-x64 on amber10 and for Linux64-
>> bullseye-cov on hythloth. amber10 seems to have an unrelated, general
>> problem.
>> What's wrong with the bullseye I have no idea, but this goes wrong for
>> the C++ test and some others, too.
>
> Ignore amber10.  The machine has some corruption on it.  We've been
> working to move those builds to some clean machines or VMs.
>
> I wonder if the BullsEye coverage tool ends up leaving errno set to
> non-zero
> after program startup.  By returning it directly the return code from the
> test
> executable ends up as non-zero so CTest thinks it failed.  This works
> around
> the problem:
>
> diff --git a/Tests/Module/CheckSymbolExists/errno.c
> b/Tests/Module/CheckSymbolExists/errno.c
> index 6010f7c..da78f02 100644
> --- a/Tests/Module/CheckSymbolExists/errno.c
> +++ b/Tests/Module/CheckSymbolExists/errno.c
> @@ -2,5 +2,6 @@
>
>   int main()
>   {
> +  errno = 0;
>     return errno;
>   }

Well, that could us lead to the point again where a compiler optimizes out
the whole usage of errno. Maybe we should call some really standard
function in between (whatever that may be). Maybe new?

>>> However the CheckCXXSymbolExist test fails:
>>
>> For the bullseye (see above) and because the dummy executable fails for
>> Borland C++. "return errno;" doesn't work in C++ mode, I have no idea
>> what's
>> that for a screwup. And especially why searching for that symbol using
>> CheckCXXSymbolExists works but using it doesn't.
>
> When you use <cerrno> shouldn't you reference "std::errno" and not
> "errno"?
> However, even that doesn't work because Borland's treatment of errno in
> <cerrno> ends up preprocessing to
>
>   namespace std { extern "C" { extern  int * __cdecl  __errno(void); } }
>   int main() { return (*__errno()); }
>
> and __errno() is not visible outside std::.  Adding std:: would end up
> giving "return std::(*__errno())" which of course doesn't work.  What
> works
> is "return (*std::__errno())" but they do not define the macro that way ;)
>
> Using just <errno.h> works for Borland.

What about just putting "using std;" before the main? Does that help?

Eike



More information about the cmake-developers mailing list