diff --git a/meson.build b/meson.build index 8135ee0e9ed90d942e4806e7a2df41c832d0323b..1b5834eb73202ac7c7fc68efb426b92209ecc88f 100644 --- a/meson.build +++ b/meson.build @@ -95,7 +95,15 @@ if host_machine.system() == 'windows' threads_dep = [] else pthreads = dependency('threads', required: true) - threads_dep = declare_dependency(link_args: '-lpthread', dependencies: pthreads) + if get_option('libtool_workaround') + libtool_forced_ldflags = ['-lpthread'] + if cxx.find_library('atomic').found() + libtool_forced_ldflags += '-latomic' + endif + threads_dep = declare_dependency(link_args: libtool_forced_ldflags, dependencies: pthreads) + else + threads_dep = pthreads + endif endif sqlite_dep = dependency('sqlite3', version: '>= 3.33.0', diff --git a/meson_options.txt b/meson_options.txt index ce684dd5f3584e63b2cbb2f47309f3bf2b3fcf3f..a3539c59b04171fc7917b398c0648b3be0ec69dd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,3 +3,6 @@ option('libjpeg_prefix', type: 'string') option('tests', type: 'feature', value: 'auto') option('force_attachment_api', type: 'boolean', value: false) option('fuzz', type: 'boolean', value: false) +option('libtool_workaround', type: 'boolean', value: false, + description: 'Force explicit mention of some libraries in the .pc ' + + 'file that would be overwritten by libtool\'s use of -nostdlib')