From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id CA935D801B2 for ; Tue, 12 Dec 2023 00:42:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=YN+8bgww7oKGa8lfKVkFQjqNvlP5SnYvLRm5SkaMebU=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702341721; v=1; b=i8vqWWGgnhFxgfARjLWet8RRhbc7gQhQldztDTGEAeN8GN8AjyYMUNKkrFp13WM2FsFUCiTD VkKFR0iY+rJTsMVx4/PpiXNcHonloy26FsVfOgVQDFDkx6NaYtSCofHWxRO7NdbSZ8XO7YyIpwL wMp9Emgmg82XSB52qms1l/Tk= X-Received: by 127.0.0.2 with SMTP id In6qYY7687511x2F3oVtU3t8; Mon, 11 Dec 2023 16:42:01 -0800 X-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.web11.1279.1702341720776379262 for ; Mon, 11 Dec 2023 16:42:00 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-nh_06fywPrCDCCQTAlO9vQ-1; Mon, 11 Dec 2023 19:41:56 -0500 X-MC-Unique: nh_06fywPrCDCCQTAlO9vQ-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8D13185A782; Tue, 12 Dec 2023 00:41:55 +0000 (UTC) X-Received: from [10.39.192.110] (unknown [10.39.192.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E68BE51E3; Tue, 12 Dec 2023 00:41:54 +0000 (UTC) Message-ID: <1a51ab01-6a06-af3d-5068-86e6668fd6ec@redhat.com> Date: Tue, 12 Dec 2023 01:41:53 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] BaseTools/tools_def: Disable unneeded-internal-declaration warning in CLANGPDB To: Mike Beaton Cc: devel@edk2.groups.io, Ard Biesheuvel , Ard Biesheuvel References: <20231210101859.19198-1-mjsbeaton@gmail.com> <9b333ba1-7ce6-5be7-6482-3aadef7f1973@redhat.com> <12387048-80bf-87db-c15e-55583678863f@redhat.com> From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: VwSsSV8ZgGheQ68R7lC9fVoOx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=i8vqWWGg; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 12/11/23 18:26, Mike Beaton wrote: >>> I believe this would be logically wrong, as the other versions still >>> wouldn't compile if you changed the relevant debug Pcds. (Which are >>> logically independent of the compile and link options - e.g. what if fo= r >>> some reason you wanted to single step with the Debug Pcds set to >>> disabled, in a NOOPT build?) >> >> I don't think that use case exists in practice. >> >> Anyway, my suggestion is based on prior art: I *think* we ask gcc to >> whine about unused local variables in RELEASE builds only, too. See >> commits 20d00edf21d2 ("BaseTools/GCC: set -Wno-unused-but-set-variables >> only on RELEASE builds", 2016-03-25) and 8b6366f87584 ("BaseTools/GCC: >> set -Wno-unused-const-variable on RELEASE builds", 2017-09-08). >> >> ... TBH I don't understand the current state of >> "-Wno-unused-but-set-variables" and "-Wno-unused-const-variable" between >> X64 and AARCH64, considering the DEBUG target. Today, >> DEBUG_GCC5_AARCH64_CC_FLAGS disables these warnings, but >> DEBUG_GCC5_X64_CC_FLAGS doesn't, even though *both* macros specify >> -flto. Compare commit 06c8a34cc4bc ("BaseTool/tools_def GCC5: enable >> optimization for ARM/AARCH64 DEBUG builds", 2017-12-08) -- I don't >> understand why "-flto" had to be accompanied by >> "-Wno-unused-but-set-variable -Wno-unused-const-variable" in that commit= . >> >> In brief, IA32 and X64 prior art supports my suggestion to shut up the >> warning only for RELEASE (for CLANGPDB too), but ARM/AARCH64 prior art >> contradicts that proposal. IOW, prior art is inconsistent per se... I >> don't understand. >> >> Laszlo >=20 > Hunting around further, it is not the Pcds which are causing this to > be optimised away, but the definition of MDEPKG_NDEBUG. >=20 > A completely different approach, which allows clang to spot that the > usage has been 'optimised away' and so to not complain (and therefore > allows us to re-enable the warning in CLANGDWARF as well), is the > following: >=20 > --- a/MdePkg/Include/Library/DebugLib.h > +++ b/MdePkg/Include/Library/DebugLib.h > @@ -426,7 +426,10 @@ UnitTestDebugAssert ( > } \ > } while (FALSE) > #else > -#define DEBUG(Expression) > +#define DEBUG(Expression) \ > + if (FALSE) { \ > + _DEBUG (Expression); \ > + } > #endif >=20 > /** >=20 But will this not litter the object files with a bunch of format strings etc? It feels like, for CLANGPDB (and maybe CLANGDWARF), the RELEASE target should not define MDEPKG_NDEBUG, but make sure (instead) that DebugPrintEnabled() evals to FALSE. If PcdDebugPropertyMask is fixed-at-build, then DebugPrintEnabled() should be possible to evaluate at compile time; is that right? (At least for clang?) Laszlo -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112349): https://edk2.groups.io/g/devel/message/112349 Mute This Topic: https://groups.io/mt/103087794/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-