Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0664684

Browse files
nathanchancemasahir0y
authored andcommitted
kbuild: Add -Werror=ignored-optimization-argument to CLANG_FLAGS
Similar to commit 589834b ("kbuild: Add -Werror=unknown-warning-option to CLANG_FLAGS"). Clang ignores certain GCC flags that it has not implemented, only emitting a warning: $ echo | clang -fsyntax-only -falign-jumps -x c - clang-14: warning: optimization flag '-falign-jumps' is not supported [-Wignored-optimization-argument] When one of these flags gets added to KBUILD_CFLAGS unconditionally, all subsequent cc-{disable-warning,option} calls fail because -Werror was added to these invocations to turn the above warning and the equivalent -W flag warning into errors. To catch the presence of these flags earlier, turn -Wignored-optimization-argument into an error so that the flags can either be implemented or ignored via cc-option and there are no more weird errors. Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 7fa6a27 commit 0664684

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/Makefile.clang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
2929
else
3030
CLANG_FLAGS += -fintegrated-as
3131
endif
32+
# By default, clang only warns when it encounters an unknown warning flag or
33+
# certain optimization flags it knows it has not implemented.
34+
# Make it behave more like gcc by erroring when these flags are encountered
35+
# so they can be implemented or wrapped in cc-option.
3236
CLANG_FLAGS += -Werror=unknown-warning-option
37+
CLANG_FLAGS += -Werror=ignored-optimization-argument
3338
KBUILD_CFLAGS += $(CLANG_FLAGS)
3439
KBUILD_AFLAGS += $(CLANG_FLAGS)
3540
export CLANG_FLAGS

0 commit comments

Comments
 (0)