* [PATCH v2 00/10] kbuild: misc cleanups
@ 2022-04-05 14:02 Masahiro Yamada
2022-04-05 14:02 ` [PATCH v2 09/10] kbuild: refactor cmd_modversions_c Masahiro Yamada
0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-04-05 14:02 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Alexander Lobakin, Michal Marek,
Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
Rasmus Villemoes, Sami Tolvanen, llvm
This is a series of prerequisite cleanups of my next work.
Masahiro Yamada (10):
kbuild: factor out genksyms command from cmd_gensymtypes_{c,S}
kbuild: do not remove empty *.symtypes explicitly
modpost: remove useless export_from_sec()
modpost: move export_from_secname() call to more relevant place
modpost: remove redundant initializes for static variables
modpost: remove annoying namespace_from_kstrtabns()
kbuild: get rid of duplication in the first line of *.mod files
kbuild: split the second line of *.mod into *.usyms
kbuild: refactor cmd_modversions_c
kbuild: refactor cmd_modversions_S
.gitignore | 1 +
Makefile | 2 +-
scripts/Makefile.build | 86 ++++++++++++++++---------------------
scripts/adjust_autoksyms.sh | 2 +-
scripts/gen_autoksyms.sh | 18 +++++---
scripts/mod/modpost.c | 49 ++++++---------------
scripts/mod/modpost.h | 4 --
scripts/mod/sumversion.c | 11 +----
8 files changed, 64 insertions(+), 109 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 09/10] kbuild: refactor cmd_modversions_c
2022-04-05 14:02 [PATCH v2 00/10] kbuild: misc cleanups Masahiro Yamada
@ 2022-04-05 14:02 ` Masahiro Yamada
0 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2022-04-05 14:02 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Michal Marek, Nathan Chancellor,
Nick Desaulniers, llvm
cmd_modversions_c implements two parts; run genksyms to calculate CRCs
of exported symbols, run $(LD) to update the object with the CRCs. The
latter is not executed for CONFIG_LTO_CLANG=y since the object is not
ELF but LLVM bit code at this point.
The first part can be unified because we can always use $(NM) instead
of "$(OBJDUMP) -h" to dump the symbols.
Split the code into the two macros, cmd_gen_symversions_c and
cmd_modversions.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Changes in v2:
- new
scripts/Makefile.build | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d934bdf84de4..ba2be555f942 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -169,29 +169,25 @@ ifdef CONFIG_MODVERSIONS
# the actual value of the checksum generated by genksyms
# o remove .tmp_<file>.o to <file>.o
-ifdef CONFIG_LTO_CLANG
# Generate .o.symversions files for each .o with exported symbols, and link these
# to the kernel and/or modules at the end.
-cmd_modversions_c = \
+gen_symversions = \
if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \
- $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
+ $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> $@.symversions; \
else \
rm -f $@.symversions; \
- fi;
-else
-cmd_modversions_c = \
- if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
- $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
- > $(@D)/.tmp_$(@F:.o=.ver); \
- \
+ fi
+
+cmd_gen_symversions_c = $(call gen_symversions,c)
+
+cmd_modversions = \
+ if [ -r $@.symversions ]; then \
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
- -T $(@D)/.tmp_$(@F:.o=.ver); \
+ -T $@.symversions; \
mv -f $(@D)/.tmp_$(@F) $@; \
- rm -f $(@D)/.tmp_$(@F:.o=.ver); \
fi
endif
-endif
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
@@ -269,7 +265,8 @@ define rule_cc_o_c
$(call cmd,checksrc)
$(call cmd,checkdoc)
$(call cmd,gen_objtooldep)
- $(call cmd,modversions_c)
+ $(call cmd,gen_symversions_c)
+ $(if $(CONFIG_LTO_CLANG),,$(call cmd,modversions))
$(call cmd,record_mcount)
endef
--
2.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 00/10] kbuild: misc cleanups
@ 2022-04-05 11:33 Masahiro Yamada
2022-04-05 11:33 ` [PATCH v2 09/10] kbuild: refactor cmd_modversions_c Masahiro Yamada
0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-04-05 11:33 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Alexander Lobakin, Michal Marek,
Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
Rasmus Villemoes, Sami Tolvanen, llvm
This is a series of prerequisite cleanups of my next work.
Masahiro Yamada (10):
kbuild: factor out genksyms command from cmd_gensymtypes_{c,S}
kbuild: do not remove empty *.symtypes explicitly
modpost: remove useless export_from_sec()
modpost: move export_from_secname() call to more relevant place
modpost: remove redundant initializes for static variables
modpost: remove annoying namespace_from_kstrtabns()
kbuild: get rid of duplication in the first line of *.mod files
kbuild: split the second line of *.mod into *.usyms
kbuild: refactor cmd_modversions_c
kbuild: refactor cmd_modversions_S
.gitignore | 1 +
Makefile | 2 +-
scripts/Makefile.build | 86 ++++++++++++++++---------------------
scripts/adjust_autoksyms.sh | 2 +-
scripts/gen_autoksyms.sh | 18 +++++---
scripts/mod/modpost.c | 49 ++++++---------------
scripts/mod/modpost.h | 4 --
scripts/mod/sumversion.c | 11 +----
8 files changed, 64 insertions(+), 109 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 09/10] kbuild: refactor cmd_modversions_c
2022-04-05 11:33 [PATCH v2 00/10] kbuild: misc cleanups Masahiro Yamada
@ 2022-04-05 11:33 ` Masahiro Yamada
2022-04-05 16:42 ` Nick Desaulniers
0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-04-05 11:33 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Michal Marek, Nathan Chancellor,
Nick Desaulniers, llvm
cmd_modversions_c implements two parts; run genksyms to calculate CRCs
of exported symbols, run $(LD) to update the object with the CRCs. The
latter is not executed for CONFIG_LTO_CLANG=y since the object is not
ELF but LLVM bit code at this point.
The first part can be unified because we can always use $(NM) instead
of "$(OBJDUMP) -h" to dump the symbols.
Split the code into the two macros, cmd_gen_symversions_c and
cmd_modversions.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Changes in v2:
- new
scripts/Makefile.build | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d934bdf84de4..ba2be555f942 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -169,29 +169,25 @@ ifdef CONFIG_MODVERSIONS
# the actual value of the checksum generated by genksyms
# o remove .tmp_<file>.o to <file>.o
-ifdef CONFIG_LTO_CLANG
# Generate .o.symversions files for each .o with exported symbols, and link these
# to the kernel and/or modules at the end.
-cmd_modversions_c = \
+gen_symversions = \
if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \
- $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
+ $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> $@.symversions; \
else \
rm -f $@.symversions; \
- fi;
-else
-cmd_modversions_c = \
- if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
- $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
- > $(@D)/.tmp_$(@F:.o=.ver); \
- \
+ fi
+
+cmd_gen_symversions_c = $(call gen_symversions,c)
+
+cmd_modversions = \
+ if [ -r $@.symversions ]; then \
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
- -T $(@D)/.tmp_$(@F:.o=.ver); \
+ -T $@.symversions; \
mv -f $(@D)/.tmp_$(@F) $@; \
- rm -f $(@D)/.tmp_$(@F:.o=.ver); \
fi
endif
-endif
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
@@ -269,7 +265,8 @@ define rule_cc_o_c
$(call cmd,checksrc)
$(call cmd,checkdoc)
$(call cmd,gen_objtooldep)
- $(call cmd,modversions_c)
+ $(call cmd,gen_symversions_c)
+ $(if $(CONFIG_LTO_CLANG),,$(call cmd,modversions))
$(call cmd,record_mcount)
endef
--
2.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 09/10] kbuild: refactor cmd_modversions_c
2022-04-05 11:33 ` [PATCH v2 09/10] kbuild: refactor cmd_modversions_c Masahiro Yamada
@ 2022-04-05 16:42 ` Nick Desaulniers
0 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2022-04-05 16:42 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Michal Marek, Nathan Chancellor, llvm,
Sami Tolvanen, Kees Cook
On Tue, Apr 5, 2022 at 4:34 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> cmd_modversions_c implements two parts; run genksyms to calculate CRCs
> of exported symbols, run $(LD) to update the object with the CRCs. The
> latter is not executed for CONFIG_LTO_CLANG=y since the object is not
> ELF but LLVM bit code at this point.
>
> The first part can be unified because we can always use $(NM) instead
> of "$(OBJDUMP) -h" to dump the symbols.
>
> Split the code into the two macros, cmd_gen_symversions_c and
> cmd_modversions.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>
> Changes in v2:
> - new
>
> scripts/Makefile.build | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index d934bdf84de4..ba2be555f942 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -169,29 +169,25 @@ ifdef CONFIG_MODVERSIONS
> # the actual value of the checksum generated by genksyms
> # o remove .tmp_<file>.o to <file>.o
>
> -ifdef CONFIG_LTO_CLANG
> # Generate .o.symversions files for each .o with exported symbols, and link these
> # to the kernel and/or modules at the end.
> -cmd_modversions_c = \
> +gen_symversions = \
> if $(NM) $@ 2>/dev/null | grep -q __ksymtab; then \
> - $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> + $(call cmd_gensymtypes_$(1),$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> > $@.symversions; \
> else \
> rm -f $@.symversions; \
> - fi;
> -else
> -cmd_modversions_c = \
> - if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
> - $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> - > $(@D)/.tmp_$(@F:.o=.ver); \
> - \
> + fi
> +
> +cmd_gen_symversions_c = $(call gen_symversions,c)
> +
> +cmd_modversions = \
> + if [ -r $@.symversions ]; then \
> $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
> - -T $(@D)/.tmp_$(@F:.o=.ver); \
> + -T $@.symversions; \
> mv -f $(@D)/.tmp_$(@F) $@; \
> - rm -f $(@D)/.tmp_$(@F:.o=.ver); \
> fi
> endif
> -endif
>
> ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
> # compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
> @@ -269,7 +265,8 @@ define rule_cc_o_c
> $(call cmd,checksrc)
> $(call cmd,checkdoc)
> $(call cmd,gen_objtooldep)
> - $(call cmd,modversions_c)
> + $(call cmd,gen_symversions_c)
> + $(if $(CONFIG_LTO_CLANG),,$(call cmd,modversions))
> $(call cmd,record_mcount)
> endef
>
> --
> 2.32.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-05 16:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-05 14:02 [PATCH v2 00/10] kbuild: misc cleanups Masahiro Yamada
2022-04-05 14:02 ` [PATCH v2 09/10] kbuild: refactor cmd_modversions_c Masahiro Yamada
-- strict thread matches above, loose matches on Subject: below --
2022-04-05 11:33 [PATCH v2 00/10] kbuild: misc cleanups Masahiro Yamada
2022-04-05 11:33 ` [PATCH v2 09/10] kbuild: refactor cmd_modversions_c Masahiro Yamada
2022-04-05 16:42 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox