Skip to content

Commit b55da84

Browse files
masahir0yojeda
authored andcommitted
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. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent ab88514 commit b55da84

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

scripts/Makefile.compiler

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ cc-option = $(call __cc-option, $(CC),\
5353

5454
# cc-option-yn
5555
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
56-
cc-option-yn = $(call try-run,\
57-
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
56+
cc-option-yn = $(if $(call cc-option,$1),y,n)
5857

5958
# cc-disable-warning
6059
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
61-
cc-disable-warning = $(call try-run,\
62-
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
60+
cc-disable-warning = $(if $(call cc-option,-W$(strip $1)),-Wno-$(strip $1))
6361

6462
# gcc-min-version
6563
# Usage: cflags-$(call gcc-min-version, 70100) += -foo
@@ -85,5 +83,4 @@ rustc-option = $(call __rustc-option, $(RUSTC),\
8583

8684
# rustc-option-yn
8785
# Usage: flag := $(call rustc-option-yn,-Cinstrument-coverage)
88-
rustc-option-yn = $(call try-run,\
89-
$(RUSTC) $(KBUILD_RUSTFLAGS) $(1) --crate-type=rlib /dev/null --out-dir=$$TMPOUT -o "$$TMP",y,n)
86+
rustc-option-yn = $(if $(call rustc-option,$1),y,n)

0 commit comments

Comments
 (0)