[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: About gcc builtin atomics



On Sun, 17 Jun 2012 13:42:29 +0000 (UTC), Thorsten Glaser <tg@mirbsd.de> wrote:
> Hi,
> 
> I was just randomly wondering whether it might still be possible
> to add __sync_* support to gcc-4.6 - earlier I've had a look at
> the relevant commits, and they depend on deep changes to the
> machine-independent code so that's a no-go.
> 
> I was wondering whether just adding one file from gcc-4.7 to the
> build and hooking it up in t-linux would work, considering gcc
> already emits externs for __sync_*_4() if it encounters use of
> such builtins in the code, because recently, I've taken some of
> that file and just added it ``inline'' to the one file using one
> of those functions, and it worked.
> 
> svn://gcc.gnu.org/svn/gcc/trunk/libgcc/config/m68k/linux-atomic.c
> is the file I was talking about.
> 
> Mikael, can that work, just adding those functions to (the static,
> as they're HIDDEN) libgcc, without patching gcc itself, in 4.6?

That could work.  You'll need to reassemble libgcc.a with the new
object file, and you'll need to replace the libgcc_s.so file that's
usually a symlink with a linker script that sources both the shared
and the static libgcc, as is already done for ARM and others.

IMO it's better to do this "properly" by modifying the gcc sources,
since that allows other gcc libraries (like libstdc++) and the test
suite to pick up the improved sync op support.  But for avoiding
compile errors in package rebuilds the above should suffice.

/Mikael

\begin{digression}
I actually began working on linux-atomic.c for m68k about 16 months
ago, basing it on the ARM one but using CAS rather than a syscall.
But I got regressions in the libgomp test suite I couldn't explain,
so I halted that project.  Now we know that aranym had a broken
CAS emulation :-(

I also did an implementation of "sync.md" for m68k in the gcc-4.6
code base, which added proper code generation support for sync ops,
rather than treating them as procedure calls.  (This was not a plain
backport from 4.7 due to technical differences between the pre-4.7
style sync ops and the 4.7+ style atomic ops.)  Again I got test suite
regressions (presumably due to the aranym CAS bug) so I didn't finish it.
\end{digression}


Reply to: