From: Ken Dreyer Date: Mon, 18 Jul 2022 19:06:06 +0000 (-0400) Subject: build: fix atomic linking with LTO on s390x X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0e07d965f93dd9f2606d541f26cfd050cc4c1e54;p=ceph.git build: fix atomic linking with LTO on s390x Prior to this change, Fedora and RHEL 9 on s390x would incorrectly pass the HAVE_CXX11_ATOMIC check. As a consequence, the rest of Ceph would fail to link because of missing atomic methods "__atomic_load_16", "__atomic_store_16", "__atomic_compare_exchange_16". Mark this method so that it is not optimized out, even with LTO. With this change, s390x properly fails HAVE_CXX11_ATOMIC and falls back to HAVE_LIBATOMIC. Move the "BuildRequires: libatomic" RPM line out from the seastar+fedora conditional and into the main fedora+rhel conditional so that the HAVE_LIBATOMIC check will pass. Fixes: https://tracker.ceph.com/issues/54514 Fixes: https://tracker.ceph.com/issues/56492 Co-authored-by: Kaleb S. Keithley Signed-off-by: Ken Dreyer --- diff --git a/ceph.spec.in b/ceph.spec.in index 9f522a750b786..c0806afaf7a85 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -311,7 +311,6 @@ BuildRequires: systemtap-sdt-devel %if 0%{?fedora} BuildRequires: libubsan BuildRequires: libasan -BuildRequires: libatomic %endif %if 0%{?rhel} BuildRequires: gcc-toolset-9-annobin @@ -353,6 +352,7 @@ Requires: systemd BuildRequires: boost-random BuildRequires: nss-devel BuildRequires: keyutils-libs-devel +BuildRequires: libatomic BuildRequires: libibverbs-devel BuildRequires: librdmacm-devel BuildRequires: ninja-build diff --git a/cmake/modules/CheckCxxAtomic.cmake b/cmake/modules/CheckCxxAtomic.cmake index 78c0f988707a0..ac697553f08b3 100644 --- a/cmake/modules/CheckCxxAtomic.cmake +++ b/cmake/modules/CheckCxxAtomic.cmake @@ -24,7 +24,14 @@ function(check_cxx_atomics var) // We specifically test access via an otherwise unknown pointer here // to ensure we get the most complex case. If this access can be // done without libatomic, then all accesses can be done. +struct tagged_ptr { + int* ptr; + std::size_t tag; +}; + bool atomic16(std::atomic *ptr) +void atomic16(std::atomic *ptr) __attribute__ ((used)); +void atomic16(std::atomic *ptr) { return *ptr != 0; }