Skip to content

Commit 0d91f1e

Browse files
committed
Add global GCC version check
We can set some of them lower than 13 if necessary on a per-port basis. At least esp32 and arm ports all use 13 from what I could see.
1 parent 98cc153 commit 0d91f1e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

py/circuitpy_mpconfig.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,19 @@ void background_callback_run_all(void);
599599
// Enable compiler functionality.
600600
#define MICROPY_ENABLE_COMPILER (1)
601601
#define MICROPY_PY_BUILTINS_COMPILE (1)
602+
603+
#ifndef CIRCUITPY_MIN_GCC_VERSION
604+
#define CIRCUITPY_MIN_GCC_VERSION 13
605+
#endif
606+
607+
#if defined(__GNUC__)
608+
#if __GNUC__ < CIRCUITPY_MIN_GCC_VERSION
609+
// (the 3 level scheme here is required to get expansion & stringization
610+
// correct)
611+
#define DO_PRAGMA(x) _Pragma(#x)
612+
#define DO_ERROR_HELPER(x) DO_PRAGMA(GCC error #x)
613+
#define DO_ERROR(x) DO_ERROR_HELPER(Minimum GCC version x \
614+
-- older versions are known to miscompile CircuitPython)
615+
DO_ERROR(CIRCUITPY_MIN_GCC_VERSION);
616+
#endif
617+
#endif

py/circuitpy_mpconfig.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@ CFLAGS += -DCIRCUITPY_TUSB_ATTR_USBRAM=$(CIRCUITPY_TUSB_ATTR_USBRAM)
697697
CIRCUITPY_SWO_TRACE ?= 0
698698
CFLAGS += -DCIRCUITPY_SWO_TRACE=$(CIRCUITPY_SWO_TRACE)
699699

700+
# Check for a minimum GCC version during build (set to 0 to disable)
701+
CIRCUITPY_MIN_GCC_VERSION ?= 13
702+
CFLAGS += -DCIRCUITPY_MIN_GCC_VERSION=$(CIRCUITPY_MIN_GCC_VERSION)
703+
700704
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
701705
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
702706
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.

0 commit comments

Comments
 (0)