This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Documentation of __sync builtins unclear on external function callback behavior
- From: Andrew Haley <aph at redhat dot com>
- To: Johan Tibell <johan dot tibell at gmail dot com>, gcc-help at gnu dot org
- Date: Thu, 17 Jul 2014 09:26:36 +0100
- Subject: Re: Documentation of __sync builtins unclear on external function callback behavior
- Authentication-results: sourceware.org; auth=none
- References: <CAK-tuPbWXcgTWdFGGioXb=a5TTCB7qbSLLKr+n5=84d4y9DZKg at mail dot gmail dot com>
On 16/07/14 23:01, Johan Tibell wrote:
> The documentation of the __sync atomic builtins [1] state that
>
>> Not all operations are supported by all target processors. If a
>> particular operation cannot be implemented on the target processor,
>> a warning is generated and a call an external function is
>> generated. The external function carries the same name as the
>> built-in version, with an additional suffix â_nâ where n is the
>> size of the data type.
>
> I initial read this as a call to some function *defined by GCC* is
> being emitted, but I now realize that this can be read as "the caller
> is supposed to have defined such a fallback function". Which reading
> is correct?
The latter. Hwever, in some cases in may not even be possible: the
hardware may be incapable of doing it.
> I have some code that fails to compile on i386 with the error
>
> /usr/home/ghc-builder/work/builder/tempbuild/build/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.3.1.0-ghc7.9.20140716.so:
> undefined reference to `__sync_fetch_and_add_8'
>
> so I guess that means that GCC is not defining these external fallback
> functions?
My guess is that you're building for an x86 that can't do it.
-march=i586 ought to work. i386 won't.
Andrew.