[Bug target/86005] [RISCV] Invalid intermixing of __atomic_* libcalls and inline atomic instruction sequences

foom at fuhm dot net gcc-bugzilla@gcc.gnu.org
Thu May 31 15:07:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86005

James Y Knight <foom at fuhm dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foom at fuhm dot net

--- Comment #4 from James Y Knight <foom at fuhm dot net> ---
I think if RISCV wants to use out-of-line lock-free atomic helpers, it should
give those another function name (for example,
__sync_fetch_and_##OP##_##WIDTH), and provide them in libgcc.a, the same as the
other architectures which use such out-of-line helpers.

(But also, why doesn't it implement __atomic_add_fetch inline?)

Since lock-free helper functions can be linked into a process as many times as
you like without correctness issues, it's safe, and preferable, to provide them
in the static runtime lib.

That is quite unlike a potentially-locking __atomic_* function, which must
share the same lock across the whole process, and thus must have only one
implementation in a process, which is why they're provided separately by
libatomic.so.

It's not a good idea to conflate the two different things.


More information about the Gcc-bugs mailing list