Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Nevo Hed <nhed+buildroot@starry.com>,
	Romain Naour <romain.naour@gmail.com>,
	Peter Korsgaard <peter@korsgaard.com>
Cc: thomas.petazzoni@bootlin.com, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] core: Use of percent_defconfig seems to impact performance
Date: Sat, 21 Jan 2023 23:27:52 +0100	[thread overview]
Message-ID: <20230121222752.GF558596@scaer> (raw)
In-Reply-To: <20230105015759.63582-2-nhed+buildroot@starry.com>

Nevo, All,

+Romain who reported an issue
+Peter the backport to stable branches

On 2023-01-04 20:57 -0500, Nevo Hed via buildroot spake thusly:
> Noticed a significant slowdown with rise of number of external trees
> in our env.  This slowdown seemed to be related to invocations if the
> percent_defconfig function (GNU Make 4.3).
n        
> Signed-off-by: Nevo Hed <nhed+buildroot@starry.com>
> ---
>  Makefile | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 88f90cd2fa..ad866f1f24 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1013,13 +1013,14 @@ oldconfig syncconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmake
>  defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
>  	@$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
>  
> -define percent_defconfig
> -# Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig

So, the following change:

> -%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig outputmakefile
[--SNIP--]
> +%_defconfig: $(BUILD_DIR)/buildroot-config/conf  outputmakefile

broke the build when the output directory ends with _defconfig. For
example:

    $ make O=/some/path/meh_defconfig meh_defconfig
    $ make O=/some/path/meh_defconfig

will break toward the end, with a rather weird issue:

    Makefile:1015: *** "Can't find /some/path/meh_defconfig".  Stop.

What looked weird, is two fold;

 1. only the defconfig name should be reported, not the path
 2. it happens after the filesystems are built

Tracing the build provides some clues;

    $ make -d O=/some/path/meh_defconfig
    [...]
          Considering target file 'staging-finalize'.
           File 'staging-finalize' does not exist.
            Considering target file '/some/path/meh_defconfig/staging'.
             File '/some/path/meh_defconfig/staging' does not exist.
              Considering target file '/some/path/meh_defconfig'.
               Looking for an implicit rule for '/some/path/meh_defconfig'.
               Trying pattern rule with stem 'meh'.
               Trying rule prerequisite '/some/path/meh_defconfig/build/buildroot-config/conf'.
               Trying rule prerequisite 'outputmakefile'.
               Found an implicit rule for '/some/path/meh_defconfig'.
                Considering target file '/some/path/meh_defconfig/build/buildroot-config/conf'.
                 Looking for an implicit rule for '/some/path/meh_defconfig/build/buildroot-config/conf'.
                 Trying pattern rule with stem 'c'.
                 Found an implicit rule for '/some/path/meh_defconfig/build/buildroot-config/conf'.
                 Finished prerequisites of target file '/some/path/meh_defconfig/build/buildroot-config/conf'.
                No need to remake target '/some/path/meh_defconfig/build/buildroot-config/conf'.
                Considering target file 'outputmakefile'.
                 File 'outputmakefile' does not exist.
                 Finished prerequisites of target file 'outputmakefile'.
                Must remake target 'outputmakefile'.
    /home/ymorin/dev/buildroot/buildroot/master/support/scripts/mkmakefile /home/ymorin/dev/buildroot/buildroot/master /some/path/meh_defconfig
    Putting child 0x55d4f3385ab0 (outputmakefile) PID 1231466 on the chain.
    Live child 0x55d4f3385ab0 (outputmakefile) PID 1231466
      GEN     /some/path/meh_defconfig/Makefile
    Reaping winning child 0x55d4f3385ab0 PID 1231466
    Removing child 0x55d4f3385ab0 PID 1231466 from chain.
                Successfully remade target file 'outputmakefile'.
               Finished prerequisites of target file '/some/path/meh_defconfig'.
               Prerequisite '/some/path/meh_defconfig/build/buildroot-config/conf' is older than target '/home/ymorin/dev/buildroot/buildroot/master/test/meh_defconfig'.
               Prerequisite 'outputmakefile' of target '/some/path/meh_defconfig' does not exist.
              Must remake target '/some/path/meh_defconfig'.
    Makefile:1015: *** "Can't find /some/path/meh_defconfig".  Stop.

So, it happens when trying to do staging-finalize. And this is becasue
we have (elided and reordered):

    staging-finalize: $(STAGING_DIR_SYMLINK)
    $(STAGING_DIR_SYMLINK): | $(BASE_DIR)
    BASE_DIR := $(CANONICAL_O)
    CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))

So, at some point, we need to have something to generate
/some/path/meh_defconfig, and thus the %_defconfig rule kick in.

The rule is %_defconfig, and the stem is now /some/path/meh, while the
way we wrote the rule, it expects a plain name (i.e. without any '/').

And of course, there is no defconfig named '/some/path/meh_defconfig',
so the error path kicks in and boom.

But then, why did it not trigger before?

Thats because, before, the defconfig rule was something like:

    %_defconfig: blabla foo/%_defconfig blabla

So the stem was on both side of the rule, and it would not kick in
because it was not an "implicit rule" (Makefile is not trivial, so maybe
I use the wrong terminology here), and because there would be an actual
file with that stem in its name.

So, I think we have two options:

  1. quickly find a fix that is not totally hackish (but with Romain, we
     could not find something trivial that worked)
  2. revert this change, and resurect my alternate patch [0]

[0] https://lore.kernel.org/buildroot/20220920194645.670432-1-yann.morin.1998@free.fr/

Regards,
Yann E. MORIN.

> +	@defconfig=$(or \
> +		$(firstword $(foreach d, \
> +			$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(wildcard $(d)/configs/$@))), \
> +		$(error "Can't find $@") \
> +	); \
> +	$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$${defconfig} \
> +		$< --defconfig=$${defconfig} $(CONFIG_CONFIG_IN)
>  
>  update-defconfig: savedefconfig
>  
> -- 
> 2.38.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2023-01-21 22:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05  1:57 [Buildroot] [PATCH v2 0/1] core: Use of percent_defconfig seems to impact performance Nevo Hed via buildroot
2023-01-05  1:57 ` [Buildroot] [PATCH 1/1] " Nevo Hed via buildroot
2023-01-07 20:15   ` Yann E. MORIN
2023-01-12 10:20     ` Peter Korsgaard
2023-01-21 22:27   ` Yann E. MORIN [this message]
2023-01-22  9:13     ` Yann E. MORIN

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=20230121222752.GF558596@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=nhed+buildroot@starry.com \
    --cc=peter@korsgaard.com \
    --cc=romain.naour@gmail.com \
    --cc=thomas.petazzoni@bootlin.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