Commit 5fd5e9ff authored by alexfanqi's avatar alexfanqi Committed by Daniel Black

improve checks for libatomic linking

This code piece is adapted from https://github.com/KDE/krita/blob/451e1415fd1b3a0f9c24de2fd4707d1b1e164236/cmake/modules/CheckAtomic.cmake#L23

Fixes: f502ccbc
Fixes: https://bugs.gentoo.org/828065Tested-by: default avatarYixun Lan <dlan@gentoo.org>
Reviewed-by: Daniel Black
parent 97695675
......@@ -891,9 +891,16 @@ HAVE_GCC_ATOMIC_BUILTINS)
CHECK_CXX_SOURCE_COMPILES("
int main()
{
long long int var= 1;
long long int *ptr= &var;
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
char x=1;
short y=1;
int z=1;
long w = 1;
long long s = 1;
x = __atomic_add_fetch(&x, 1, __ATOMIC_SEQ_CST);
y = __atomic_add_fetch(&y, 1, __ATOMIC_SEQ_CST);
z = __atomic_add_fetch(&z, 1, __ATOMIC_SEQ_CST);
w = __atomic_add_fetch(&w, 1, __ATOMIC_SEQ_CST);
return (int)__atomic_load_n(&s, __ATOMIC_SEQ_CST);
}"
HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
IF (HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
......@@ -904,9 +911,16 @@ ELSE()
CHECK_CXX_SOURCE_COMPILES("
int main()
{
long long int var= 1;
long long int *ptr= &var;
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
char x=1;
short y=1;
int z=1;
long w = 1;
long long s = 1;
x = __atomic_add_fetch(&x, 1, __ATOMIC_SEQ_CST);
y = __atomic_add_fetch(&y, 1, __ATOMIC_SEQ_CST);
z = __atomic_add_fetch(&z, 1, __ATOMIC_SEQ_CST);
w = __atomic_add_fetch(&w, 1, __ATOMIC_SEQ_CST);
return (int)__atomic_load_n(&s, __ATOMIC_SEQ_CST);
}"
HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
......
......@@ -129,7 +129,8 @@ SET(ROCKSDB_SE_SOURCES
# This is a strong requirement coming from RocksDB. No conditional checks here.
#ADD_DEFINITIONS(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX
#)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
if (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
SET(ATOMIC_EXTRA_LIBS -latomic)
else()
SET(ATOMIC_EXTRA_LIBS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment