From de3c42125b661f62757f8ee4f6184c089340d3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 13 Nov 2023 23:29:12 +0100 Subject: [PATCH] chibios: disable RWX segment warning on newer GNU lds (#22007) --- builddefs/common_rules.mk | 11 ++++++++--- platforms/avr/platform.mk | 4 +--- platforms/chibios/platform.mk | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk index 52dccbe475bc..ddd36409a7ca 100644 --- a/builddefs/common_rules.mk +++ b/builddefs/common_rules.mk @@ -15,6 +15,13 @@ VPATH := # Helper to return the distinct elements of a list uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) +cc-option = $(shell \ + if $(CC) $(1) -shared -o /dev/null -xc /dev/null > /dev/null 2>&1; \ + then echo "$(1)"; else echo "$(2)"; fi) + +# helper to pass comma character to make functions +, := , + # Convert all SRC to OBJ define OBJ_FROM_SRC $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$(patsubst %.clib,$1/%.a,$($1_SRC)))))) @@ -66,9 +73,7 @@ CFLAGS += $(CDEFS) CFLAGS += -O$(OPT) # add color ifeq ($(COLOR),true) -ifeq ("$(shell echo "int main(){}" | $(CC) -fdiagnostics-color -x c - -o /dev/null 2>&1)", "") - CFLAGS+= -fdiagnostics-color -endif + CFLAGS+= $(call cc-option, -fdiagnostics-color) endif CFLAGS += -Wall CFLAGS += -Wstrict-prototypes diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index aef449cadf76..8f8e01523fd7 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk @@ -12,9 +12,7 @@ HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) BIN = -ifeq ("$(shell echo "int main(){}" | $(CC) --param=min-pagesize=0 -x c - -o /dev/null 2>&1)", "") -COMPILEFLAGS += --param=min-pagesize=0 -endif +COMPILEFLAGS += $(call cc-option, --param=min-pagesize=0) COMPILEFLAGS += -funsigned-char COMPILEFLAGS += -funsigned-bitfields diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk index 081b001e6da9..6c38aa16a7c5 100644 --- a/platforms/chibios/platform.mk +++ b/platforms/chibios/platform.mk @@ -476,6 +476,9 @@ HEX = $(OBJCOPY) -O $(FORMAT) EEP = BIN = $(OBJCOPY) -O binary +# disable warning about RWX triggered by ChibiOS linker scripts +SHARED_LDFLAGS += $(call cc-option, -Wl$(,)--no-warn-rwx-segments) + ############################################################################## # Make targets #