Re: [PATCH v10 08/11] build: Add modules.builtin.alias

From: Luis Chamberlain
Date: Wed May 24 2023 - 03:03:40 EST


On Thu, Apr 06, 2023 at 02:00:27PM -0500, Allen Webb wrote:
> Generate modules.builtin.alias using modpost and install it with the
> modules.

Why? This is probably one of the more important commits and the
commit log is pretty slim.

> Signed-off-by: Allen Webb <allenwebb@xxxxxxxxxx>
> ---
> .gitignore | 1 +
> Makefile | 1 +
> scripts/Makefile.modpost | 15 +++++++++++++++
> 3 files changed, 17 insertions(+)
>
> diff --git a/.gitignore b/.gitignore
> index 13a7f08a3d73..ddaa622bddac 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -71,6 +71,7 @@ modules.order
> /System.map
> /Module.markers
> /modules.builtin
> +/modules.builtin.alias
> /modules.builtin.modinfo
> /modules.nsdeps
>
> diff --git a/Makefile b/Makefile
> index a2c310df2145..43dcc1ea5fcf 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1578,6 +1578,7 @@ __modinst_pre:
> fi
> @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
> @cp -f modules.builtin $(MODLIB)/
> + @cp -f modules.builtin.alias $(MODLIB)/
> @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
>
> endif # CONFIG_MODULES
> diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
> index 0980c58d8afc..e3ecc17a7a19 100644
> --- a/scripts/Makefile.modpost
> +++ b/scripts/Makefile.modpost
> @@ -15,6 +15,7 @@
> # 2) modpost is then used to
> # 3) create one <module>.mod.c file per module
> # 4) create one Module.symvers file with CRC for all exported symbols
> +# 5) create modules.builtin.alias the aliases for built-in modules

Does everyone want that file?

> # Step 3 is used to place certain information in the module's ELF
> # section, including information such as:
> @@ -63,6 +64,20 @@ modpost-args += -T $(MODORDER)
> modpost-deps += $(MODORDER)
> endif
>
> +ifneq ($(wildcard vmlinux.o),)
> +output-builtin.alias := modules.builtin.alias
> +modpost-args += -b .modules.builtin.alias.in
> +.modules.builtin.alias.in: $(output-symdump)
> + @# Building $(output-symdump) generates .modules.builtin.alias.in as a
> + @# side effect.
> + @[ -e $@ ] || $(MODPOST) -b .modules.builtin.alias.in vmlinux.o

Does using -b create a delay in builds ? What is the effect on build
time on a typical 4-core or 8-core build? Does everyone want it?

Should we add a new option which lets people decide if they want this
at build time or not?

Luis

> +
> +$(output-builtin.alias): .modules.builtin.alias.in
> + sort -o $@ $^
> +
> +__modpost: $(output-builtin.alias)
> +endif
> +
> ifeq ($(KBUILD_EXTMOD),)
>
> # Generate the list of in-tree objects in vmlinux
> --
> 2.39.2
>