mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: barebox@lists.infradead.org
Cc: Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 3/8] kbuild: resync mkdir code with Linux 5.7-rc6
Date: Tue, 19 May 2020 16:13:47 +0900	[thread overview]
Message-ID: <20200519071353.395493-3-masahiroy@kernel.org> (raw)
In-Reply-To: <20200519071353.395493-1-masahiroy@kernel.org>

Kbuild automatically creates the output directories for O= builds.
Previously it called mkdir too much. Linux optimized this a lot.
Let's import the outcome so it works faster.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.build | 25 ++++++++++++-------------
 scripts/Makefile.host  |  2 --
 scripts/Makefile.lib   |  4 ----
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f4e771980..d94ad488d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -49,15 +49,6 @@ ifneq ($(hostprogs)$(hostprogs-y)$(hostprogs-m),)
 include scripts/Makefile.host
 endif
 
-ifdef building_out_of_srctree
-# Create output directory if not already present
-_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
-
-# Create directories for object files if directory does not exist
-# Needed when obj-y := dir/file.o syntax is used
-_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
-endif
-
 ifndef obj
 $(warning kbuild: Makefile.build is included improperly)
 endif
@@ -332,11 +323,19 @@ FORCE:
 # optimization, we don't need to read them if the target does not
 # exist, we will rebuild anyway in that case.
 
-targets := $(wildcard $(sort $(targets)))
-cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
+existing-targets := $(wildcard $(sort $(targets)))
 
-ifneq ($(cmd_files),)
-  include $(cmd_files)
+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
+
+ifdef building_out_of_srctree
+# Create directories for object files if they do not exist
+obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
+# If targets exist, their directories apparently exist. Skip mkdir.
+existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
+obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
+ifneq ($(obj-dirs),)
+$(shell mkdir -p $(obj-dirs))
+endif
 endif
 
 .PHONY: $(PHONY)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 55b565ce3..038b3054a 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -76,8 +76,6 @@ host-cxxmulti	:= $(addprefix $(obj)/,$(host-cxxmulti))
 host-cxxobjs	:= $(addprefix $(obj)/,$(host-cxxobjs))
 host-objdirs    := $(addprefix $(obj)/,$(host-objdirs))
 
-obj-dirs += $(host-objdirs)
-
 #####
 # Handle options to gcc. Support building with separate output directory
 
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 604bedfc5..70303adb5 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -77,9 +77,6 @@ __subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y))
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 subdir-obj-y += $(__subdir-obj-y)
 
-# $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(obj-y) $(pbl-y))
-
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
 real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
@@ -104,7 +101,6 @@ multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
 multi-objs-y	:= $(addprefix $(obj)/,$(multi-objs-y))
 multi-objs-m	:= $(addprefix $(obj)/,$(multi-objs-m))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
-obj-dirs	:= $(addprefix $(obj)/,$(obj-dirs))
 bbenv-y		:= $(addprefix $(obj)/,$(bbenv-y))
 
 # target with $(obj)/ and its suffix stripped
-- 
2.25.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-05-19  7:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  7:13 [PATCH 1/8] kbuild: rename pbl object pbl-*.o to *.pbl.o Masahiro Yamada
2020-05-19  7:13 ` [PATCH 2/8] kbuild: remove obj-dtb-y, pbl-dtb-y, lwl-dtb-y syntax Masahiro Yamada
2020-05-19  7:13 ` Masahiro Yamada [this message]
2020-05-19  7:13 ` [PATCH 4/8] kbuild: append $(bbenv-y) to obj-y earlier Masahiro Yamada
2020-05-19  7:13 ` [PATCH 5/8] kbuild: resync modkern_{c, a}flags and quiet_modtag with Linux 5.7-rc6 Masahiro Yamada
2020-05-19  7:13 ` [PATCH 6/8] kbuild: unify barebox and pbl build commands Masahiro Yamada
2020-05-19  7:49   ` Masahiro Yamada
2020-05-19  7:13 ` [PATCH 7/8] kbuild: switch over to thin archive Masahiro Yamada
2020-05-19  7:13 ` [PATCH 8/8] Revert "ARM: socfpga: generate smaller images when multiple boards are selected" Masahiro Yamada
2020-05-20 11:18 ` [PATCH 1/8] kbuild: rename pbl object pbl-*.o to *.pbl.o Sascha Hauer

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=20200519071353.395493-3-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=barebox@lists.infradead.org \
    /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