[07/37] modpost: fix -i (--ignore-errors) MAKEFLAGS detection
diff mbox series

Message ID 20200601055731.3006266-7-masahiroy@kernel.org
State New
Headers show
  • [01/37] kbuild: refactor subdir-ym calculation
Related show

Commit Message

Masahiro Yamada June 1, 2020, 5:57 a.m. UTC
$(filter -i,$(MAKEFLAGS)) works only for some cases.

The representation of $(MAKEFLAGS) depends on various factors:
  - GNU Make version (version 3.8x or version 4.x)
  - The context where $(MAKEFLAGS) is expanded (parse stage or recipe)
  - The presence of other flags like -j

In my experiments, $(MAKEFLAGS) is expanded as follows:

  * GNU Make 3.8x:
    * without -j option:
      --no-print-directory -Rri
    * with -j option
      * parse stage
        --no-print-directory -Rri
      * recipe line
        --no-print-directory -Rr --jobserver-fds=3,4 -j -i
  * GNU Make 4.x:
    * without -j option
      irR --no-print-directory
    * with -j option
      * parse stage
        irR --no-print-directory
      * recipe line
        irR -j --jobserver-fds=3,4 --no-print-directory

If you use GNU Make 4.x, the flags are grouped together like 'irR',
which does not work.

For the single thread build with GNU Make 3.8x, the flags are grouped
like '-Rri', which does not work either.

To make it work for all cases, do likewise as commit 6f0fa58e4596
("kbuild: simplify silent build (-s) detection").

BTW, since commit ff9b45c55b26 ("kbuild: modpost: read modules.order
instead of $(MODVERDIR)/*.mod"), you also need to pass -k option to
build final *.ko files. 'make -i -k' ignores compile errors in modules,
and build as many remaining *.ko as possible.

Please note this feature is kind of dangerous because a module may
depend on another module. If the prerequisite module fails to build,
other modules may lack the correct module dependency or CRC.
Honestly, I am not a big fan of it, but I am keeping this feature.

Fixes: eed380f3f593 ("modpost: Optionally ignore secondary errors seen if a single module build fails")
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

 scripts/Makefile.modpost | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff mbox series

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index b79bf0e30d32..451bbd16c3cd 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -66,7 +66,7 @@  __modpost:
-MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
+MODPOST += -s -T - \
 ifeq ($(KBUILD_EXTMOD),)
@@ -82,6 +82,10 @@  include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
              $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
+ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
+MODPOST += -n
 # find all modules listed in modules.order
 modules := $(sort $(shell cat $(MODORDER)))