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 4F5F09413FC for ; Tue, 12 Dec 2023 08:48:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=RJx48H1qFbsPi6GsgIvsVM2HiahqVGz6LQ8rryt4aKo=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1702370907; v=1; b=tnr9fsGtSc4xfqc5E3/Jwm4e6aViOMx3nHmlP9NaVXg0h1KyTvfV5AwLxKjmrWHQY7yMW3Y1 aYCG2EQEqqSgeyH5s84VoTYmpOzT1w/ebajIFRFiDutu9HDiqv0yGNcXvPGCco/uS4POK7kCCKd Sy9xB2TlmCI4taI5h7jTzayQ= X-Received: by 127.0.0.2 with SMTP id wMdgYY7687511xFz6JFEQzxl; Tue, 12 Dec 2023 00:48:27 -0800 X-Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mx.groups.io with SMTP id smtpd.web11.12538.1702370907072274780 for ; Tue, 12 Dec 2023 00:48:27 -0800 X-Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40c41df5577so23557175e9.0 for ; Tue, 12 Dec 2023 00:48:26 -0800 (PST) X-Gm-Message-State: Yg4Uk7VhY7P7AjEI2nsDdy8Cx7686176AA= X-Google-Smtp-Source: AGHT+IGXhdTKj1oBSMVBnPzkHvN4zyafzNYv8jEeBV3x2GSkB2c7OPab2ShVLjMjL1KbhWR2JFp6Rl1R44zMyGodfag= X-Received: by 2002:a05:600c:524e:b0:40c:1257:77ba with SMTP id fc14-20020a05600c524e00b0040c125777bamr1206702wmb.36.1702370905174; Tue, 12 Dec 2023 00:48:25 -0800 (PST) MIME-Version: 1.0 References: <20231210101859.19198-1-mjsbeaton@gmail.com> <9b333ba1-7ce6-5be7-6482-3aadef7f1973@redhat.com> <12387048-80bf-87db-c15e-55583678863f@redhat.com> <1a51ab01-6a06-af3d-5068-86e6668fd6ec@redhat.com> In-Reply-To: From: "Mike Beaton" Date: Tue, 12 Dec 2023 08:48:13 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH] BaseTools/tools_def: Disable unneeded-internal-declaration warning in CLANGPDB To: Ard Biesheuvel Cc: Laszlo Ersek , devel@edk2.groups.io, Ard Biesheuvel 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,mjsbeaton@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=tnr9fsGt; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io I have realised that this was already fixed (i.e. allowing keeping the warning) in Acidanthera fork of EDK-II. Discussed here https://bugzilla.tianocore.org/show_bug.cgi?id=3704 - includes the fix in question and other fixes for newer gcc as well. I'll post a new patch to the list proposing just the relevant fix for clang. On Tue, 12 Dec 2023 at 07:49, Ard Biesheuvel wrote: > > On Tue, 12 Dec 2023 at 08:17, Mike Beaton wrote: > > > > > > 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: > > > > > > > > --- 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 > > > > > > > > /** > > > > > > > > > > But will this not litter the object files with a bunch of format strings > > > etc? > > > > Yes. Which would be optimized away at link time. (Or rather, I believe > > so, would need further tests to confirm exactly what is optimized away > > when.) > > > > Link time optimization does not usually optimize away assets at this > granularity. Even if --gc-sections is set, the only thing it can > optimize away is an entire input section. > > However, the compiler should be smart enough not to emit any > references to format strings etc in the first place, as it knows the > condition can never become true (but NOOPT builds should retain them). > > > > 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?) > > > > Yes, that is my understanding of how compile-time Pcds work too - but > > wouldn't the net result be the same as what I suggested? > > It depends on the kind of access. For PCDs that are fixed-at-build > only, the FixedPcdGet###() accessors will evaluate to constant > preprocessor expressions, allowing the compiler to do optimizations. > The ordinary PcdGet###() routines will not produce compile time > constant expressions in the same way, so there, all the logic is > retained (again, modulo LTO) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112362): https://edk2.groups.io/g/devel/message/112362 Mute This Topic: https://groups.io/mt/103087794/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-