]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
cmake: Improve test for 16-byte atomic support on IBM Z 33716/head
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 23 Jan 2020 12:07:08 +0000 (13:07 +0100)
committerKefu Chai <kchai@redhat.com>
Wed, 4 Mar 2020 10:56:24 +0000 (18:56 +0800)
commit1172b87ec7f8083cdfd393df94fc321595d7c0c1
tree38daa4451f9c107af37a2bd280680281c8e5d128
parent5c678cc768d432130c95755240f5bc3c4cef4f72
cmake: Improve test for 16-byte atomic support on IBM Z

Commit d1b9d14324586d02dc6c8dd0a9bdf4b98ae16416 added a check for
16-byte atomics without library support on IBM Z.  Unfortunately
it turns out this test only works correctly when the test case
is built without optimization.  (This is normally true, but it
may not be the case when passing explicit CXXFLAGS to cmake.)

The underlying reason is that GCC may choose to use either an
inline implementation of the 16-byte atomics or library calls,
depending on whether or not it is able to prove the atomic
variable is properly aligned.  At -O0 it is never able to prove
that, but at higher optimization levels it depends on the complexity
of the expression (in particular, whether GCC can track down the
definition of the underlying object).

As the test case uses a very simple expression, it may happen that
this test can be built without requiring library support, but some
of the "real" uses of atomics in Ceph code cannot.   This defeats
the whole purpose of the test at configure time.

Fixed by making the access pattern in the test more complex, so
that the test fails even at high optimization levels.

Fixes: https://tracker.ceph.com/issues/43747
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
(cherry picked from commit c58fc258a280bce62ed454bd0345076aca29a822)
cmake/modules/CheckCxxAtomic.cmake