This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Invoking atomic functions from a C++ shared lib (or should I force linking with -lgcc?)
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 19 Nov 2010 10:21:20 +0000
- Subject: Re: Invoking atomic functions from a C++ shared lib (or should I force linking with -lgcc?)
- References: <4CE3E81D.2010008@st.com> <4CE64E01.4060206@st.com>
On 11/19/2010 10:14 AM, Christophe Lyon wrote:
>
>>
>> What I have found is that g++ (unlike gcc) links with -lgcc_s instead of
>> -lgcc and that the atomic functions are present in libgcc.a and not in
>> libgcc_s.so.
>>
>
> Anyone knows the rationale for the absence of functions such as
> __sync_fetch_and_add (and more generally all __sunc* functions) from
> libgcc_s.so ?
It was to make them faster by avoiding a trip through the PLT.
> Is it a bug/feature specific to the ARM port? (on x86 for instance, such
> functions do not exist, the corresponding builtin is fully expanded and
> requires not lib call).
There are a couple of targets that use libcalls for atomics.
You should be able simply to link with
-lgcc_s -lgcc
Andrew.