[LTP] [PATCH v4 2/2] modules.mk: Add FORCE_MODULES=1 to fail on error

Petr Vorel pvorel@suse.cz
Thu Aug 14 15:18:57 CEST 2025


Hi Li,

> Hi Petr,

> I am still trying to make sure my understanding is correct on
> 'FORCE_MODULES=1',
> which one below do you mean:

>   1. If a subdirectory fails, it stops for that subdirectory but the
> top-level make
>       continues with the next directory in the list.

>   2. The top-level build should stop immediately when any subdirectory
> fails.

> If the answer is (1), I believe our current patch is correct (feel free to
> add my RBT).
> However, if the intended behavior is (2), we will need to amend the
> top-level Makefile
> to ensure the build stops at the first failure.

I intended 1., but exit afterwards non-zero on error. But this actually is not
true.  => v5 is needed.

The reason for 1. was to see which modules failed (all of them).
Maybe it'd be enough to implement 2.

This works for me (sending v5 today):
-               $(MAKE) -C $(abs_srcdir)/$(dir); \
+               $(MAKE) -C $(abs_srcdir)/$(dir); [ $$? -eq 0 ] || exit exit $$?; \

I wonder if it's enough to add the change only to 'modules' target or whether I
should add it to the others (modules-clean, modules-install) as well.

Kind regards,
Petr

...
> > +++ b/include/mk/module.mk
...
> > +define newline
> > +
> > +
> > +endef
> > +n := $(newline)
> > +
> > +$(info skip: $(SKIP), FORCE_MODULES: $(FORCE_MODULES))
> >  ifneq ($(SKIP),0)
> >  MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS))
> > +ifeq ($(FORCE_MODULES),1)
> > +$(error Kernel modules not built!$(n)\
> > +Check that package for building kernel modules for $(LINUX_VERSION)\
> > +is installed and try again.$(n)\
> > +* openSUSE/SLES: kernel-default-devel$(n)\
> > +* Fedora/RHEL: kernel-devel/kernel-headers$(n)\
> > +* Debian/Ubuntu: linux-kbuild$(n)\
> > +You can build anyway by omitting FORCE_MODULES=1)
> > +endif
> >  endif

> >  ifneq ($(filter install clean,$(MAKECMDGOALS)),)
> > @@ -45,6 +63,10 @@ MODULE_SOURCES := $(patsubst %.ko,%.c,$(filter %.ko,
> > $(MAKE_TARGETS)))

> >  .dep_modules: $(MODULE_SOURCES)
> >         @echo "Building modules: $(MODULE_SOURCES)"
> > +ifneq ($(FORCE_MODULES),1)
> >         -$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir)
> > +else
> > +       $(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir)
> > +endif
> >         rm -rf *.mod.c *.o *.ko.unsigned modules.order .tmp* .*.ko .*.cmd
> > Module.symvers
> >         @touch .dep_modules
> > --
> > 2.50.1


More information about the ltp mailing list