From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Lieven <pl@kamp.de>
Subject: [PULL 10/36] meson: accept either shared or static libraries if --disable-static
Date: Fri, 29 Jan 2021 12:17:48 +0100 [thread overview]
Message-ID: <20210129111814.566629-11-pbonzini@redhat.com> (raw)
In-Reply-To: <20210129111814.566629-1-pbonzini@redhat.com>
Meson's "static" argument to cc.find_library is a tri-state. By default
Meson *prefers* a shared library, which basically means using -l to
look for it; instead, "static: false" *requires* a shared library. Of
course, "static: true" requires a static library, which is all good
for --enable-static builds.
For --disable-static, "static: false" is rarely desirable; it does not
match what the configure script used to do and the test is more complex
(and harder to debug if it fails, which was reported by Peter Lieven
for librbd).
Reported-by: Peter Lieven <pl@kamp.de>
Tested-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/devel/build-system.rst | 2 +-
meson.build | 79 +++++++++++++++++++------------------
2 files changed, 42 insertions(+), 39 deletions(-)
diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst
index 31f4dced2a..69ce3087e3 100644
--- a/docs/devel/build-system.rst
+++ b/docs/devel/build-system.rst
@@ -100,7 +100,7 @@ In meson.build::
# Detect dependency
sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
method: 'pkg-config',
- static: enable_static)
+ kwargs: static_kwargs)
# Create config-host.h (if applicable)
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
diff --git a/meson.build b/meson.build
index a58c6f6785..688124d3da 100644
--- a/meson.build
+++ b/meson.build
@@ -18,6 +18,9 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
enable_modules = 'CONFIG_MODULES' in config_host
enable_static = 'CONFIG_STATIC' in config_host
+# Allow both shared and static libraries unless --enable-static
+static_kwargs = enable_static ? {'static': true} : {}
+
# Temporary directory used for files created while
# configure runs. Since it is in the build directory
# we can safely blow away any previous version of it
@@ -311,14 +314,14 @@ endif
pixman = not_found
if have_system or have_tools
pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
endif
pam = not_found
if 'CONFIG_AUTH_PAM' in config_host
pam = cc.find_library('pam')
endif
libaio = cc.find_library('aio', required: false)
-zlib = dependency('zlib', required: true, static: enable_static)
+zlib = dependency('zlib', required: true, kwargs: static_kwargs)
linux_io_uring = not_found
if 'CONFIG_LINUX_IO_URING' in config_host
linux_io_uring = declare_dependency(compile_args: config_host['LINUX_IO_URING_CFLAGS'].split(),
@@ -333,7 +336,7 @@ libnfs = not_found
if not get_option('libnfs').auto() or have_block
libnfs = dependency('libnfs', version: '>=1.9.3',
required: get_option('libnfs'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
endif
libattr_test = '''
@@ -354,7 +357,7 @@ if not get_option('attr').disabled()
else
libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
required: get_option('attr'),
- static: enable_static)
+ kwargs: static_kwargs)
if libattr.found() and not \
cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
libattr = not_found
@@ -381,14 +384,14 @@ seccomp = not_found
if not get_option('seccomp').auto() or have_system or have_tools
seccomp = dependency('libseccomp', version: '>=2.3.0',
required: get_option('seccomp'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
endif
libcap_ng = not_found
if not get_option('cap_ng').auto() or have_system or have_tools
libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
required: get_option('cap_ng'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
if libcap_ng.found() and not cc.links('''
#include <cap-ng.h>
@@ -409,7 +412,7 @@ if get_option('xkbcommon').auto() and not have_system and not have_tools
xkbcommon = not_found
else
xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
endif
vde = not_found
if config_host.has_key('CONFIG_VDE')
@@ -445,13 +448,13 @@ libiscsi = not_found
if not get_option('libiscsi').auto() or have_block
libiscsi = dependency('libiscsi', version: '>=1.9.0',
required: get_option('libiscsi'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
endif
zstd = not_found
if not get_option('zstd').auto() or have_block
zstd = dependency('libzstd', version: '>=1.4.0',
required: get_option('zstd'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
endif
gbm = not_found
if 'CONFIG_GBM' in config_host
@@ -468,14 +471,14 @@ if not get_option('curl').auto() or have_block
curl = dependency('libcurl', version: '>=7.29.0',
method: 'pkg-config',
required: get_option('curl'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
libudev = not_found
if targetos == 'linux' and (have_system or have_tools)
libudev = dependency('libudev',
method: 'pkg-config',
required: get_option('libudev'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
mpathlibs = [libudev]
@@ -511,17 +514,17 @@ if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
}'''
libmpathpersist = cc.find_library('mpathpersist',
required: get_option('mpath'),
- static: enable_static)
+ kwargs: static_kwargs)
if libmpathpersist.found()
mpathlibs += libmpathpersist
if enable_static
mpathlibs += cc.find_library('devmapper',
required: get_option('mpath'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
mpathlibs += cc.find_library('multipath',
required: get_option('mpath'),
- static: enable_static)
+ kwargs: static_kwargs)
foreach lib: mpathlibs
if not lib.found()
mpathlibs = []
@@ -571,7 +574,7 @@ if have_system and not get_option('curses').disabled()
curses = dependency(curses_dep,
required: false,
method: 'pkg-config',
- static: enable_static)
+ kwargs: static_kwargs)
endif
endforeach
msg = get_option('curses').enabled() ? 'curses library not found' : ''
@@ -596,7 +599,7 @@ if have_system and not get_option('curses').disabled()
foreach curses_libname : curses_libname_list
libcurses = cc.find_library(curses_libname,
required: false,
- static: enable_static)
+ kwargs: static_kwargs)
if libcurses.found()
if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
curses = declare_dependency(compile_args: curses_compile_args,
@@ -647,7 +650,7 @@ brlapi = not_found
if not get_option('brlapi').auto() or have_system
brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
required: get_option('brlapi'),
- static: enable_static)
+ kwargs: static_kwargs)
if brlapi.found() and not cc.links('''
#include <brlapi.h>
#include <stddef.h>
@@ -663,7 +666,7 @@ endif
sdl = not_found
if not get_option('sdl').auto() or (have_system and not cocoa.found())
- sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
+ sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs)
sdl_image = not_found
endif
if sdl.found()
@@ -671,7 +674,7 @@ if sdl.found()
sdl = declare_dependency(compile_args: '-Wno-undef',
dependencies: sdl)
sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
else
if get_option('sdl_image').enabled()
error('sdl-image required, but SDL was @0@'.format(
@@ -683,10 +686,10 @@ endif
rbd = not_found
if not get_option('rbd').auto() or have_block
librados = cc.find_library('rados', required: get_option('rbd'),
- static: enable_static)
+ kwargs: static_kwargs)
librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
required: get_option('rbd'),
- static: enable_static)
+ kwargs: static_kwargs)
if librados.found() and librbd.found() and cc.links('''
#include <stdio.h>
#include <rbd/librbd.h>
@@ -705,7 +708,7 @@ glusterfs_iocb_has_stat = false
if not get_option('glusterfs').auto() or have_block
glusterfs = dependency('glusterfs-api', version: '>=3',
required: get_option('glusterfs'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
if glusterfs.found()
glusterfs_ftruncate_has_stat = cc.links('''
#include <glusterfs/api/glfs.h>
@@ -744,7 +747,7 @@ libbzip2 = not_found
if not get_option('bzip2').auto() or have_block
libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
required: get_option('bzip2'),
- static: enable_static)
+ kwargs: static_kwargs)
if libbzip2.found() and not cc.links('''
#include <bzlib.h>
int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
@@ -761,7 +764,7 @@ liblzfse = not_found
if not get_option('lzfse').auto() or have_block
liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
required: get_option('lzfse'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
if liblzfse.found() and not cc.links('''
#include <lzfse.h>
@@ -798,12 +801,12 @@ if not get_option('gtk').auto() or (have_system and not cocoa.found())
gtk = dependency('gtk+-3.0', version: '>=3.22.0',
method: 'pkg-config',
required: get_option('gtk'),
- static: enable_static)
+ kwargs: static_kwargs)
if gtk.found()
gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
method: 'pkg-config',
required: false,
- static: enable_static)
+ kwargs: static_kwargs)
gtk = declare_dependency(dependencies: [gtk, gtkx11])
endif
endif
@@ -816,7 +819,7 @@ endif
x11 = not_found
if gtkx11.found() or 'lm32-softmmu' in target_dirs
x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
- static: enable_static)
+ kwargs: static_kwargs)
endif
vnc = not_found
png = not_found
@@ -825,12 +828,12 @@ sasl = not_found
if get_option('vnc').enabled()
vnc = declare_dependency() # dummy dependency
png = dependency('libpng', required: get_option('vnc_png'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
required: get_option('vnc_sasl'),
- static: enable_static)
+ kwargs: static_kwargs)
if sasl.found()
sasl = declare_dependency(dependencies: sasl,
compile_args: '-DSTRUCT_IOVEC_DEFINED')
@@ -841,7 +844,7 @@ snappy = not_found
if not get_option('snappy').auto() or have_system
snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
required: get_option('snappy'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
if snappy.found() and not cc.links('''
#include <snappy-c.h>
@@ -858,7 +861,7 @@ lzo = not_found
if not get_option('lzo').auto() or have_system
lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
required: get_option('lzo'),
- static: enable_static)
+ kwargs: static_kwargs)
endif
if lzo.found() and not cc.links('''
#include <lzo/lzo1x.h>
@@ -893,7 +896,7 @@ u2f = not_found
if have_system
u2f = dependency('u2f-emu', required: get_option('u2f'),
method: 'pkg-config',
- static: enable_static)
+ kwargs: static_kwargs)
endif
usbredir = not_found
if 'CONFIG_USB_REDIR' in config_host
@@ -920,7 +923,7 @@ if 'CONFIG_TASN1' in config_host
link_args: config_host['TASN1_LIBS'].split())
endif
keyutils = dependency('libkeyutils', required: false,
- method: 'pkg-config', static: enable_static)
+ method: 'pkg-config', kwargs: static_kwargs)
has_gettid = cc.has_function('gettid')
@@ -979,7 +982,7 @@ endif
fuse = dependency('fuse3', required: get_option('fuse'),
version: '>=3.1', method: 'pkg-config',
- static: enable_static)
+ kwargs: static_kwargs)
fuse_lseek = not_found
if not get_option('fuse_lseek').disabled()
@@ -1364,7 +1367,7 @@ capstone_opt = get_option('capstone')
if capstone_opt in ['enabled', 'auto', 'system']
have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
capstone = dependency('capstone', version: '>=4.0',
- static: enable_static, method: 'pkg-config',
+ kwargs: static_kwargs, method: 'pkg-config',
required: capstone_opt == 'system' or
capstone_opt == 'enabled' and not have_internal)
if capstone.found()
@@ -1474,7 +1477,7 @@ if have_system
slirp_opt = get_option('slirp')
if slirp_opt in ['enabled', 'auto', 'system']
have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
- slirp = dependency('slirp', static: enable_static,
+ slirp = dependency('slirp', kwargs: static_kwargs,
method: 'pkg-config',
required: slirp_opt == 'system' or
slirp_opt == 'enabled' and not have_internal)
@@ -1553,7 +1556,7 @@ fdt_opt = get_option('fdt')
if have_system
if fdt_opt in ['enabled', 'auto', 'system']
have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
- fdt = cc.find_library('fdt', static: enable_static,
+ fdt = cc.find_library('fdt', kwargs: static_kwargs,
required: fdt_opt == 'system' or
fdt_opt == 'enabled' and not have_internal)
if fdt.found() and cc.links('''
--
2.29.2
next prev parent reply other threads:[~2021-01-29 11:39 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 11:17 [PULL 00/36] Misc patches (buildsys, i386, fuzzing) for 2021-01-29 Paolo Bonzini
2021-01-29 11:17 ` [PULL 01/36] fuzz: ignore address_space_map is_write flag Paolo Bonzini
2021-01-29 11:17 ` [PULL 02/36] fuzz: refine the ide/ahci fuzzer configs Paolo Bonzini
2021-01-29 11:17 ` [PULL 03/36] docs/fuzz: fix pre-meson path Paolo Bonzini
2021-01-29 11:17 ` [PULL 04/36] fuzz: log the arguments used to initialize QEMU Paolo Bonzini
2021-01-29 11:17 ` [PULL 05/36] fuzz: enable dynamic args for generic-fuzz configs Paolo Bonzini
2021-01-29 11:17 ` [PULL 06/36] docs/fuzz: add some information about OSS-Fuzz Paolo Bonzini
2021-01-29 11:17 ` [PULL 07/36] fuzz: add virtio-9p configurations for fuzzing Paolo Bonzini
2021-01-29 11:17 ` [PULL 08/36] target/i386: do not set LM for 32-bit emulation "-cpu host/max" Paolo Bonzini
2021-01-29 11:17 ` [PULL 09/36] machine: add missing doc for memory-backend option Paolo Bonzini
2021-01-29 11:17 ` Paolo Bonzini [this message]
2021-01-29 11:17 ` [PULL 11/36] meson: honor --enable-rbd if cc.links test fails Paolo Bonzini
2021-01-29 11:17 ` [PULL 12/36] x86/cpu: Populate SVM CPUID feature bits Paolo Bonzini
2021-01-29 11:17 ` [PULL 13/36] fuzz: fix wrong index in clear_bits Paolo Bonzini
2021-01-29 11:17 ` [PULL 14/36] docs: don't install corresponding man page if guest agent is disabled Paolo Bonzini
2021-01-29 11:17 ` [PULL 15/36] virtio-scsi: don't uninitialize queues that we didn't initialize Paolo Bonzini
2021-01-29 11:17 ` [PULL 16/36] event_notifier: handle initialization failure better Paolo Bonzini
2021-01-29 11:17 ` [PULL 17/36] target/i386: Fix decoding of certain BMI instructions Paolo Bonzini
2021-01-29 11:17 ` [PULL 18/36] target/i86: implement PKS Paolo Bonzini
2021-01-29 11:17 ` [PULL 19/36] configure: Fix --enable-tcg-interpreter Paolo Bonzini
2021-01-29 11:17 ` [PULL 20/36] configure: Improve TCI feature description Paolo Bonzini
2021-01-29 11:17 ` [PULL 21/36] meson: Explicit TCG backend used Paolo Bonzini
2021-01-29 11:18 ` [PULL 22/36] meson: Warn when TCI is selected but TCG backend is available Paolo Bonzini
2021-01-29 11:18 ` [PULL 23/36] slirp: update to git master Paolo Bonzini
2021-01-29 11:18 ` [PULL 24/36] build-sys: make libslirp a meson subproject Paolo Bonzini
2021-01-29 11:18 ` [PULL 25/36] tests/meson: Only build softfloat objects if TCG is selected Paolo Bonzini
2021-01-29 11:18 ` [PULL 26/36] pc-bios/meson: Only install EDK2 blob firmwares with system emulation Paolo Bonzini
2021-01-29 11:18 ` [PULL 27/36] meson: Restrict block subsystem processing Paolo Bonzini
2021-01-29 11:18 ` [PULL 28/36] meson: Merge trace_events_subdirs array Paolo Bonzini
2021-01-29 11:18 ` [PULL 29/36] meson: Restrict some trace event directories to user/system emulation Paolo Bonzini
2021-01-29 11:18 ` [PULL 30/36] meson: Restrict emulation code Paolo Bonzini
2021-01-29 11:18 ` [PULL 31/36] qapi/meson: Restrict qdev code to system-mode emulation Paolo Bonzini
2021-01-29 11:18 ` [PULL 32/36] qapi/meson: Remove QMP from user-mode emulation Paolo Bonzini
2021-01-29 11:18 ` [PULL 33/36] qapi/meson: Restrict system-mode specific modules Paolo Bonzini
2021-01-29 11:18 ` [PULL 34/36] qapi/meson: Restrict UI module to system emulation and tools Paolo Bonzini
2021-01-29 11:18 ` [PULL 35/36] hvf: Fetch cr4 before evaluating CPUID(1) Paolo Bonzini
2021-01-29 11:18 ` [PULL 36/36] accel/kvm/kvm-all: Fix wrong return code handling in dirty log code Paolo Bonzini
2021-01-29 19:49 ` [PULL 00/36] Misc patches (buildsys, i386, fuzzing) for 2021-01-29 Peter Maydell
2021-01-29 19:54 ` Paolo Bonzini
2021-01-30 10:11 ` Marc-André Lureau
2021-01-30 11:14 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210129111814.566629-11-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).