Re: git: f7026fbbb2bd - main - sys/modules: MODULES_OVERRIDE takes precedence over EXTRA_MODULES and WITHOUT_MODULES

From: Andriy Gapon <andriy.gapon_at_uabsd.com>
Date: Thu, 05 Jan 2023 10:51:09 UTC
On 2022-10-29 19:33, Warner Losh wrote:
> The branch main has been updated by imp:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=f7026fbbb2bd72176d73921dd2dd5e4b263d5103
> 
> commit f7026fbbb2bd72176d73921dd2dd5e4b263d5103
> Author:     Warner Losh <imp@FreeBSD.org>
> AuthorDate: 2022-10-29 14:34:16 +0000
> Commit:     Warner Losh <imp@FreeBSD.org>
> CommitDate: 2022-10-29 16:17:40 +0000
> 
>      sys/modules: MODULES_OVERRIDE takes precedence over EXTRA_MODULES and WITHOUT_MODULES
>      
>      MODULES_OVERRIDE has traditionally taken precedence over EXTRA_MODULES
>      and WITHOUT_MODULES as the exact list of modules to build. Over time,
>      things have been added that has broken this. Move the .endif that makes
>      this the case to the right place. The so called 'ALL_MODULES' option is
>      the only thing with higher precedence, but it's not quite all the
>      options anymore (though it is much more of them, and doesn't quite
>      work on !x86).
>      
>      Sponsored by:           Netflix

Warner,

this change broke one use-case of mine.  The use-case does not seem to 
be exotic, so others may be affected as well.

I am building a custom arm64 kernel and a set of modules for a specific 
SoC (rockchip).
The kernel configuration, similarly to GENERIC, has this statement:
	include         "std.rockchip"

In turn, std.rockchip has this statement:
	# DTBs
	makeoptions     MODULES_EXTRA+="dtb/rockchip"

Additionally, in my make.conf I have MODULES_OVERRIDE set to a short 
list of modules.

Previously this worked without issues, completely transparently.
Now, MODULES_OVERRIDE apparently cancels MODULES_EXTRA.
I can easily add dtb/rockchip to my MODULES_OVERRIDE, of course, but I 
get a feeling that the previous behavior was more useful because it 
allowed to specify mandatory "internal" modules in addition to a 
user-specified list of modules.  Not sure what's the benefit of the 
traditional behavior that you restored, it's not spelled out.

TLDR: dtb-s and dtbo-s are not getting build for anyone with 
MODULES_OVERRIDE in make.conf (on relevant platforms).

> ---
>   sys/modules/Makefile | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sys/modules/Makefile b/sys/modules/Makefile
> index 00afbffb1baf..3a009f071cab 100644
> --- a/sys/modules/Makefile
> +++ b/sys/modules/Makefile
> @@ -848,8 +848,6 @@ _nvram=		opal_nvram
>   _nvram+=	powermac_nvram
>   .endif
>   
> -.endif
> -
>   .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "aarch64"
>   _bcm283x_clkman=  bcm283x_clkman
>   _bcm283x_pwm=  bcm283x_pwm
> @@ -867,6 +865,8 @@ SUBDIR+=${MODULES_EXTRA}
>   SUBDIR:= ${SUBDIR:N${reject}}
>   .endfor
>   
> +.endif # MODULES_OVERRIDE -- Keep last
> +
>   # Calling kldxref(8) for each module is expensive.
>   .if !defined(NO_XREF)
>   .MAKEFLAGS+=	-DNO_XREF

-- 
Andriy Gapon

https://standforukraine.com
https://razomforukraine.org