meson.build: test for and link against libatomic if it exists

It's needed on some platforms for some subset (or all) atomic operations and
checking for the cases when it's actually needed is quite complex.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4300

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8637>
This commit is contained in:
Marc Leeman 2025-01-22 15:02:03 +01:00 committed by GStreamer Marge Bot
parent e845b596a2
commit f2b5c0b602
4 changed files with 23 additions and 10 deletions

View File

@ -48,15 +48,12 @@ if host_system not in ['windows', 'linux']
subdir_done()
endif
# Linux ARM would need -latomic for std::atomic<int64_t>
if host_system == 'linux' and host_machine.cpu_family() in ['aarch64', 'arm']
libatomic_dep = cxx.find_library('atomic', required: get_option('cuda-nvmm'))
if not libatomic_dep.found()
subdir_done()
endif
gstcuda_platform_dep += [libatomic_dep]
endif
# Check for libatomic for use of C11 atomics: some architectures need
# to link explicitly to this library.
# TODO: Once meson 1.7 is in use, this can be updated to
# dependency('atomic')
atomic_dep = cxx.find_library('atomic', required: false)
gstcuda_platform_dep += [atomic_dep]
cuda_win32_headers = [
'initguid.h',

View File

@ -162,7 +162,7 @@ gstaudio = library('gstaudio-@0@'.format(api_version),
soversion : soversion,
darwin_versions : osxversion,
install : true,
dependencies : gstaudio_deps,
dependencies : [ gstaudio_deps, base_platform_dep ],
)
pkg_name = 'gstreamer-audio-1.0'
pkgconfig.generate(gstaudio,

View File

@ -398,6 +398,15 @@ else
core_conf.set('DISABLE_ORC', 1)
endif
base_platform_dep = []
# Check for libatomic for use of C11 atomics: some architectures need
# to link explicitly to this library.
# TODO: Once meson 1.7 is in use, this can be updated to
# dependency('atomic')
atomic_dep = cc.find_library('atomic', required: false)
base_platform_dep += [atomic_dep]
# Used to build SSE* things in audio-resampler
sse_args = '-msse'
sse2_args = '-msse2'

View File

@ -599,6 +599,13 @@ if nsl_lib.found()
network_deps += nsl_lib
endif
# Check for libatomic for use of C11 atomics: some architectures need
# to link explicitly to this library.
# TODO: Once meson 1.7 is in use, this can be updated to
# dependency('atomic')
atomic_dep = cc.find_library('atomic', required: false)
platform_deps += atomic_dep
gir = find_program('g-ir-scanner', required : get_option('introspection'))
gnome = import('gnome')