Re: [PATCH] kbuild: install-extmod-build: do not exclude scripts/dtc/libfdt/

From: Icenowy Zheng

Date: Tue Feb 03 2026 - 22:27:14 EST


在 2026-02-03星期二的 19:16 -0700,Nathan Chancellor写道:
> + Rob, Saravana, and devicetree@ since this concerns files they own.
>
> On Sun, Feb 01, 2026 at 09:02:59PM +0800, Icenowy Zheng wrote:
> > There exists a header file in include/linux/ called libfdt.h that
> > is
> > just a wrapper for libfdt header file in scripts/dtc/libfdt/. This
> > makes
> > the headers inside libfdt copy at scripts/dtc/libfdt/ part of the
> > kernel
> > headers for building external modules.
> >
> > Do not exclude them, otherwise modules that include
> > <linux/libfdt.h>
> > will fail to build externally.
> >
> > Fixes: aaed5c7739be ("kbuild: slim down package for building
> > external modules")
> > Signed-off-by: Icenowy Zheng <zhengxingda@xxxxxxxxxxx>
>
> This does indeed bring back scripts/dtc/libfdt back into the headers
> package that I examined. However, how does including libfdt.h in an
> external module actually work, even with this change? libfdt appears
> to
> be built into vmlinux IIUC and I do not see any EXPORT_SYMBOLs in the
> list, so how can you actually use any of the functions from libfdt
> within the module? Would you just build and link the pieces that your
> module needs using the other source files?

To be honest what I met is quite weird -- my module [1] does not use
libfdt at all. However, as a MIPS platform-specific module, it includes
arch/mips/include/asm/bootinfo.h, which pulls in libfdt.h.

Or maybe I should prevent libfdt.h inclusion from other kernel headers?
It looks like only two headers in MIPS architecture-specific code
includes libfdt.h, asm/bootinfo.h and asm/machine.h .

Thanks,
Icenowy

>
> > ---
> >  scripts/package/install-extmod-build | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/package/install-extmod-build
> > b/scripts/package/install-extmod-build
> > index 2576cf7902dbb..d1e448d7f59f6 100755
> > --- a/scripts/package/install-extmod-build
> > +++ b/scripts/package/install-extmod-build
> > @@ -11,7 +11,8 @@ is_enabled() {
> >  
> >  find_in_scripts() {
> >         find scripts \
> > -               \( -name atomic -o -name dtc -o -name kconfig -o -
> > name package \) -prune -o \
> > +               \( -name atomic -o -name kconfig -o -name package -
> > o \
> > +                  \( -path '*/dtc/*' -a ! -path '*/libfdt*' \) \)
> > -prune -o \
> >                 ! -name unifdef -a ! -name mk_elfconfig -a \( -type
> > f -o -type l \) -print
> >  }
> >  
> > --
> > 2.52.0
> >