From 1836382f66ac419e383e76a19bda9fec15b95f82 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sun, 17 May 2026 13:06:47 +1000 Subject: [PATCH] GCC 16.1 compatibility fix. (#26216) Co-authored-by: Joel Challis --- builddefs/common_rules.mk | 5 ++++- builddefs/support.mk | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk index 0e5731b4b8..c92ec6baba 100644 --- a/builddefs/common_rules.mk +++ b/builddefs/common_rules.mk @@ -72,6 +72,8 @@ endif endif CFLAGS += -Wall CFLAGS += -Wstrict-prototypes +CFLAGS += $(call cc-option,-Wunused-but-set-variable=1,-Wunused-but-set-variable) +CFLAGS += $(call cc-option,-Wunused-but-set-parameter=1,-Wunused-but-set-parameter) ifneq ($(strip $(ALLOW_WARNINGS)), yes) CFLAGS += -Werror endif @@ -89,7 +91,8 @@ CXXFLAGS += -O$(OPT) CXXFLAGS += -w CXXFLAGS += -Wall CXXFLAGS += -Wundef - +CXXFLAGS += $(call cc-option,-Wunused-but-set-variable=1,-Wunused-but-set-variable) +CXXFLAGS += $(call cc-option,-Wunused-but-set-parameter=1,-Wunused-but-set-parameter) ifneq ($(strip $(ALLOW_WARNINGS)), yes) CXXFLAGS += -Werror endif diff --git a/builddefs/support.mk b/builddefs/support.mk index 7ef7b9b041..de1d3fd5c4 100644 --- a/builddefs/support.mk +++ b/builddefs/support.mk @@ -4,7 +4,7 @@ # $(2) = option to use if $(1) is not supported # $(3) = additional arguments to pass to the compiler during the test, but aren't contained in the output cc-option = $(shell \ - if { echo 'int main(){return 0;}' | $(CC) $(1) $(3) -o /dev/null -x c /dev/null >/dev/null 2>&1; }; \ + if { echo 'int main(){return 0;}' | $(CC) $(1) $(3) -Wl,--unresolved-symbols=ignore-all -o /dev/null -x c /dev/null >/dev/null 2>&1; }; \ then echo "$(1)"; else echo "$(2)"; fi) # Helper to pass comma character to make functions (use with `$(,)` to pass in `$(call ...)` arguments)