Hello!

I'm currently trying to solve a problem in LLVM which arises when building the 
compiler-rt
library on 32-bit SPARC [1].

More specifically, I'm getting a linker error which indicates that the target 
does not 64-bit
atomic operations natively and has to use libatomic:

/usr/bin/ld: warning: -z gnu-version-script-compat ignored
/usr/bin/ld: 
projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.sparc.dir/sanitizer_libignore.cpp.o:
 in function `bool 
__sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint64_t>(__sanitizer::atomic_uint64_t
 volatile*, __sanitizer::atomic_uint64_t::Type*, 
__sanitizer::atomic_uint64_t::Type, __sanitizer::memory_order)':
/var/lib/buildbot/workers/debian-stadler-sparc64/clang-sparc64-linux-multistage/llvm/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h:80:
 undefined reference to `__sync_val_compare_and_swap_8'

While playing around with the compiler options trying to find a solution, I 
made an interesting
discovery which is that GCC support 64-bit compare and swap on SPARCv8plus but 
not on 32-bit
SPARCv9:

glaubitz@gcc202:~$ echo | gcc -mv8plus -E -dM -|grep -i SWAP
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
glaubitz@gcc202:~$ echo | gcc -mcpu=v9 -m32 -E -dM -|grep -i SWAP
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
glaubitz@gcc202:~$

Is this intentional? If yes, what is the exact difference between V8+ and 
32-bit V9?

Thanks,
Adrian

> [1] https://github.com/llvm/llvm-project/issues/53337

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply via email to