From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.12284.1676288355998877722 for ; Mon, 13 Feb 2023 03:39:16 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Il+Z05Up; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676288355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dVMc+mRLk9iqTf/Ho3QZd7clKDBjMUzZLvxU0/L9p8Q=; b=Il+Z05UpbrU3c8jAi95D5ZOZlY0JmducMmNPmG3/hofFkCr5pR6XbnlYriPxENEDWLJrnf gXzlsbWRSXzAHSyNloNa2ycQEV2MNxvwr37GST2YOP99gJ6RfKdVrQcuh4O9mLFA5f2FSO RWxUMU+QveEAn+nnlPrS8EHkdwuNzYo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-175-sM8nZNFCMCudzRo_V1vhWg-1; Mon, 13 Feb 2023 06:39:13 -0500 X-MC-Unique: sM8nZNFCMCudzRo_V1vhWg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E925811E6E; Mon, 13 Feb 2023 11:39:12 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2149140EBF4; Mon, 13 Feb 2023 11:39:11 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6061B1800082; Mon, 13 Feb 2023 12:39:10 +0100 (CET) Date: Mon, 13 Feb 2023 12:39:10 +0100 From: "Gerd Hoffmann" To: Ard Biesheuvel Cc: devel@edk2.groups.io, Pawel Polawski , Guomin Jiang , Tom Lendacky , Jiewen Yao , Xiaoyu Lu , Jordan Justen , Min Xu , Jian J Wang , Michael Roth , Oliver Steffen , James Bottomley , Erdem Aktas , Ard Biesheuvel Subject: Re: [PATCH v2 00/10] OvmfPkg: add Crypto Driver support Message-ID: <20230213113910.mjxt276su2eeqixt@sirius.home.kraxel.org> References: <20230209102648.2291743-1-kraxel@redhat.com> <20230210084157.s35f5j4rzkr6ibl7@sirius.home.kraxel.org> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 10, 2023 at 02:46:34PM +0100, Ard Biesheuvel wrote: > On Fri, 10 Feb 2023 at 14:42, Ard Biesheuvel wrote: > > > > > Can LTO be enabled for the NOOPT build? Or depends that on > > > optimizations being turned on? Turns out: kind of. The crypto driver effectively does if (fixed.pcd.bit) call libcrypt / libopenssl else throw error With optimizations turned off altogether gcc will not notice it can evaluate the PCD config bits at compile time, which in turn leads to everything being compiled in no matter whenever the features are enabled or not ... take care, Gerd >>From e0a080ead544813445f731eef137747ff805a5cd Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 13 Feb 2023 10:21:50 +0100 Subject: [PATCH 1/1] CryptoPkg/Driver: enable moderate optimizations for NOOPT builds With optimizations turned off altogether gcc will not evaluate the (constant) configuration PCDs at compile time (see CALL_BASECRYPTLIB macro). Which renders LTO ineffective and leads to huge amounts of dead code being included in the crypto driver builds. Turn on optimizations for GCC, lowest level (-O1), to fix this. FIXME: visual studio needs that too. Signed-off-by: Gerd Hoffmann --- CryptoPkg/Driver/CryptoDxe.inf | 3 +++ CryptoPkg/Driver/CryptoPei.inf | 3 +++ CryptoPkg/Driver/CryptoSmm.inf | 3 +++ 3 files changed, 9 insertions(+) diff --git a/CryptoPkg/Driver/CryptoDxe.inf b/CryptoPkg/Driver/CryptoDxe.inf index 0d08f3a190c8..44921c1fdaa8 100644 --- a/CryptoPkg/Driver/CryptoDxe.inf +++ b/CryptoPkg/Driver/CryptoDxe.inf @@ -47,3 +47,6 @@ [Pcd] [Depex] TRUE + +[BuildOptions] + GCC:NOOPT_*_*_CC_FLAGS = -O1 diff --git a/CryptoPkg/Driver/CryptoPei.inf b/CryptoPkg/Driver/CryptoPei.inf index dfa1ab58b16f..45704f5f9e42 100644 --- a/CryptoPkg/Driver/CryptoPei.inf +++ b/CryptoPkg/Driver/CryptoPei.inf @@ -49,3 +49,6 @@ [Pcd] [Depex] TRUE + +[BuildOptions] + GCC:NOOPT_*_*_CC_FLAGS = -O1 diff --git a/CryptoPkg/Driver/CryptoSmm.inf b/CryptoPkg/Driver/CryptoSmm.inf index 9fe8718823d2..906cf06006f4 100644 --- a/CryptoPkg/Driver/CryptoSmm.inf +++ b/CryptoPkg/Driver/CryptoSmm.inf @@ -47,3 +47,6 @@ [Pcd] [Depex] TRUE + +[BuildOptions] + GCC:NOOPT_*_*_CC_FLAGS = -O1 -- 2.39.1