From nobody Tue Feb 10 12:43:00 2026 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=1612825364; cv=none; d=zohomail.com; s=zohoarc; b=KFuLqVJg5t/KyKuowhpkOUH7uVqvpWriP62i3rSeY8RZjHegKoAkMPLY/7+RRuXd7dFsLV0B4clPrhCHYw/Y3+TSBqQCJ8XPYETxpn7/gJg3NIbfvb5ZcqL7Mq/8s5dt53fZthzjEoWb6cQV1fnfSp32x6x49ywhou8QK0EfTZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612825364; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v3nWXJKoken2wu6yZkOmxurevNjqlczbSMx4DrujPTw=; b=jVdcKPYGkBPRIOWFDPOedndF8PdvtvZXVu+nMhrdLrwX63Cl2ltNtpwdndNFJ/rtqMiK/h/qiyuGkwSOce+pf13rJmhN3UEnnPd6OZkKGbkTpWdH73gdj2lAhZnSBWxE/stUYQjsZkYArR7/qzoV5k7OlO2sYQL7ZkAdn2BSCWY= 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 1612825364329184.71917753280604; Mon, 8 Feb 2021 15:02:44 -0800 (PST) Received: from localhost ([::1]:54024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9FYJ-0008Ca-4y for importer@patchew.org; Mon, 08 Feb 2021 18:02:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9BCM-00031W-VP for qemu-devel@nongnu.org; Mon, 08 Feb 2021 13:23:46 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:45574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9BCK-00064n-7F for qemu-devel@nongnu.org; Mon, 08 Feb 2021 13:23:46 -0500 Received: by mail-wr1-x42e.google.com with SMTP id m13so18329840wro.12 for ; Mon, 08 Feb 2021 10:23:43 -0800 (PST) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id x22sm19670wmc.25.2021.02.08.10.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 10:23:42 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=v3nWXJKoken2wu6yZkOmxurevNjqlczbSMx4DrujPTw=; b=YgVvYOUy1L1v3NTOCR5+OI9ZNf/nC0Zwnfkazwc1Pk+BcTZORx00iuuTRsOYETBzYR KB6tuhrXMv54mKqfqd7+VJdYADXTrlCiQhc5emOWSZn/tu3hNg3UCm/3DYbFODCZFyTJ Pgip8XPkNFhUfjgxe47j+8E+fjGaaYuj/95kzVekUd8RWI9O3J6Hh47I0EZCDQ33BNM9 BJ+6FnEjdcjCS2BHoG/t7X7vvGLZTZS9XXSDnCEzAI4pmdKE4idcXGavbeWNo7PlAib/ UFOkfgt/qNFXUpypPzUri1fIqk48Op5MaDOrhMIPnDt8YX4MxBdzIi+o51LPjJx2p0ZF Ej1g== 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 :in-reply-to:references:mime-version:content-transfer-encoding; bh=v3nWXJKoken2wu6yZkOmxurevNjqlczbSMx4DrujPTw=; b=llt0fi1/7pecL78apQseGBrtPAsf9FxThAmRc0XzOgBysRcMcbE7CPjk385iaRbqfT E/bGEYUjyth3MUNdp7G/HaFgwpSD5Z9CBd+pFdx618U4ODzzMKvUb050qmQpcs7uJpes WNHEKcBWkEyAn/XgCvKAKwem2CjmnVRLae6TMEb6989hU9no2lAkz33Ck/YU9gtAK7w+ OtAud2GXCixnl8NWpLIPDrkL3R66UPCqZjtwdWqX9WR5mDZoMguzgw86ZslsP2fnMd5e Zb2+hapzdP2QElFJKIHNFPFrCZ/rNlcH/Tvvnzijd4t71nop74BAKndr8Nv4vKaC2a8I fS+A== X-Gm-Message-State: AOAM531COo72LdznBEwrlZRQPbjDzVAN5zixaKjTDhVDDM2HRqV8Ah8R I63Y1U7tp+BBoCbNd4lkerEoQhcTWfvQAg== X-Google-Smtp-Source: ABdhPJzcE5bcO1Imk5qKAlV0McXqjza6V/zdImTLyJx+wdkWxykoB1YbkdTXhsgXtoPUSTmwIOIofw== X-Received: by 2002:a5d:6b47:: with SMTP id x7mr21641023wrw.170.1612808622815; Mon, 08 Feb 2021 10:23:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/46] meson: accept either shared or static libraries if --disable-static Date: Mon, 8 Feb 2021 19:22:55 +0100 Message-Id: <20210208182331.58897-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210208182331.58897-1-pbonzini@redhat.com> References: <20210208182331.58897-1-pbonzini@redhat.com> 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::42e; envelope-from=paolo.bonzini@gmail.com; helo=mail-wr1-x42e.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.248, 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: Peter Lieven 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 --- 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 2d8b433ff0..6d6537d74a 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() @@ -1367,7 +1370,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() @@ -1477,7 +1480,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) @@ -1556,7 +1559,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