diff --git a/lix/libutil/meson.build b/lix/libutil/meson.build index 71d55154c..f3b2332d5 100644 --- a/lix/libutil/meson.build +++ b/lix/libutil/meson.build @@ -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 ) diff --git a/lix/nix/meson.build b/lix/nix/meson.build index 356f3b6b0..35f1f9fb7 100644 --- a/lix/nix/meson.build +++ b/lix/nix/meson.build @@ -178,6 +178,7 @@ nix = executable( capnp_rpc, nlohmann_json, kj, + libatomic, ], cpp_pch : cpp_pch, install : true, diff --git a/meson.build b/meson.build index 985b245a4..7b229ccef 100644 --- a/meson.build +++ b/meson.build @@ -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 +int main() { + std::atomic w1; + std::atomic w2; + std::atomic w4; + std::atomic 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 # diff --git a/subprojects/lix-clang-tidy/meson.build b/subprojects/lix-clang-tidy/meson.build index 70dabe6da..03c878191 100644 --- a/subprojects/lix-clang-tidy/meson.build +++ b/subprojects/lix-clang-tidy/meson.build @@ -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'] )