From c5954f9c787d6f659a64b2c9b4d91abb75cb363c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 11 Feb 2022 09:33:14 +0100 Subject: [PATCH 1/2] meson: Conditionally enable libtool workaround --- meson.build | 6 +++++- meson_options.txt | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8135ee0e..104417da 100644 --- a/meson.build +++ b/meson.build @@ -95,7 +95,11 @@ 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') + threads_dep = declare_dependency(link_args: '-lpthread', 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 ce684dd5..a3539c59 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') -- GitLab From af08dff6cc872f1b5044a7f059d4c020d53937fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Mon, 24 Jan 2022 09:13:38 +0100 Subject: [PATCH 2/2] meson: Force -latomic when libtool workaround is enabled Fix #411 --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 104417da..1b5834eb 100644 --- a/meson.build +++ b/meson.build @@ -96,7 +96,11 @@ if host_machine.system() == 'windows' else pthreads = dependency('threads', required: true) if get_option('libtool_workaround') - threads_dep = declare_dependency(link_args: '-lpthread', dependencies: pthreads) + 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 -- GitLab