Message ID | 20250211002930.1865689-1-masahiroy@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tools: fix annoying "mkdir -p ..." logs when building tools in parallel | expand |
Frank and Matt, Please ignore this. This is intended for kbuild ML. On Tue, Feb 11, 2025 at 9:29 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > When CONFIG_OBJTOOL=y or CONFIG_DEBUG_INFO_BTF=y, parallel builds > show awkward "mkdir -p ..." logs. > > $ make -j16 > [ snip ] > mkdir -p /home/masahiro/ref/linux/tools/objtool && make O=/home/masahiro/ref/linux subdir=tools/objtool --no-print-directory -C objtool > mkdir -p /home/masahiro/ref/linux/tools/bpf/resolve_btfids && make O=/home/masahiro/ref/linux subdir=tools/bpf/resolve_btfids --no-print-directory -C bpf/resolve_btfids > > Defining MAKEFLAGS=<value> on the command line wipes out command line > switches from the resultant MAKEFLAGS definition, even though the command > line switches are active. [1] > > The first word of $(MAKEFLAGS) is a possibly empty group of characters > representing single-letter options that take no argument. However, this > breaks if MAKEFLAGS=<value> is given on the command line. > > The tools/ and tools/% targets set MAKEFLAGS=<value> on the command > line, which breaks the following code in tools/scripts/Makefile.include: > > short-opts := $(firstword -$(MAKEFLAGS)) > > If MAKEFLAGS really needs modification, it should be done through the > environment variable, as follows: > > MAKEFLAGS=<value> $(MAKE) ... > > That said, I question whether modifying MAKEFLAGS is necessary here. > The only flag we might want to exclude is --no-print-directory, as the > tools build system changes the working directory. However, people might > find the "Entering/Leaving directory" logs annoying. > > I simply removed the offending MAKEFLAGS=. > > [1]: https://savannah.gnu.org/bugs/?62469 > > Fixes: a50e43332756 ("perf tools: Honor parallel jobs") > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > --- > > Makefile | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/Makefile b/Makefile > index 89628e354ca7..52207bcb1a9d 100644 > --- a/Makefile > +++ b/Makefile > @@ -1421,18 +1421,13 @@ ifneq ($(wildcard $(resolve_btfids_O)),) > $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean > endif > > -# Clear a bunch of variables before executing the submake > -ifeq ($(quiet),silent_) > -tools_silent=s > -endif > - > tools/: FORCE > $(Q)mkdir -p $(objtree)/tools > - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ > + $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ > > tools/%: FORCE > $(Q)mkdir -p $(objtree)/tools > - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* > + $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* > > # --------------------------------------------------------------------------- > # Kernel selftest > -- > 2.43.0 >
Hi Masahiro, Thanks for looking into this! Much better than my attempt :P On Tue, Feb 11, 2025 at 09:29:06AM +0900, Masahiro Yamada wrote: > When CONFIG_OBJTOOL=y or CONFIG_DEBUG_INFO_BTF=y, parallel builds > show awkward "mkdir -p ..." logs. > > $ make -j16 > [ snip ] > mkdir -p /home/masahiro/ref/linux/tools/objtool && make O=/home/masahiro/ref/linux subdir=tools/objtool --no-print-directory -C objtool > mkdir -p /home/masahiro/ref/linux/tools/bpf/resolve_btfids && make O=/home/masahiro/ref/linux subdir=tools/bpf/resolve_btfids --no-print-directory -C bpf/resolve_btfids > > Defining MAKEFLAGS=<value> on the command line wipes out command line > switches from the resultant MAKEFLAGS definition, even though the command > line switches are active. [1] > > The first word of $(MAKEFLAGS) is a possibly empty group of characters > representing single-letter options that take no argument. However, this > breaks if MAKEFLAGS=<value> is given on the command line. > > The tools/ and tools/% targets set MAKEFLAGS=<value> on the command > line, which breaks the following code in tools/scripts/Makefile.include: > > short-opts := $(firstword -$(MAKEFLAGS)) > > If MAKEFLAGS really needs modification, it should be done through the > environment variable, as follows: > > MAKEFLAGS=<value> $(MAKE) ... > > That said, I question whether modifying MAKEFLAGS is necessary here. > The only flag we might want to exclude is --no-print-directory, as the > tools build system changes the working directory. However, people might > find the "Entering/Leaving directory" logs annoying. > > I simply removed the offending MAKEFLAGS=. > > [1]: https://savannah.gnu.org/bugs/?62469 > > Fixes: a50e43332756 ("perf tools: Honor parallel jobs") > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Daniel Xu <dxu@dxuuu.xyz>
diff --git a/Makefile b/Makefile index 89628e354ca7..52207bcb1a9d 100644 --- a/Makefile +++ b/Makefile @@ -1421,18 +1421,13 @@ ifneq ($(wildcard $(resolve_btfids_O)),) $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean endif -# Clear a bunch of variables before executing the submake -ifeq ($(quiet),silent_) -tools_silent=s -endif - tools/: FORCE $(Q)mkdir -p $(objtree)/tools - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ + $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ tools/%: FORCE $(Q)mkdir -p $(objtree)/tools - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* + $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* # --------------------------------------------------------------------------- # Kernel selftest
When CONFIG_OBJTOOL=y or CONFIG_DEBUG_INFO_BTF=y, parallel builds show awkward "mkdir -p ..." logs. $ make -j16 [ snip ] mkdir -p /home/masahiro/ref/linux/tools/objtool && make O=/home/masahiro/ref/linux subdir=tools/objtool --no-print-directory -C objtool mkdir -p /home/masahiro/ref/linux/tools/bpf/resolve_btfids && make O=/home/masahiro/ref/linux subdir=tools/bpf/resolve_btfids --no-print-directory -C bpf/resolve_btfids Defining MAKEFLAGS=<value> on the command line wipes out command line switches from the resultant MAKEFLAGS definition, even though the command line switches are active. [1] The first word of $(MAKEFLAGS) is a possibly empty group of characters representing single-letter options that take no argument. However, this breaks if MAKEFLAGS=<value> is given on the command line. The tools/ and tools/% targets set MAKEFLAGS=<value> on the command line, which breaks the following code in tools/scripts/Makefile.include: short-opts := $(firstword -$(MAKEFLAGS)) If MAKEFLAGS really needs modification, it should be done through the environment variable, as follows: MAKEFLAGS=<value> $(MAKE) ... That said, I question whether modifying MAKEFLAGS is necessary here. The only flag we might want to exclude is --no-print-directory, as the tools build system changes the working directory. However, people might find the "Entering/Leaving directory" logs annoying. I simply removed the offending MAKEFLAGS=. [1]: https://savannah.gnu.org/bugs/?62469 Fixes: a50e43332756 ("perf tools: Honor parallel jobs") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)