Skip to content

Commit 54b7be4

Browse files
Leo-YanKernel Patches Daemon
authored andcommitted
bpftool: Conditionally add -Wformat-signedness flag
clang-18.1.3 on Ubuntu 24.04.2 reports warning: warning: unknown warning option '-Wformat-signedness' [-Wunknown-warning-option] Conditionally add the option only when it is supported by compiler. Signed-off-by: Leo Yan <[email protected]>
1 parent d9fd2c0 commit 54b7be4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tools/bpf/bpftool/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,21 @@ $(LIBBPF_BOOTSTRAP)-clean: FORCE | $(LIBBPF_BOOTSTRAP_OUTPUT)
6464
prefix ?= /usr/local
6565
bash_compdir ?= /usr/share/bash-completion/completions
6666

67+
try-run = $(shell set -e; \
68+
if ($(1)) >/dev/null 2>&1; \
69+
then echo "$(2)"; \
70+
else echo "$(3)"; \
71+
fi)
72+
73+
__cc-option = $(call try-run,\
74+
$(1) -Werror $(2) -c -x c /dev/null -o /dev/null,$(2),)
75+
cc-option = $(call __cc-option, $(CC),$(1))
76+
6777
CFLAGS += -O2
6878
CFLAGS += -W
6979
CFLAGS += -Wall
7080
CFLAGS += -Wextra
71-
CFLAGS += -Wformat-signedness
81+
CFLAGS += $(call cc-option,-Wformat-signedness)
7282
CFLAGS += -Wno-unused-parameter
7383
CFLAGS += -Wno-missing-field-initializers
7484
CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS))

0 commit comments

Comments
 (0)