[PATCH v4 06/14] kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS

Masahiro Yamada masahiroy at kernel.org
Tue May 10 23:03:31 AEST 2022


On Tue, May 10, 2022 at 2:51 AM Nick Desaulniers
<ndesaulniers at google.com> wrote:
>
>  On Sun, May 8, 2022 at 12:10 PM Masahiro Yamada <masahiroy at kernel.org> wrote:
> >
> > diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
> > index 07a36a874dca..51ce72ce80fa 100644
> > --- a/include/asm-generic/export.h
> > +++ b/include/asm-generic/export.h
> > @@ -2,6 +2,14 @@
> >  #ifndef __ASM_GENERIC_EXPORT_H
> >  #define __ASM_GENERIC_EXPORT_H
> >
> > +/*
> > + * This comment block is used by fixdep. Please do not remove.
>
> I don't know much about fixdep. How does that work, if you could summarize?


You can find detailed explanation in scripts/basic/fixdep.c


In short, it works like this:

fixdep parses every source (including headers).
If it finds "CONFIG_MODVERSIONS", it adds a dependency
on $(wildcard include/config/MODVERSIONS)
to the .cmd files.

If CONFIG_MODVERSIONS is toggled in Kconfig,
it touches include/config/MODVERSIONS.    [1]

In the next run of Make, all the sources depending on
CONFIG_MODVERSIONS will be re-compiled because the
timestamp of include/config/MODVERSIONS is up-to-date.


[1]: https://github.com/torvalds/linux/blob/v5.17/scripts/kconfig/confdata.c#L141





> > + *
> > + * When CONFIG_MODVERSIONS is changed from n to y, all source files having
> > + * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
> > + * side effect of the .o build rule.
> > + */
> > +
> >  #ifndef KSYM_FUNC
> >  #define KSYM_FUNC(x) x
> >  #endif
> > @@ -12,9 +20,6 @@
> >  #else
> >  #define KSYM_ALIGN 4
> >  #endif
> > -#ifndef KCRC_ALIGN
> > -#define KCRC_ALIGN 4
> > -#endif
>
> The #ifndef is there because arch/m68k/include/asm/export.h:1 defines
> KCRC_ALIGN. You should delete that, too.

Nice catch! I will clean it up too.




>
> > diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
> > index 4827c5abe5b7..6e6933ae7911 100644
> > --- a/scripts/genksyms/genksyms.c
> > +++ b/scripts/genksyms/genksyms.c
> > @@ -33,7 +33,7 @@ char *cur_filename;
> >  int in_source_file;
> >
> >  static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
> > -          flag_preserve, flag_warnings, flag_rel_crcs;
> > +          flag_preserve, flag_warnings;
> >
> >  static int errors;
> >  static int nsyms;
> > @@ -681,10 +681,7 @@ void export_symbol(const char *name)
> >                         fputs(">\n", debugfile);
> >
> >                 /* Used as a linker script. */
>
> ^ Does this comment still apply?

No.  From this commit going forward,
the genksyms output will not be used as a linker script.

08/14 will delete this comment anyway, but
it is possible to remove it in this commit.








>
> > -               printf(!flag_rel_crcs ? "__crc_%s = 0x%08lx;\n" :
> > -                      "SECTIONS { .rodata : ALIGN(4) { "
> > -                      "__crc_%s = .; LONG(0x%08lx); } }\n",
> > -                      name, crc);
> > +               printf("__crc_%s = 0x%08lx;\n", name, crc);
> >         }
> >  }
> >
> > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> > index eceb3ee7ec06..6aee2401f3ad 100755
> > --- a/scripts/link-vmlinux.sh
> > +++ b/scripts/link-vmlinux.sh
> > @@ -88,11 +88,6 @@ modpost_link()
> >                 gen_initcalls
> >                 lds="-T .tmp_initcalls.lds"
> >
> > -               if is_enabled CONFIG_MODVERSIONS; then
> > -                       gen_symversions
>
> ^ this is the only caller of gen_symversions, right? Then
> gen_symversions can be cleaned up, too?


We can keep it in this commit.

The follow-up cleaning is done in 07/14.

To avoid too big commit,
I separated the build flow change and
trivial cleanups.



>
> > -                       lds="${lds} -T .tmp_symversions.lds"
> > -               fi
> > -
> >                 # This might take a while, so indicate that we're doing
> >                 # an LTO link
> >                 info LTO ${1}
> > @@ -183,6 +178,10 @@ vmlinux_link()
> >                 libs="${KBUILD_VMLINUX_LIBS}"
> >         fi
> >
> > +       if is_enabled CONFIG_MODULES; then
> > +               objs="${objs} .vmlinux.export.o"
> > +       fi
> > +
> >         if [ "${SRCARCH}" = "um" ]; then
> >                 wl=-Wl,
> >                 ld="${CC}"
> > @@ -312,6 +311,7 @@ cleanup()
> >         rm -f vmlinux.o
> >         rm -f .vmlinux.d
> >         rm -f .vmlinux.objs
> > +       rm -f .vmlinux.export.c
>
> Probably can drop the `rm -f .tmp_symversions.lds` here, too?

It will be cleaned up by 07/14.







> --
> Thanks,
> ~Nick Desaulniers



--
Best Regards
Masahiro Yamada


More information about the Linuxppc-dev mailing list