Skip to content

Commit 9cbf31d

Browse files
NJRoadfanrdmark
authored andcommitted
meson: Fix detection of libatomic
Currently if the test for built-in GCC atomic functions fails, meson only searches for the libatomic library at the default location. Some platforms install the library in an alternate location (ex: NetBSD/m68k), so we search those additional locations. If the library is found, update the linker args to search that directory. Fixes #3043.
1 parent ae54748 commit 9cbf31d

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

meson.build

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,23 @@ int main(void) {
405405
}
406406
'''
407407
if not cc.links(atomic_test_code, name: 'atomic builtins without -latomic')
408-
cc.find_library('atomic', required: true)
409-
netatalk_common_link_args = ['-latomic'] + netatalk_common_link_args
408+
# Find the library: system paths, platform paths
409+
atomic = cc.find_library('atomic', required: false)
410+
foreach d : libsearch_dirs
411+
if not atomic.found()
412+
atomic = cc.find_library('atomic', dirs: d, required: false)
413+
if atomic.found()
414+
netatalk_common_link_args += ['-L' + d]
415+
endif
416+
endif
417+
endforeach
418+
if atomic.found()
419+
netatalk_common_link_args += '-latomic'
420+
endif
421+
have_atomic = atomic.found()
422+
if not have_atomic
423+
error('libatomic is required! Please install it.')
424+
endif
410425
endif
411426

412427
add_global_link_arguments(netatalk_common_link_args, language: 'c')

0 commit comments

Comments
 (0)