GCC in-line assembly and the removal of -mcx16
Alexander Monakov
amonakov@ispras.ru
Tue May 30 14:52:00 GMT 2017
On Tue, 30 May 2017, Jonathan Wakely wrote:
> > I just built GCC from trunk, and this gives me:
> >
> > mustang-b0:~ $ /scratch/gcc/trunk/install/bin/gcc zzz.c
> > /tmp/ccmc3Y73.o: In function `main':
> > zzz.c:(.text+0x20): undefined reference to `__sync_val_compare_and_swap_16'
> > collect2: error: ld returned 1 exit status
> >
> > I can't figure out where __sync_val_compare_and_swap_16 should be
> > defined. It's not in libatomic or libc or libgcc.
libgcc implements __sync..._N calls in terms of __sync_val_compare_and_swap_N
built-in when it's available, but there's no way libgcc could conjure CAS "out
of thin air". The way libatomic does that with mutexes is questionable to say
the least, because it's wrong when signal handlers or cross-process shared
memory is involved.
> But if you compile with -mcx16 then it should use cmpxchg16b instead
> of a library call.
>
> That only works for x86_64 (like the -mcx16 option itself). I don't
> know how to guarantee no library call for aarch64.
The Aarch64 double-word cas instruction, CASP, is not (yet) implemented in GCC.
Alexander
More information about the Gcc-help
mailing list