Skip to content

Commit

Permalink
modpost: fix -i (--ignore-errors) MAKEFLAGS detection
Browse files Browse the repository at this point in the history
$(filter -i,$(MAKEFLAGS)) works only in limited use-cases.

The representation of $(MAKEFLAGS) depends on various factors:
  - GNU Make version (version 3.8x or version 4.x)
  - 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:
      --no-print-directory -Rr --jobserver-fds=3,4 -j -i

  * GNU Make 4.x:

    * without -j option:
      irR --no-print-directory

    * with -j option:
      irR -j --jobserver-fds=3,4 --no-print-directory

For GNU Make 4.x, the flags are grouped as 'irR', which does not work.

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

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

BTW, since commit ff9b45c ("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 if other modules depend
on the broken module because the generated modules will lack the correct
module dependency or CRC. Honestly, I am not a big fan of it, but I am
keeping this feature.

Fixes: eed380f ("modpost: Optionally ignore secondary errors seen if a single module build fails")
Cc: Guenter Roeck <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
masahir0y committed Jun 3, 2020
1 parent b2c8855 commit 91e6ee5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/Makefile.modpost
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ __modpost:

else

MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
MODPOST += -s -T - \
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))

ifeq ($(KBUILD_EXTMOD),)
Expand All @@ -82,6 +82,11 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
$(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
endif

# 'make -i -k' ignores compile errors, and builds as many modules as possible.
ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
MODPOST += -n
endif

# find all modules listed in modules.order
modules := $(sort $(shell cat $(MODORDER)))

Expand Down

0 comments on commit 91e6ee5

Please sign in to comment.