On Thu, Nov 12, 2026 at 10:09:49AM +0100, Jakub Jelinek wrote:
> On Thu, Nov 12, 2026 at 10:05:53AM +0100, Jakub Jelinek wrote:
> > On Thu, Nov 12, 2026 at 09:56:55AM +0100, Stefan Schulze Frielinghaus wrote:
> > > I'm seeing now:
> > > 
> > > libsanitizer/tsan/.libs/tsan_interface_atomic.o:                 U 
> > > __sync_fetch_and_and_16
> > 
> > In that case it is probably the
> > https://github.com/llvm/llvm-project/commit/c96a176dd15690ed8181c6764b26d0303008a40f
> > change.  Maybe clang doesn't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 on
> > s390x and GCC does?
> 
> Ah, seems GCC does define it and has the optabs, but they FAIL if the
> address doesn't have 16-byte alignment.

Yea in GCC we set HAVE_atomic_compare_and_swapti for s390 which renders
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 true, and in Clang I only see

clang/lib/Basic/Targets/AArch64.cpp
809:  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");

clang/lib/Basic/Targets/X86.cpp
1080:    Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");

but not s390.

> So maybe for tsan purposes #undef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 on
> s390x given that __int128 doesn't have 128-bit alignment and the library
> uses it carelessly?

libatomic on s390 checks for 128-bit alignment and if that is not the case
falls back to a lock.  My reading of tsan_interface_atomic.cpp does the
same if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16).  So yes,
undefining __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 on s390 probably solves
this.

Cheers,
Stefan

Reply via email to