Skip to content

Commit d64e81d

Browse files
committed
chibios: disable RWX segment warning on newer GNU lds
The cc-option function is LGPL-2.1 from uClibc (originally check_gcc). Adapted to handle -Wl linker arguments. Also adapt the new function in existing logic where applicable. See discussion in qmk#21986 Cc @tzarc @KarlK90
1 parent 3575e27 commit d64e81d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

builddefs/common_rules.mk

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ VPATH :=
1515
# Helper to return the distinct elements of a list
1616
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
1717

18+
cc-option = $(shell \
19+
if $(CC) $(1) -shared -o /dev/null -xc /dev/null > /dev/null 2>&1; \
20+
then echo "$(1)"; else echo "$(2)"; fi)
21+
22+
# helper to pass comma character to make functions
23+
, := ,
24+
1825
# Convert all SRC to OBJ
1926
define OBJ_FROM_SRC
2027
$(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)
6673
CFLAGS += -O$(OPT)
6774
# add color
6875
ifeq ($(COLOR),true)
69-
ifeq ("$(shell echo "int main(){}" | $(CC) -fdiagnostics-color -x c - -o /dev/null 2>&1)", "")
70-
CFLAGS+= -fdiagnostics-color
71-
endif
76+
CFLAGS+= $(call cc-option, -fdiagnostics-color)
7277
endif
7378
CFLAGS += -Wall
7479
CFLAGS += -Wstrict-prototypes

platforms/avr/platform.mk

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature
1212
EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT)
1313
BIN =
1414

15-
ifeq ("$(shell echo "int main(){}" | $(CC) --param=min-pagesize=0 -x c - -o /dev/null 2>&1)", "")
16-
COMPILEFLAGS += --param=min-pagesize=0
17-
endif
15+
COMPILEFLAGS += $(call cc-option, --param=min-pagesize=0)
1816

1917
COMPILEFLAGS += -funsigned-char
2018
COMPILEFLAGS += -funsigned-bitfields

platforms/chibios/platform.mk

+3
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ HEX = $(OBJCOPY) -O $(FORMAT)
476476
EEP =
477477
BIN = $(OBJCOPY) -O binary
478478

479+
# disable warning about RWX triggered by ChibiOS linker scripts
480+
SHARED_LDFLAGS += $(call cc-option, -Wl$(,)--no-warn-rwx-segments)
481+
479482
##############################################################################
480483
# Make targets
481484
#

0 commit comments

Comments
 (0)