Raising the default baseline for a target

Hello!

I'm trying to figure out how to raise the default baseline for the 32-bit SPARC
target on Linux. Currently, this target defaults to the SPARCv7 architecture which
lacks support for atomic instructions which is why the build of compiler-rt fails
with, see [1]:

/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'

Since Linux distributions have been defaulting to the v9 instruction set with 32-bit
pointers for the 32-bit SPARC for quite a while, I would like to set this baseline as
default when targeting SPARC on 32-bit Linux. If anyone wanted to build for v7, they
could still set the target with "-mcpu=v7".

Does anyone know how to set the default baseline for a given target? Raising the
baseline would finally fix the LLVM build on the Linux sparc64 buildbot which has
been failing for quite a long time.

Discussion for this change happens in [2].

Thanks,
Adrian

Hello!

I'm trying to figure out how to raise the default baseline for the 32-bit SPARC
target on Linux. Currently, this target defaults to the SPARCv7 architecture which
lacks support for atomic instructions which is why the build of compiler-rt fails
with, see [1]:

Can anyone recommend a place where I might find an answer?

The discourse channel for the related topics code generation [1] and sanitizers [2]
don't seem to get much attention either.

Thanks,
Adrian

It would seem that the default in the back end is “v9” for 64-bit and “v8” otherwise as per: https://llvm.org/doxygen/SparcSubtarget_8cpp_source.html#l00028

In clang, it looks like tools::getCPUName() (https://clang.llvm.org/doxygen/namespaceclang_1_1driver_1_1tools.html#a4aa5f09d301ea25099c8badc35a4e09d) returns “v9” for Solaris and an empty string otherwise. Presumably if you set it to what it should be set for, you will get what you want.

Hello!

Thanks for the answer!

It would seem that the default in the back end is "v9" for 64-bit and "v8" otherwise
as per: LLVM: lib/Target/Sparc/SparcSubtarget.cpp Source File

In clang, it looks like tools::getCPUName() (clang: clang::driver::tools Namespace Reference) returns "v9" for Solaris and an empty string otherwise. Presumably if you set it to what it should be set for, you will get what you want.

Yes, that is what I am planning to do now, although I still need to make changes
to compiler-rt since even with V9, __sync_val_compare_and_swap_8 are not available
with GCC.

I opened a bug report for that matter [1]. I will also check whether I can fix something
on the GCC side.

Adrian