From patchwork Thu Sep 3 11:21:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 248994 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp350031ilg; Thu, 3 Sep 2020 04:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTO0xeWEcycveWLFZIcIxR/vvuvfy60+4BsAieJcyW6GAud0w4fy0GdY9YxDrmYTb9sY+W X-Received: by 2002:a5b:450:: with SMTP id s16mr2046195ybp.237.1599132179941; Thu, 03 Sep 2020 04:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599132179; cv=none; d=google.com; s=arc-20160816; b=GiaXUPcz7VSq1uCR1YcSlp5C4egndXHcpfi2v5NjWq9EZ+Cp7cEqTf752mdaXDT1S2 GuO5KsSbz+CH2cxOFsse/D8YItXoItfBotdernhxnvuMNGAp1S7N2cwjSBKk2mh8awBr vDOUMqzdJWUg9iDgDVPZ72qOrCugFk5K1YDlwAFntQPq67RRQUNjz95T4B0FTRY02RDw QDEnsiHw7l9VPoU0wqRwumBXQwjdzBykrLK51BN1n3WRqJTGBcJFfVcKT8LfOmdUnerA M0xP2c8HQ/rz75sFaLuSDatmRFzWhd5ibb0oKz2IAnGvvYtUTs504pLXts7huCnKytRv Mmrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=z5RvT4eB7MnQELSA2qZHA1d+KPyyThIlq3rK75djlgU=; b=H7qRHd+eFdNaUCG1v3O6li92rk+VsBhbLHzYhGU7RJeuVntreVZPc6QU6hq2XAb8Zq vtr7b2I8M3nf9QFNP5gK+azkVU5GfSSBI1QmFMHf6y0yzsuetSfT1igxuyvt+bPBXZd1 YpJdo3bwFWhVK7Pn1NodSeIoeye4GOd0L7XDgozZySiqxM4ri0IzXo2nWW34XByUOvlX OoWTKfCuXyQcaadt7fyJgUadhmfnHMFQEjPlPyJt7V16D1uOFUr9la3dAlPr3UrfAtl4 /+NsP3rYsTOn4raabCNPn1NjB/wTLhFa/G1/fMSWzQWSDVh0hdmGs7Ug8eV1X88rlX4s BffA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X6GtVzYW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z14si1021763ybp.423.2020.09.03.04.22.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Sep 2020 04:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X6GtVzYW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDnKV-00051K-ES for patch@linaro.org; Thu, 03 Sep 2020 07:22:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDnIp-0002Rq-UD for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:21:15 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:55513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kDnIo-0007ZB-0G for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:21:15 -0400 Received: by mail-wm1-x330.google.com with SMTP id a65so2459391wme.5 for ; Thu, 03 Sep 2020 04:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z5RvT4eB7MnQELSA2qZHA1d+KPyyThIlq3rK75djlgU=; b=X6GtVzYWz+SPJh7EUuaGmaf+o6y55m2OL85XdfGSbHoDWVCmjqRCS+CJGFQ3P0v4RO pzc4mogmTeB/dmYuIghrn/jj50TuOVpnsLCt6Okkbvd9i3cCQRY5ljPJjPhURM+n56TG tkk/g+mdtmAeC6JRtmvUDhHCkc8/S0HYj2kvG41rxVr3dN0ysAiTl+gzwjYqBrZtojST f1CYO8qtQc+q+hGKBIgMubSYbPt1JkoxBPZs4Cjbqitx3k3hO2KQf8eRx0yW/f4rwvVl LXmtNDV7hrZ2+OBZiIoJ+EnD3vf23s/8qOWYWWdbEY9qs+RwgOH5HLQc99Ce2ddlqG2C ARNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z5RvT4eB7MnQELSA2qZHA1d+KPyyThIlq3rK75djlgU=; b=Yp1JUvRz3P/79JVUo9sf4U7zoMcORPnjVU/H/oPOYf3yw8M079p3S5INJihYw3CY1M wSR6uEhquNhVFPPNT1/aX3HbQuHfp3Ap738qksugzZ1Cn2Znf4lXRjqsYYFPJHJytnwP jLfxOjd4LCR1p4X4IzQeGaJ32ddTGFbx+8FAwr5QFTg1dmEdmOEIiEtlZ+aeKIOd/oMN X7OnsPE1pZR7S2qmSjRjtNV5YOawpCblP0ARMHg51IcdmQ2Ro/SFwTdB3kkDMD1tUJ1a 4aOg+o4vcd3HWtJyp+kJSn4TnUtgcPwb/rhggehkUvv7/1jJZPk1BcBCWP7KkAsXutXM gzwA== X-Gm-Message-State: AOAM532OcmnW5TY9nSHpuQYBvMV4DPLwOs8veJP23NfCuaCCu9ZMCWN/ iffR+qT4jtwh73iYpeR+1ruSHA== X-Received: by 2002:a7b:c38f:: with SMTP id s15mr963802wmj.16.1599132072571; Thu, 03 Sep 2020 04:21:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e18sm3977022wrx.50.2020.09.03.04.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:21:08 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E2F161FF8C; Thu, 3 Sep 2020 12:21:07 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 2/8] crypto: fix build with gcrypt enabled Date: Thu, 3 Sep 2020 12:21:01 +0100 Message-Id: <20200903112107.27367-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200903112107.27367-1-alex.bennee@linaro.org> References: <20200903112107.27367-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, stefanb@linux.vnet.ibm.com, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, cota@braap.org, stefanha@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Daniel P. Berrangé If nettle is disabled and gcrypt enabled, the compiler and linker flags needed for gcrypt are not passed. Gnutls was also not added as a dependancy when gcrypt is enabled. Attempting to add the library dependencies at the same time as the source dependencies is error prone, as there are alot of different rules for picking which sources to use, and some of the source files use code level conditionals intead. It is thus clearer to add the library dependencies separately. Signed-off-by: Daniel P. Berrangé Signed-off-by: Alex Bennée Message-Id: <20200901133050.381844-2-berrange@redhat.com> --- configure | 2 ++ crypto/meson.build | 42 +++++++++++++++++++++++++++++++----------- meson.build | 5 +++++ 3 files changed, 38 insertions(+), 11 deletions(-) -- 2.20.1 Tested-by: Richard Henderson Reviewed-by: Richard Henderson diff --git a/configure b/configure index cc9af723580..1f61e363a18 100755 --- a/configure +++ b/configure @@ -6953,6 +6953,8 @@ if test "$gcrypt" = "yes" ; then if test "$gcrypt_hmac" = "yes" ; then echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak fi + echo "GCRYPT_CFLAGS=$gcrypt_cflags" >> $config_host_mak + echo "GCRYPT_LIBS=$gcrypt_libs" >> $config_host_mak fi if test "$nettle" = "yes" ; then echo "CONFIG_NETTLE=y" >> $config_host_mak diff --git a/crypto/meson.build b/crypto/meson.build index 18da7c8541d..f6f5ce1ecd0 100644 --- a/crypto/meson.build +++ b/crypto/meson.build @@ -23,24 +23,35 @@ crypto_ss.add(files( 'tlssession.c', )) -if 'CONFIG_GCRYPT' in config_host - wo_nettle = files('hash-gcrypt.c', 'pbkdf-gcrypt.c') +if 'CONFIG_NETTLE' in config_host + crypto_ss.add(files('hash-nettle.c', 'hmac-nettle.c', 'pbkdf-nettle.c')) +elif 'CONFIG_GCRYPT' in config_host + crypto_ss.add(files('hash-gcrypt.c', 'pbkdf-gcrypt.c')) + if 'CONFIG_GCRYPT_HMAC' in config_host + crypto_ss.add(files('hmac-gcrypt.c')) + else + crypto_ss.add(files('hmac-glib.c')) + endif else - wo_nettle = files('hash-glib.c', 'pbkdf-stub.c') -endif -if 'CONFIG_GCRYPT_HMAC' not in config_host - wo_nettle += files('hmac-glib.c') + crypto_ss.add(files('hash-glib.c', 'hmac-glib.c', 'pbkdf-stub.c')) endif -crypto_ss.add(when: [nettle, 'CONFIG_NETTLE'], - if_true: files('hash-nettle.c', 'hmac-nettle.c', 'pbkdf-nettle.c'), - if_false: wo_nettle) crypto_ss.add(when: 'CONFIG_SECRET_KEYRING', if_true: files('secret_keyring.c')) crypto_ss.add(when: 'CONFIG_QEMU_PRIVATE_XTS', if_true: files('xts.c')) -crypto_ss.add(when: 'CONFIG_GCRYPT_HMAC', if_true: files('hmac-gcrypt.c')) crypto_ss.add(when: 'CONFIG_AF_ALG', if_true: files('afalg.c', 'cipher-afalg.c', 'hash-afalg.c')) crypto_ss.add(when: 'CONFIG_GNUTLS', if_true: files('tls-cipher-suites.c')) +if 'CONFIG_NETTLE' in config_host + crypto_ss.add(nettle) +elif 'CONFIG_GCRYPT' in config_host + crypto_ss.add(gcrypt) +endif + +if 'CONFIG_GNUTLS' in config_host + crypto_ss.add(gnutls) +endif + + crypto_ss = crypto_ss.apply(config_host, strict: false) libcrypto = static_library('crypto', crypto_ss.sources() + genh, dependencies: [crypto_ss.dependencies()], @@ -52,12 +63,21 @@ crypto = declare_dependency(link_whole: libcrypto, util_ss.add(files('aes.c')) util_ss.add(files('init.c')) + if 'CONFIG_GCRYPT' in config_host util_ss.add(files('random-gcrypt.c')) elif 'CONFIG_GNUTLS' in config_host - util_ss.add(files('random-gnutls.c'), gnutls) + util_ss.add(files('random-gnutls.c')) elif 'CONFIG_RNG_NONE' in config_host util_ss.add(files('random-none.c')) else util_ss.add(files('random-platform.c')) endif + +if 'CONFIG_GCRYPT' in config_host + util_ss.add(gcrypt) +endif + +if 'CONFIG_GNUTLS' in config_host + util_ss.add(gnutls) +endif diff --git a/meson.build b/meson.build index 55c7d2318cd..9b5076452b2 100644 --- a/meson.build +++ b/meson.build @@ -116,6 +116,11 @@ urcubp = not_found if 'CONFIG_TRACE_UST' in config_host urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split()) endif +gcrypt = not_found +if 'CONFIG_GCRYPT' in config_host + gcrypt = declare_dependency(compile_args: config_host['GCRYPT_CFLAGS'].split(), + link_args: config_host['GCRYPT_LIBS'].split()) +endif nettle = not_found if 'CONFIG_NETTLE' in config_host nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),