From nobody Tue Nov 18 16:52:50 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611656975; cv=none; d=zohomail.com; s=zohoarc; b=aFPCr8Y2wzXKj8XAD8TMPT5mmUFqk13l7WpnyAYmmj8oJdQlHL2PydHonJnsuZTCUhHOYqc0TurGtsoiKO/tC+8UabR92tERRIfIWWPeYuRK4MGW9j/eWAjEHuk1aUsH+1LtTTaXKfFe2z6MDvjMLV1OcGxGEQ9E1+NqQb8DVac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611656975; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=bOjIZ1631Un8okOsR0CIAocNIq3KO4m8UkoLNEYudlU=; b=VIpgL+Ggz1Zcwn5YTh+bst0qVIoPLOXQ8G/YJ9av+en+kGfhfG4sU+xENLD03cU0b2pEr0cC3b/yQYRapIUnibqVyUAYxRCce9Vh6SyH2H6ZNpyN8YyiJ/US93yMFOGFAnJN/Tk0u7b44xrakmy+xWOk3xwtvVknb01WPducWV8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611656975230592.8564709137613; Tue, 26 Jan 2021 02:29:35 -0800 (PST) Received: from localhost ([::1]:50094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4LbK-0005gm-2c for importer@patchew.org; Tue, 26 Jan 2021 05:29:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4LZj-0004PN-6X for qemu-devel@nongnu.org; Tue, 26 Jan 2021 05:27:55 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:44428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l4LZg-0007kv-NA for qemu-devel@nongnu.org; Tue, 26 Jan 2021 05:27:54 -0500 Received: by mail-ej1-x631.google.com with SMTP id w1so22156691ejf.11 for ; Tue, 26 Jan 2021 02:27:51 -0800 (PST) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id bo12sm9447907ejb.93.2021.01.26.02.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 02:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bOjIZ1631Un8okOsR0CIAocNIq3KO4m8UkoLNEYudlU=; b=h7G0jJ6IyK7zRdzzMVVDDTEAoweNfpDojxC8NWrQ70SfjbuyKyHppP1RyMo0UMI99A U1epUjL195xKWTPXY1jphljyhabhTFYqU70DsmnhCOwG4sLvcg0jT4pM1TUx2dAtLmZE KscZ0Kb5M9Jb9Y2RXojZLQj9GQpnEo7s2fVcHU6oPEYLDNiv165Fmi4wzu3/A5vgVvsl nvEQCaHwS1aeHUY+0vHvh7Am3eVQbIB3KM0g9zR0ZOaZ/sLi2bbCzE9cf6F1PIfqX5O6 vpV2l/aHBwp/9cn8aa/LHcxCNAM9XXAkibO4Ns8VnhEMx8OTVst6IEbE3aS+G+aUSmtS ciXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=bOjIZ1631Un8okOsR0CIAocNIq3KO4m8UkoLNEYudlU=; b=dyVWtnVg3drm6i90bTg9PrANpbwq/5WEVSodnA8p1XrUGZrvji993GJBXNBAEaH577 t5KATMKF3+FTS/gXTxekZt/AZvHGg2VPWul+i+i3GPEZ2U6ouTFkwJUX2jHh7WnB46PZ EXVstWSjkVzeBDuK42u0fj3yXE+tFJt0O8iYC6k+a+CJoMNRJDChfIe9yG4U0SzZZb9W jh5Lp1RGJ0G8RjRtZIX81LCl8sUyZCAmP+lPW3GCUWXJPthSHiW8zoWH99UksI62H47W e3/Fqlw/o2uwAtKB9HTOpF7uG4Wmu7cREKVXNJXy3Xysn2ZgOeblDnFn7XzFtMjdVibW MwFw== X-Gm-Message-State: AOAM5337Y7VCQLihNK5K3ld0En4El6dzHXM3AeJyjdLHk3ii8z/m0miA pyqOBIjFTy20mCWK914+F8dZ56y1SlRixA== X-Google-Smtp-Source: ABdhPJxR/Zkdh1hWQl9Hqv+YOuZm7019sNjah1vE24P+88r9e3X5lTug+vD5wfafzoL9siwfGi6eYQ== X-Received: by 2002:a17:906:4bc2:: with SMTP id x2mr2998074ejv.4.1611656869992; Tue, 26 Jan 2021 02:27:49 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH] meson: accept either shared or static libraries if --disable-static Date: Tue, 26 Jan 2021 11:27:47 +0100 Message-Id: <20210126102748.341403-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x631.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pl@kamp.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 Tested-by: Peter Lieven Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D dependency('SDL2_image', required: get_option('sdl_image'), method: 'pkg-config', - static: enable_static) + kwargs: static_kwargs) =20 # 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 35a9eddf5c..f991d4274d 100644 --- a/meson.build +++ b/meson.build @@ -18,6 +18,9 @@ config_host =3D keyval.load(meson.current_build_dir() / '= config-host.mak') enable_modules =3D 'CONFIG_MODULES' in config_host enable_static =3D 'CONFIG_STATIC' in config_host =20 +# Allow both shared and static libraries unless --enable-static +static_kwargs =3D 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 =3D not_found if have_system or have_tools pixman =3D dependency('pixman-1', required: have_system, version:'>=3D0.= 21.8', - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) endif pam =3D not_found if 'CONFIG_AUTH_PAM' in config_host pam =3D cc.find_library('pam') endif libaio =3D cc.find_library('aio', required: false) -zlib =3D dependency('zlib', required: true, static: enable_static) +zlib =3D dependency('zlib', required: true, kwargs: static_kwargs) linux_io_uring =3D not_found if 'CONFIG_LINUX_IO_URING' in config_host linux_io_uring =3D declare_dependency(compile_args: config_host['LINUX_I= O_URING_CFLAGS'].split(), @@ -333,7 +336,7 @@ libnfs =3D not_found if not get_option('libnfs').auto() or have_block libnfs =3D dependency('libnfs', version: '>=3D1.9.3', required: get_option('libnfs'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) endif =20 libattr_test =3D ''' @@ -354,7 +357,7 @@ if not get_option('attr').disabled() else libattr =3D 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_LIBATT= R') libattr =3D not_found @@ -381,14 +384,14 @@ seccomp =3D not_found if not get_option('seccomp').auto() or have_system or have_tools seccomp =3D dependency('libseccomp', version: '>=3D2.3.0', required: get_option('seccomp'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) endif =20 libcap_ng =3D not_found if not get_option('cap_ng').auto() or have_system or have_tools libcap_ng =3D 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 @@ -409,7 +412,7 @@ if get_option('xkbcommon').auto() and not have_system a= nd not have_tools xkbcommon =3D not_found else xkbcommon =3D dependency('xkbcommon', required: get_option('xkbcommon'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) endif vde =3D not_found if config_host.has_key('CONFIG_VDE') @@ -445,13 +448,13 @@ libiscsi =3D not_found if not get_option('libiscsi').auto() or have_block libiscsi =3D dependency('libiscsi', version: '>=3D1.9.0', required: get_option('libiscsi'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) endif zstd =3D not_found if not get_option('zstd').auto() or have_block zstd =3D dependency('libzstd', version: '>=3D1.4.0', required: get_option('zstd'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) endif gbm =3D not_found if 'CONFIG_GBM' in config_host @@ -468,14 +471,14 @@ if not get_option('curl').auto() or have_block curl =3D dependency('libcurl', version: '>=3D7.29.0', method: 'pkg-config', required: get_option('curl'), - static: enable_static) + kwargs: static_kwargs) endif libudev =3D not_found if targetos =3D=3D 'linux' and (have_system or have_tools) libudev =3D dependency('libudev', method: 'pkg-config', required: get_option('libudev'), - static: enable_static) + kwargs: static_kwargs) endif =20 mpathlibs =3D [libudev] @@ -511,17 +514,17 @@ if targetos =3D=3D 'linux' and have_tools and not get= _option('mpath').disabled() }''' libmpathpersist =3D cc.find_library('mpathpersist', required: get_option('mpath'), - static: enable_static) + kwargs: static_kwargs) if libmpathpersist.found() mpathlibs +=3D libmpathpersist if enable_static mpathlibs +=3D cc.find_library('devmapper', required: get_option('mpath'), - static: enable_static) + kwargs: static_kwargs) endif mpathlibs +=3D cc.find_library('multipath', required: get_option('mpath'), - static: enable_static) + kwargs: static_kwargs) foreach lib: mpathlibs if not lib.found() mpathlibs =3D [] @@ -571,7 +574,7 @@ if have_system and not get_option('curses').disabled() curses =3D dependency(curses_dep, required: false, method: 'pkg-config', - static: enable_static) + kwargs: static_kwargs) endif endforeach msg =3D 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 =3D 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 =3D declare_dependency(compile_args: curses_compile_arg= s, @@ -647,7 +650,7 @@ brlapi =3D not_found if not get_option('brlapi').auto() or have_system brlapi =3D 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 #include @@ -663,7 +666,7 @@ endif =20 sdl =3D not_found if not get_option('sdl').auto() or (have_system and not cocoa.found()) - sdl =3D dependency('sdl2', required: get_option('sdl'), static: enable_s= tatic) + sdl =3D dependency('sdl2', required: get_option('sdl'), kwargs: static_k= wargs) sdl_image =3D not_found endif if sdl.found() @@ -671,7 +674,7 @@ if sdl.found() sdl =3D declare_dependency(compile_args: '-Wno-undef', dependencies: sdl) sdl_image =3D 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 =3D not_found if not get_option('rbd').auto() or have_block librados =3D cc.find_library('rados', required: get_option('rbd'), - static: enable_static) + kwargs: static_kwargs) librbd =3D 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 #include @@ -705,7 +708,7 @@ glusterfs_iocb_has_stat =3D false if not get_option('glusterfs').auto() or have_block glusterfs =3D dependency('glusterfs-api', version: '>=3D3', required: get_option('glusterfs'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) if glusterfs.found() glusterfs_ftruncate_has_stat =3D cc.links(''' #include @@ -744,7 +747,7 @@ libbzip2 =3D not_found if not get_option('bzip2').auto() or have_block libbzip2 =3D 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 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: li= bbzip2) @@ -761,7 +764,7 @@ liblzfse =3D not_found if not get_option('lzfse').auto() or have_block liblzfse =3D 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 @@ -798,12 +801,12 @@ if not get_option('gtk').auto() or (have_system and n= ot cocoa.found()) gtk =3D dependency('gtk+-3.0', version: '>=3D3.22.0', method: 'pkg-config', required: get_option('gtk'), - static: enable_static) + kwargs: static_kwargs) if gtk.found() gtkx11 =3D dependency('gtk+-x11-3.0', version: '>=3D3.22.0', method: 'pkg-config', required: false, - static: enable_static) + kwargs: static_kwargs) gtk =3D declare_dependency(dependencies: [gtk, gtkx11]) endif endif @@ -816,7 +819,7 @@ endif x11 =3D not_found if gtkx11.found() or 'lm32-softmmu' in target_dirs x11 =3D dependency('x11', method: 'pkg-config', required: gtkx11.found(), - static: enable_static) + kwargs: static_kwargs) endif vnc =3D not_found png =3D not_found @@ -825,12 +828,12 @@ sasl =3D not_found if get_option('vnc').enabled() vnc =3D declare_dependency() # dummy dependency png =3D dependency('libpng', required: get_option('vnc_png'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) jpeg =3D dependency('libjpeg', required: get_option('vnc_jpeg'), - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) sasl =3D cc.find_library('sasl2', has_headers: ['sasl/sasl.h'], required: get_option('vnc_sasl'), - static: enable_static) + kwargs: static_kwargs) if sasl.found() sasl =3D declare_dependency(dependencies: sasl, compile_args: '-DSTRUCT_IOVEC_DEFINED') @@ -841,7 +844,7 @@ snappy =3D not_found if not get_option('snappy').auto() or have_system snappy =3D 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 @@ -858,7 +861,7 @@ lzo =3D not_found if not get_option('lzo').auto() or have_system lzo =3D 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 @@ -893,7 +896,7 @@ u2f =3D not_found if have_system u2f =3D dependency('u2f-emu', required: get_option('u2f'), method: 'pkg-config', - static: enable_static) + kwargs: static_kwargs) endif usbredir =3D 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 =3D dependency('libkeyutils', required: false, - method: 'pkg-config', static: enable_static) + method: 'pkg-config', kwargs: static_kwargs) =20 has_gettid =3D cc.has_function('gettid') =20 @@ -979,7 +982,7 @@ endif =20 fuse =3D dependency('fuse3', required: get_option('fuse'), version: '>=3D3.1', method: 'pkg-config', - static: enable_static) + kwargs: static_kwargs) =20 fuse_lseek =3D not_found if not get_option('fuse_lseek').disabled() @@ -1364,7 +1367,7 @@ capstone_opt =3D get_option('capstone') if capstone_opt in ['enabled', 'auto', 'system'] have_internal =3D fs.exists(meson.current_source_dir() / 'capstone/Makef= ile') capstone =3D dependency('capstone', version: '>=3D4.0', - static: enable_static, method: 'pkg-config', + kwargs: static_kwargs, method: 'pkg-config', required: capstone_opt =3D=3D 'system' or capstone_opt =3D=3D 'enabled' and not ha= ve_internal) if capstone.found() @@ -1473,7 +1476,7 @@ if have_system slirp_opt =3D get_option('slirp') if slirp_opt in ['enabled', 'auto', 'system'] have_internal =3D fs.exists(meson.current_source_dir() / 'slirp/meson.= build') - slirp =3D dependency('slirp', static: enable_static, + slirp =3D dependency('slirp', kwargs: static_kwargs, method: 'pkg-config', required: slirp_opt =3D=3D 'system' or slirp_opt =3D=3D 'enabled' and not have_i= nternal) @@ -1551,7 +1554,7 @@ fdt_opt =3D get_option('fdt') if have_system if fdt_opt in ['enabled', 'auto', 'system'] have_internal =3D fs.exists(meson.current_source_dir() / 'dtc/libfdt/M= akefile.libfdt') - fdt =3D cc.find_library('fdt', static: enable_static, + fdt =3D cc.find_library('fdt', kwargs: static_kwargs, required: fdt_opt =3D=3D 'system' or fdt_opt =3D=3D 'enabled' and not have_= internal) if fdt.found() and cc.links(''' --=20 2.29.2