Re: git: 701ab6dba4a2 - main - Stop building FDT-only modules in an ACPI only kernel

From: Warner Losh <imp_at_bsdimp.com>
Date: Sat, 29 Oct 2022 00:09:28 UTC
On Fri, Oct 28, 2022 at 2:23 PM Mitchell Horne <mhorne@freebsd.org> wrote:

>
>
> On 10/28/22 12:59, John Baldwin wrote:
> > On 10/27/22 10:59 AM, Andrew Turner wrote:
> >> The branch main has been updated by andrew:
> >>
> >> URL:
> >>
> https://cgit.FreeBSD.org/src/commit/?id=701ab6dba4a2232751cd91f79bfc1d8e96bf5316
> >>
> >> commit 701ab6dba4a2232751cd91f79bfc1d8e96bf5316
> >> Author:     Andrew Turner <andrew@FreeBSD.org>
> >> AuthorDate: 2022-10-27 17:01:44 +0000
> >> Commit:     Andrew Turner <andrew@FreeBSD.org>
> >> CommitDate: 2022-10-27 17:59:33 +0000
> >>
> >>      Stop building FDT-only modules in an ACPI only kernel
> >>      When building a kernel without FDT these modules don't build. As
> >> they
> >>      depend on FDT and don't work with ACPI disable them.
> >>      Reviewed by:    imp, kevans
> >>      Sponsored by:   The FreeBSD Foundation
> >>      Differential Revision: https://reviews.freebsd.org/D37178
> >
> > Hmm, the OPT_FDT handling seems a bit atypical.  Other optional
> > components are
> > tested for by ${KERN_OPTS:M<foo>} rather than empty(OPT_<foo>) under
> > sys/modules.
> >
>
> Some time ago I experimented with trying to build a NOFDT kernel like
> this. I found that this type of construct worked well:
>
> SUBDIR.${MK_FDT}= ${_allwinner} \
>                    ${_if_cgem} \
>                    ${_sdhci_fdt} \
>                    ...
>
> That is, use the existing SUBDIR.yes logic to conditionally exclude
> these already conditional subdirectories. It avoids multiple identical
> checks, whether you use ${KERN_OPTS:MFDT} or empty(OPT_FDT) forms.
> Something to consider.
>

I have a more extensive set of changes I'm working on that I might as well
trot out here...

First, I'd 100% kill every last _foo variable. They aren't needed.
Next, I'd have a Makefile.$MACHINE. This makefile would be responsible
for defining a MODULES_FEATURES variable that would be a list like
MODULE_FEATUERS=32bit x86 64bit-atomics
for i386. Each of these features would have subdirs associated with them
SUBDIR.64bit-atomics+=mpr
SUBDIR.64bit-atomics+=mps
and then we'd join them all together at the end. The Makefile.$MACHINE
might also add modules to SUBDIRS that are always compiled for that machine,
and might add features like 'fdt' or 'acpi' conditionally to MODULE_FEATURES
so it would need to be more than just a bunch of MODULE_FEATURES.<arch>=
lines at the top of this Makefile.

I was hoping to share a preview early next week. I think this will be a good
balance between simplicity and the mess we have today...

Warner