Skip to content

Commit 3d04d61

Browse files
authored
Merge pull request #221 from daniel-thompson/fix_gcc-11
Use -fno-ipa-modref when building with gcc-11 (or later)
2 parents 58e756e + 235c0fa commit 3d04d61

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,18 @@ CFLAGS += -Wno-unused-parameter -Wno-expansion-to-defined
270270
# TinyUSB tusb_hal_nrf_power_event
271271
CFLAGS += -Wno-cast-function-type
272272

273+
# Nordic Softdevice SDK header files contains inline assembler that has
274+
# broken constraints. As a result the IPA-modref pass, introduced in gcc-11,
275+
# is able to "prove" that arguments to wrapper functions generated with
276+
# the SVCALL() macro are unused and, as a result, the optimizer will remove
277+
# code within the callers that sets up these arguments (which results in
278+
# a broken bootloader). The broken headers come from Nordic-supplied zip
279+
# files and are not trivial to patch so, for now, we'll simply disable the
280+
# new gcc-11 inter-procedural optimizations.
281+
ifeq (,$(findstring unrecognized,$(shell $(CC) $(CFLAGS) -fno-ipa-modref 2>&1)))
282+
CFLAGS += -fno-ipa-modref
283+
endif
284+
273285
# Defined Symbol (MACROS)
274286
CFLAGS += -D__HEAP_SIZE=0
275287
CFLAGS += -DCONFIG_GPIO_AS_PINRESET

0 commit comments

Comments
 (0)