kbuild: factor out genksyms command from cmd_gensymtypes_{c,S}
PATCH 1/2 kbuild: factor out genksyms command from cmd_gensymtypes_{c,S}
The genksyms command part in cmd_gensymtypes_{c,S} is duplicated. Factor it out into the 'genksyms' macro.
For the readability, I slightly refactor the arguments to genksyms.
---
scripts/Makefile.build | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
scripts/Makefile.build +8 -11
@@ -125,13 +125,14 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cpp_i_c) +genksyms = scripts/genksyms/genksyms \ + $(if $(1), -T $(2)) \ + $(if $(CONFIG_MODULE_REL_CRCS), -R) \ + $(if $(KBUILD_PRESERVE), -p) \ + -r $(or $(wildcard $(2:.symtypes=.symref), /dev/null)) + # These mirror gensymtypes_S and co below, keep them in synch. -cmd_gensymtypes_c = \ - $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ - scripts/genksyms/genksyms $(if $(1), -T $(2)) \ - $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ - $(if $(KBUILD_PRESERVE),-p) \ - -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) +cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \
@@ -344,11 +345,7 @@ cmd_gensymtypes_S = \ $(CPP) $(a_flags) $< | \ grep "\<___EXPORT_SYMBOL\>" | \ sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ - $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ - scripts/genksyms/genksyms $(if $(1), -T $(2)) \ - $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ - $(if $(KBUILD_PRESERVE),-p) \ - -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ cmd_cc_symtypes_S = \
Signature · 1 line
2.32.0
PATCH 2/2 kbuild: do not remove empty *.symtypes explicitly
Presumably, 'test -s $@ || rm -f $@' intends to remove the output when the genksyms command fails.
It is unneeded because .DELETE_ON_ERROR automatically removes the output on failure.
---
scripts/Makefile.build | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
scripts/Makefile.build +2 -6
@@ -135,9 +135,7 @@ genksyms = scripts/genksyms/genksyms \ cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ -cmd_cc_symtypes_c = \ - $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ - test -s $@ || rm -f $@ + cmd_cc_symtypes_c = $(call cmd_gensymtypes_c,true,$@) $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c)
@@ -348,9 +346,7 @@ cmd_gensymtypes_S = \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ -cmd_cc_symtypes_S = \ - $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ - test -s $@ || rm -f $@ + cmd_cc_symtypes_S = $(call cmd_gensymtypes_S,true,$@) >/dev/null $(obj)/%.symtypes : $(src)/%.S FORCE $(call cmd,cc_symtypes_S)
Signature · 1 line
2.32.0
Re: [PATCH 2/2] kbuild: do not remove empty *.symtypes explicitly
Quoted 18 lines · Masahiro Yamada
Presumably, 'test -s $@ || rm -f $@' intends to remove the output when the genksyms command fails.
It is unneeded because .DELETE_ON_ERROR automatically removes the output on failure.
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.build | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)scripts/Makefile.build +0
-0
scripts/Makefile.build genksyms = scripts/genksyms/genksyms \ · line 138
Quoted 7 lines
scripts/Makefile.build +1
-3@@ -135,9 +135,7 @@ genksyms = scripts/genksyms/genksyms \ cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ -cmd_cc_symtypes_c = \ - $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ - test -s $@ || rm -f $@ + cmd_cc_symtypes_c = $(call cmd_gensymtypes_c,true,$@)
Was it an accident that you removed the redirection of stdout to /dev/null here, but not also below?
If quiet_modtag silences the output, perhaps the redirection should be dropped below as well?
Quoted 17 lines
scripts/Makefile.build +1
-4$(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c)@@ -348,9 +346,7 @@ cmd_gensymtypes_S = \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ -cmd_cc_symtypes_S = \ - $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ - test -s $@ || rm -f $@ + cmd_cc_symtypes_S = $(call cmd_gensymtypes_S,true,$@) >/dev/null $(obj)/%.symtypes : $(src)/%.S FORCE $(call cmd,cc_symtypes_S) --2.32.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 2/2] kbuild: do not remove empty *.symtypes explicitly
Quoted 22 lines · Nick Desaulniers
Quoted 20 lines · Masahiro Yamada
Presumably, 'test -s $@ || rm -f $@' intends to remove the output when the genksyms command fails.
It is unneeded because .DELETE_ON_ERROR automatically removes the output on failure.
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.build | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)scripts/Makefile.build +0
-0@@ -135,9 +135,7 @@ genksyms = scripts/genksyms/genksyms \ cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms)
Quoted 8 lines
scripts/Makefile.build genksyms = scripts/genksyms/genksyms \ · line 138
Quoted 5 lines
scripts/Makefile.build +1
-3quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ -cmd_cc_symtypes_c = \ - $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ - test -s $@ || rm -f $@ + cmd_cc_symtypes_c = $(call cmd_gensymtypes_c,true,$@)Was it an accident that you removed the redirection of stdout to
/dev/nullhere, but not also below?
It was an accident. I will fix it. Thanks.
Quoted 25 lines
If
quiet_modtagsilences the output, perhaps the redirection should be dropped below as well?Quoted 15 lines
scripts/Makefile.build +1
-4$(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c)@@ -348,9 +346,7 @@ cmd_gensymtypes_S = \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ -cmd_cc_symtypes_S = \ - $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ - test -s $@ || rm -f $@ + cmd_cc_symtypes_S = $(call cmd_gensymtypes_S,true,$@) >/dev/null $(obj)/%.symtypes : $(src)/%.S FORCE $(call cmd,cc_symtypes_S) --Quoted 2 lines
2.32.0
--
Thanks,
~Nick Desaulniers
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 5 lines · Masahiro Yamada
The genksyms command part in cmd_gensymtypes_{c,S} is duplicated. Factor it out into the 'genksyms' macro.
For the readability, I slightly refactor the arguments to genksyms.
Looks nicer, thanks for the patch!
Quoted 48 lines
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.build | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)scripts/Makefile.build +8
-12@@ -125,13 +125,14 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cpp_i_c) +genksyms = scripts/genksyms/genksyms \ + $(if $(1), -T $(2)) \ + $(if $(CONFIG_MODULE_REL_CRCS), -R) \ + $(if $(KBUILD_PRESERVE), -p) \ + -r $(or $(wildcard $(2:.symtypes=.symref), /dev/null)) + # These mirror gensymtypes_S and co below, keep them in synch. -cmd_gensymtypes_c = \ - $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ - scripts/genksyms/genksyms $(if $(1), -T $(2)) \ - $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ - $(if $(KBUILD_PRESERVE),-p) \ - -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) +cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \@@ -344,11 +345,7 @@ cmd_gensymtypes_S = \ $(CPP) $(a_flags) $< | \ grep "\<___EXPORT_SYMBOL\>" | \ sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ - $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ - scripts/genksyms/genksyms $(if $(1), -T $(2)) \ - $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ - $(if $(KBUILD_PRESERVE),-p) \ - -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ cmd_cc_symtypes_S = \ --2.32.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 12 lines · Nick Desaulniers
Quoted 5 lines · Masahiro Yamada
The genksyms command part in cmd_gensymtypes_{c,S} is duplicated. Factor it out into the 'genksyms' macro.
For the readability, I slightly refactor the arguments to genksyms.
Looks nicer, thanks for the patch!
Reviewed-by Nick Desaulniers <[email protected]>Quoted 1 line
Applied to linux-kbuild.
Quoted 52 lines
Quoted 45 lines
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.build | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)scripts/Makefile.build +8
-12@@ -125,13 +125,14 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cpp_i_c) +genksyms = scripts/genksyms/genksyms \ + $(if $(1), -T $(2)) \ + $(if $(CONFIG_MODULE_REL_CRCS), -R) \ + $(if $(KBUILD_PRESERVE), -p) \ + -r $(or $(wildcard $(2:.symtypes=.symref), /dev/null)) + # These mirror gensymtypes_S and co below, keep them in synch. -cmd_gensymtypes_c = \ - $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ - scripts/genksyms/genksyms $(if $(1), -T $(2)) \ - $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ - $(if $(KBUILD_PRESERVE),-p) \ - -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) +cmd_gensymtypes_c = $(CPP) -D__GENKSYMS__ $(c_flags) $< | $(genksyms) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \@@ -344,11 +345,7 @@ cmd_gensymtypes_S = \ $(CPP) $(a_flags) $< | \ grep "\<___EXPORT_SYMBOL\>" | \ sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ - $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ - scripts/genksyms/genksyms $(if $(1), -T $(2)) \ - $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ - $(if $(KBUILD_PRESERVE),-p) \ - -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | $(genksyms) quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ cmd_cc_symtypes_S = \ --Quoted 2 lines
2.32.0
--
Thanks,
~Nick Desaulniers
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 9 lines · Masahiro Yamada
Quoted 6 lines · Nick Desaulniers
Quoted 4 lines · Masahiro Yamada
The genksyms command part in cmd_gensymtypes_{c,S} is duplicated. Factor it out into the 'genksyms' macro.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
For the readability, I slightly refactor the arguments to genksyms.
Looks nicer, thanks for the patch!
Reviewed-by Nick Desaulniers <[email protected]>Quoted 1 line
Applied to linux-kbuild.
No, this patch is wrong.
I will send v2 later.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/Makefile.build | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)scripts/Makefile.build +0
-0@@ -125,13 +125,14 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cpp_i_c)
Quoted 5 lines
Quoted 5 lines
scripts/Makefile.build cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< · line 132
Quoted 5 lines
scripts/Makefile.build +5
-0+genksyms = scripts/genksyms/genksyms \ + $(if $(1), -T $(2)) \ + $(if $(CONFIG_MODULE_REL_CRCS), -R) \ + $(if $(KBUILD_PRESERVE), -p) \ + -r $(or $(wildcard $(2:.symtypes=.symref), /dev/null))
The position of the closing parenthesis was wrong.
-r $(or $(wildcard $(2:.symtypes=.symref)), /dev/null)
Signature · 2 lines
Best Regards Masahiro Yamada