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

Petr Vorel pvorel@suse.cz
Thu Aug 7 08:17:06 CEST 2025


Hi Li,

> >  # doesn't find the module (i.e. it wasn't built either due to kernel-devel
> >  # missing or module build failure).
> > +ifneq ($(FORCE_MODULES),1)
> >  %.ko: %.c .dep_modules ;
> > +endif

> Unfortunately, this wouldn't work as expected, the module's build process
> only skipped silently with `make modules FORCE_MODULES=1`.

Good catch, thank you. It's because '-' in
-$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir)
must be changed to get make fail.

It should be fixed by patch below, I'll send v4 shortly.
In the mean time you can use make-modules.v4 in my fork:
https://github.com/pevik/ltp/tree/refs/heads/make-modules.v4

Kind regards,
Petr

diff --git include/mk/module.mk include/mk/module.mk
index 65054ae502..3e97f01289 100644
--- include/mk/module.mk
+++ include/mk/module.mk
@@ -30,6 +30,7 @@ SKIP ?= $(shell \
 endif
 endif
 
+$(info skip: $(SKIP), FORCE_MODULES: $(FORCE_MODULES))
 ifneq ($(SKIP),0)
 MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS))
 ifeq ($(FORCE_MODULES),1)
@@ -58,12 +59,14 @@ MODULE_SOURCES := $(patsubst %.ko,%.c,$(filter %.ko, $(MAKE_TARGETS)))
 # kernel internal API changes. The user-space test will return TCONF, if it
 # doesn't find the module (i.e. it wasn't built either due to kernel-devel
 # missing or module build failure).
-ifneq ($(FORCE_MODULES),1)
 %.ko: %.c .dep_modules ;
-endif
 
 .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


More information about the ltp mailing list