public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: "Simon Glass" <sjg@chromium.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"Bill Mills" <bill.mills@linaro.org>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"François Ozog" <francois.ozog@linaro.org>,
	"Masahiro Yamada" <yamada.masahiro@socionext.com>
Subject: Re: [PATCH 02/31] kconfig: Add support for conditional values
Date: Thu, 13 Jan 2022 10:29:48 -0500	[thread overview]
Message-ID: <20220113152948.GL9207@bill-the-cat> (raw)
In-Reply-To: <1c45eb3c-678c-017b-82c2-942fcf7be1bb@prevas.dk>

[-- Attachment #1: Type: text/plain, Size: 3624 bytes --]

On Thu, Jan 13, 2022 at 04:01:45PM +0100, Rasmus Villemoes wrote:
> On 13/01/2022 13.52, Tom Rini wrote:
> > On Thu, Jan 13, 2022 at 08:56:02AM +0100, Rasmus Villemoes wrote:
> >> On 12/01/2022 22.56, Tom Rini wrote:
> >>> I also think I've seen cases where doing:
> >>> if (CONFIG_EVALUATES_TO_ZERO) {
> >>>   ...
> >>> }
> >>>
> >>> takes more space in the binary than an #ifdef does.
> >>
> >> Please provide a specific example. If CONFIG_EVALUATES_TO_ZERO is any
> >> integer-constant-expression evaluating at compile-time to 0, gcc throws
> >> away the whole block very early during parsing. If it doesn't, that's a
> >> compiler bug, so let's please not make decisions based on
> >> not-even-anecdotal data.
> > 
> > OK.  I believe it was commit 7856cd5a6dd6 ("Convert CONFIG_SYS_PCI_64BIT
> > to Kconfig") a few platforms changed size 
> 
> Can you remember which ones? I'd like to see if I can reproduce.
> 
> That said, that commit made the Kconfig symbol 'default y if PPC'. Are
> you really sure all ppc-boards that set CONFIG_PCI also used to set
> SYS_PCI_64BIT?
> 
> And another thing I notice is that a lot of the #define removals remove
> 
> #define CONFIG_SYS_PCI_64BIT
> 
> and not
> 
> #define CONFIG_SYS_PCI_64BIT 1
> 
> Now that doesn't matter for the places that test the definedness of
> CONFIG_SYS_PCI_64BIT, because kconfig either doesn't define it or define
> it with value 1. But it does matter for (the single) IS_ENABLED() use,
> because IS_ENABLED(bla) evaluates to 1 if and only if bla expands to 1.
> Or rather, if and only if __ARG_PLACEHOLDER_ concatenated with the
> expansion of bla in turn expands to "0, " - which only happens if we hit
> the __ARG_PLACEHOLDER_1 macro.
> 
> So when bla is defined with an empty expansion, for the purpose of
> IS_ENABLED, it might as well not be defined or expand to 0 or to
> gobbledygook.
> 
> And when one knows what to look for, it's easy to demonstrate:
> 
> $ export ARCH=ppc
> $ export CROSS_COMPILE=powerpc-linux-gnu-
> $ git checkout 7856cd5a6dd6~1
> $ make T1042D4RDB_defconfig
> $ make drivers/pci/pci-uclass.i
> $ grep -C3 'beyond the 32-bit boundary' drivers/pci/pci-uclass.i
> 
>   if (!(0) &&
>       type == 0x00000000 && ((u32)(((pci_addr) >> 16) >> 16))) {
>    ({ if (0) printf(" - beyond the 32-bit boundary, ignoring\n"); });
>    continue;
>   }
> 
> $ git checkout 7856cd5a6dd6
> $ make T1042D4RDB_defconfig
> $ make drivers/pci/pci-uclass.i
> $ grep -C3 'beyond the 32-bit boundary' drivers/pci/pci-uclass.i
> 
>   if (!(1) &&
>       type == 0x00000000 && ((u32)(((pci_addr) >> 16) >> 16))) {
>    ({ if (0) printf(" - beyond the 32-bit boundary, ignoring\n"); });
>    continue;
>   }
> 
> Whether that change makes the generated code smaller or larger I can't
> say, but it's certainly not a nop semantically. [Of course, the change
> is for the better, as the generated code now matches the intention;
> previously 64 bit pci addresses would be ignored for the boards that had
> an empty definition of CONFIG_SYS_PCI_64BIT.]
> 
> But it has nothing whatsoever to do with whether gcc is capable of
> throwing away a whole "if (0)" block. But I will believe that other
> Kconfig conversions have been bit by the same issue, making it _seem_
> like IS_ENABLED() is somehow at fault and #ifdefs are "better".

Yes, that's what happened there, thanks for digging in and explaining.
What I really meant by "better" was "same size when converting" which is
important when migrating a ton of machines I can only very partially
test.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2022-01-13 15:29 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01  1:17 [PATCH 00/31] passage: Define a standard for firmware data flow Simon Glass
2021-11-01  1:17 ` [PATCH 01/31] Makefile: Correct TPL rule for OF_REAL Simon Glass
2021-11-01  6:54   ` Ilias Apalodimas
2021-11-14  0:34     ` Simon Glass
2021-11-01  1:17 ` [PATCH 02/31] kconfig: Add support for conditional values Simon Glass
2021-11-01  7:05   ` Ilias Apalodimas
2022-01-12 21:28     ` Simon Glass
2022-01-12 21:56       ` Tom Rini
2022-01-12 22:22         ` Simon Glass
2022-01-12 23:04           ` Tom Rini
2022-01-13  7:56         ` Rasmus Villemoes
2022-01-13 12:52           ` Tom Rini
2022-01-13 13:56             ` Simon Glass
2022-01-13 15:01             ` Rasmus Villemoes
2022-01-13 15:29               ` Tom Rini [this message]
2021-11-01  1:17 ` [PATCH 03/31] dm: core: Allow getting some basic stats Simon Glass
2021-11-01  7:07   ` Ilias Apalodimas
2021-11-01  1:17 ` [PATCH 04/31] stddef: Avoid warning with clang with offsetof() Simon Glass
2022-01-13  8:08   ` Rasmus Villemoes
2022-01-13 13:07     ` Tom Rini
2022-01-13 13:37       ` Simon Glass
2022-01-13 13:41         ` Tom Rini
2022-01-13 13:50           ` Simon Glass
2021-11-01  1:17 ` [PATCH 05/31] fdt: Drop SPL_BUILD macro Simon Glass
2021-11-01  7:42   ` Ilias Apalodimas
2021-11-01  1:17 ` [PATCH 06/31] bloblist: Put the magic number first Simon Glass
2021-11-01  1:17 ` [PATCH 07/31] bloblist: Rename the SPL tag Simon Glass
2021-11-01  1:17 ` [PATCH 08/31] bloblist: Drop unused tags Simon Glass
2021-11-01  1:17 ` [PATCH 09/31] bloblist: Use explicit numbering for the tags Simon Glass
2021-11-01  1:17 ` [PATCH 10/31] bloblist: Support allocating the bloblist Simon Glass
2021-11-01  1:17 ` [PATCH 11/31] bloblist: Use LOG_CATEGORY to simply logging Simon Glass
2021-11-01  1:17 ` [PATCH 12/31] bloblist: Use 'phase' consistently for bloblists Simon Glass
2021-11-01  1:17 ` [PATCH 13/31] bloblist: Refactor Kconfig to support alloc or fixed Simon Glass
2021-11-01  1:17 ` [PATCH 14/31] arm: qemu: Add an SPL build Simon Glass
2021-11-01  1:17 ` [PATCH 15/31] bloblist: Add functions to obtain base address and size Simon Glass
2021-11-01  1:17 ` [PATCH 16/31] passage: Support an incoming passage Simon Glass
2021-11-01  1:17 ` [PATCH 17/31] passage: Support a control devicetree Simon Glass
2021-11-01  1:17 ` [PATCH 18/31] passage: arm: Accept a passage from the previous phase Simon Glass
2021-11-01  1:17 ` [PATCH 19/31] passage: spl: Support adding the dtb to the passage bloblist Simon Glass
2021-11-01  1:17 ` [PATCH 20/31] passage: spl: Support passing the passage to U-Boot Simon Glass
2021-11-01  1:17 ` [PATCH 21/31] passage: Record where the devicetree came from Simon Glass
2021-11-01  1:17 ` [PATCH 22/31] passage: Report the devicetree source Simon Glass
2021-11-01  1:17 ` [PATCH 23/31] passage: Add a qemu test for ARM Simon Glass
2021-11-01  1:17 ` [PATCH 24/31] bloblist: doc: Bring in the API documentation Simon Glass
2021-11-01  1:17 ` [PATCH 25/31] bloblist: Relicense to allow BSD-3-Clause Simon Glass
2021-11-01  1:17 ` [PATCH 26/31] sandbox: Add a way of checking structs for standard passage Simon Glass
2021-11-01  1:17 ` [PATCH 27/31] passage: Add documentation Simon Glass
2021-11-01  1:17 ` [PATCH 28/31] passage: Add docs for spl_handoff Simon Glass
2021-11-01  1:17 ` [PATCH 29/31] x86: Move Intel GNVS file into the common include directory Simon Glass
2021-11-01  1:17 ` [PATCH 30/31] passage: Add checks for pre-existing blobs Simon Glass
2021-11-01  1:17 ` [PATCH 31/31] WIP: RFC: Add a gitlab test Simon Glass
2021-11-01  8:53 ` [PATCH 00/31] passage: Define a standard for firmware data flow François Ozog
2021-11-01 18:19   ` Mark Kettenis
2021-11-01 20:45     ` François Ozog
2021-11-02 14:58   ` Simon Glass
2021-11-02 16:03     ` François Ozog
2021-11-05  2:02       ` Simon Glass
2021-11-05  8:26         ` François Ozog
2021-11-05 16:12           ` Simon Glass
2021-11-05 16:31             ` François Ozog
2021-11-05 17:16               ` Simon Glass
2021-11-08 16:20                 ` François Ozog
2021-11-10 19:37                   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220113152948.GL9207@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=bill.mills@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=francois.ozog@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox