kbuild: refactor cc-option-yn, cc-disable-warning, rust-option-yn macros
PATCH 1/1 kbuild: refactor cc-option-yn, cc-disable-warning, rust-option-yn macros
cc-option-yn and cc-disable-warning duplicate the compile command seen a few lines above. These can be defined based on cc-option.
I also refactored rustc-option-yn in the same way, although there are currently no users of it.
---
This avoids applying similar fixes to rustc-option and rustc-option-yn.
scripts/Makefile.compiler | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
scripts/Makefile.compiler +3 -6
@@ -53,13 +53,11 @@ cc-option = $(call __cc-option, $(CC),\ # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) -cc-option-yn = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) +cc-option-yn = $(if $(call cc-option,$1),y,n) # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) -cc-disable-warning = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) +cc-disable-warning = $(if $(call cc-option,-W$(strip $1)),-Wno-$(strip $1)) # gcc-min-version # Usage: cflags-$(call gcc-min-version, 70100) += -foo
@@ -85,5 +83,4 @@ rustc-option = $(call __rustc-option, $(RUSTC),\ # rustc-option-yn # Usage: flag := $(call rustc-option-yn,-Cinstrument-coverage) -rustc-option-yn = $(call try-run,\ - $(RUSTC) $(KBUILD_RUSTFLAGS) $(1) --crate-type=rlib /dev/null --out-dir=$$TMPOUT -o "$$TMP",y,n) +rustc-option-yn = $(if $(call rustc-option,$1),y,n)
Signature · 1 line
2.43.0
Quoted 11 lines · Masahiro Yamada
cc-option-yn and cc-disable-warning duplicate the compile command seen a few lines above. These can be defined based on cc-option.
I also refactored rustc-option-yn in the same way, although there are currently no users of it.
Signed-off-by Masahiro Yamada <[email protected]>---
This avoids applying similar fixes to rustc-option and rustc-option-yn.
Quoted 7 lines · Masahiro Yamada
cc-option-yn and cc-disable-warning duplicate the compile command seen a few lines above. These can be defined based on cc-option.
I also refactored rustc-option-yn in the same way, although there are currently no users of it.
Signed-off-by Masahiro Yamada <[email protected]>
Neat!
Quoted 37 lines
---
This avoids applying similar fixes to rustc-option and rustc-option-yn.
scripts/Makefile.compiler | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)scripts/Makefile.compiler +3
-6@@ -53,13 +53,11 @@ cc-option = $(call __cc-option, $(CC),\ # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) -cc-option-yn = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) +cc-option-yn = $(if $(call cc-option,$1),y,n) # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) -cc-disable-warning = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) +cc-disable-warning = $(if $(call cc-option,-W$(strip $1)),-Wno-$(strip $1)) # gcc-min-version # Usage: cflags-$(call gcc-min-version, 70100) += -foo@@ -85,5 +83,4 @@ rustc-option = $(call __rustc-option, $(RUSTC),\ # rustc-option-yn # Usage: flag := $(call rustc-option-yn,-Cinstrument-coverage) -rustc-option-yn = $(call try-run,\ - $(RUSTC) $(KBUILD_RUSTFLAGS) $(1) --crate-type=rlib /dev/null --out-dir=$$TMPOUT -o "$$TMP",y,n) +rustc-option-yn = $(if $(call rustc-option,$1),y,n)Signature · 1 line
2.43.0
Miguel Ojeda
AppliedQuoted 8 lines · Masahiro Yamada
cc-option-yn and cc-disable-warning duplicate the compile command seen a few lines above. These can be defined based on cc-option.
I also refactored rustc-option-yn in the same way, although there are currently no users of it.
Signed-off-by Masahiro Yamada <[email protected]>
Applied to rust-fixes as a prerequisite for the rustc-option fix -- thanks everyone!
Cheers,
Miguel