meson: link against libatomic if required
Some platforms like 32-Bit PowerPC need linking against libatomic.
Try to compile and link a very simple snippet of code which uses atomics
and make libatomic required if it fails.
Because we're using `dependency('atomic')`, the required meson versions
gets bumped to 1.7.0. See https://mesonbuild.com/Dependencies.html#atomic-stdatomic
Change-Id: I6a6a696471e1d352fb161c537ba9023b97c2d31e
This commit is contained in:
@@ -333,6 +333,7 @@ dependencies = [
|
||||
libarchive,
|
||||
nlohmann_json,
|
||||
openssl,
|
||||
libatomic,
|
||||
]
|
||||
|
||||
libutil_temp = library(
|
||||
@@ -409,6 +410,7 @@ liblixutil = declare_dependency(
|
||||
kj,
|
||||
libarchive,
|
||||
nlohmann_json,
|
||||
libatomic,
|
||||
],
|
||||
link_with : libutil
|
||||
)
|
||||
|
||||
@@ -178,6 +178,7 @@ nix = executable(
|
||||
capnp_rpc,
|
||||
nlohmann_json,
|
||||
kj,
|
||||
libatomic,
|
||||
],
|
||||
cpp_pch : cpp_pch,
|
||||
install : true,
|
||||
|
||||
+21
-1
@@ -34,7 +34,7 @@
|
||||
|
||||
project('lix', 'cpp', 'rust',
|
||||
# NOTE: when bumping this, remember to also bump meson_version in subprojects.
|
||||
meson_version : '>=1.5.0',
|
||||
meson_version : '>=1.7.0',
|
||||
version : run_command('bash', '-c', 'echo -n $(jq -r .version < ./version.json)$VERSION_SUFFIX', check : true).stdout().strip(),
|
||||
default_options : [
|
||||
'cpp_std=c++23',
|
||||
@@ -380,6 +380,26 @@ if is_freebsd
|
||||
libprocstat = declare_dependency(link_args : [ '-lprocstat' ])
|
||||
endif
|
||||
|
||||
libatomic_test_program = '''
|
||||
#include <atomic>
|
||||
int main() {
|
||||
std::atomic<uint8_t> w1;
|
||||
std::atomic<uint16_t> w2;
|
||||
std::atomic<uint32_t> w4;
|
||||
std::atomic<uint64_t> w8;
|
||||
return ++w1 + ++w2 + ++w4 + ++w8;
|
||||
}
|
||||
'''
|
||||
|
||||
libatomic = dependency('atomic', required : false)
|
||||
|
||||
# Some platforms like 32-Bit PowerPC need libatomic because they're lacking 64-Bit hardware atomic instructions
|
||||
# and compilers don't handle this automatically (yet).
|
||||
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358 and https://clang.llvm.org/docs/Toolchain.html#atomics-library
|
||||
if cxx.links(libatomic_test_program, name : 'test if simple atomic program links')
|
||||
libatomic = dependency('atomic', required : true)
|
||||
endif
|
||||
|
||||
#
|
||||
# Build-time tools
|
||||
#
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
project('lix-clang-tidy', ['cpp', 'c'],
|
||||
meson_version : '>=1.5.0',
|
||||
meson_version : '>=1.7.0',
|
||||
version : '0.1',
|
||||
default_options : ['warning_level=3', 'cpp_std=c++20']
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user