From 0d91f1e08540be80ab4c5c2f35f62ce4c6a8475d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 1 Nov 2024 11:30:24 -0500 Subject: [PATCH 1/3] 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. --- py/circuitpy_mpconfig.h | 16 ++++++++++++++++ py/circuitpy_mpconfig.mk | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index adb881ebac23a..eacfbfbeb77c2 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -599,3 +599,19 @@ void background_callback_run_all(void); // Enable compiler functionality. #define MICROPY_ENABLE_COMPILER (1) #define MICROPY_PY_BUILTINS_COMPILE (1) + +#ifndef CIRCUITPY_MIN_GCC_VERSION +#define CIRCUITPY_MIN_GCC_VERSION 13 +#endif + +#if defined(__GNUC__) +#if __GNUC__ < CIRCUITPY_MIN_GCC_VERSION +// (the 3 level scheme here is required to get expansion & stringization +// correct) +#define DO_PRAGMA(x) _Pragma(#x) +#define DO_ERROR_HELPER(x) DO_PRAGMA(GCC error #x) +#define DO_ERROR(x) DO_ERROR_HELPER(Minimum GCC version x \ + -- older versions are known to miscompile CircuitPython) +DO_ERROR(CIRCUITPY_MIN_GCC_VERSION); +#endif +#endif diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index e425552911929..1a831dbf314b5 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -697,6 +697,10 @@ CFLAGS += -DCIRCUITPY_TUSB_ATTR_USBRAM=$(CIRCUITPY_TUSB_ATTR_USBRAM) CIRCUITPY_SWO_TRACE ?= 0 CFLAGS += -DCIRCUITPY_SWO_TRACE=$(CIRCUITPY_SWO_TRACE) +# Check for a minimum GCC version during build (set to 0 to disable) +CIRCUITPY_MIN_GCC_VERSION ?= 13 +CFLAGS += -DCIRCUITPY_MIN_GCC_VERSION=$(CIRCUITPY_MIN_GCC_VERSION) + # Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk # $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. # This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. From 3a5c4e3a7473522b22a55b0c55b66e0ab40e0fcc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 1 Nov 2024 14:22:20 -0500 Subject: [PATCH 2/3] these ports currently use older gcc versions --- ports/broadcom/Makefile | 2 ++ ports/litex/mpconfigport.mk | 1 + 2 files changed, 3 insertions(+) diff --git a/ports/broadcom/Makefile b/ports/broadcom/Makefile index 56c8c3237443e..1c640fb2f7b99 100644 --- a/ports/broadcom/Makefile +++ b/ports/broadcom/Makefile @@ -10,10 +10,12 @@ ifeq ($(CHIP_VARIANT), "bcm2711") CFLAGS += -mcpu=cortex-a72 -DBCM_VERSION=2711 CROSS_COMPILE = aarch64-none-elf- SUFFIX = 8 +CIRCUITPY_MIN_GCC_VERSION ?= 10 else ifeq ($(CHIP_VARIANT), "bcm2837") CFLAGS += -mcpu=cortex-a53 -DBCM_VERSION=2837 CROSS_COMPILE = aarch64-none-elf- SUFFIX = 8 +CIRCUITPY_MIN_GCC_VERSION ?= 10 else ifeq ($(CHIP_VARIANT), "bcm2835") CFLAGS += -mcpu=arm1176jzf-s -DBCM_VERSION=2835 CROSS_COMPILE = arm-none-eabi- diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index d8dc4eef1edcd..a93a3890bbc9a 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -31,3 +31,4 @@ CIRCUITPY_USB_HID = 1 CIRCUITPY_USB_MIDI = 1 CIRCUITPY_BUILD_EXTENSIONS ?= dfu +CIRCUITPY_MIN_GCC_VERSION ?= 8 From a4399cf2d34bc7436e719b9c02f63bd6d7e8425f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 1 Nov 2024 15:04:11 -0500 Subject: [PATCH 3/3] Fix gcc version on broadcom again --- ports/broadcom/Makefile | 2 -- ports/broadcom/mpconfigport.mk | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/broadcom/Makefile b/ports/broadcom/Makefile index 1c640fb2f7b99..56c8c3237443e 100644 --- a/ports/broadcom/Makefile +++ b/ports/broadcom/Makefile @@ -10,12 +10,10 @@ ifeq ($(CHIP_VARIANT), "bcm2711") CFLAGS += -mcpu=cortex-a72 -DBCM_VERSION=2711 CROSS_COMPILE = aarch64-none-elf- SUFFIX = 8 -CIRCUITPY_MIN_GCC_VERSION ?= 10 else ifeq ($(CHIP_VARIANT), "bcm2837") CFLAGS += -mcpu=cortex-a53 -DBCM_VERSION=2837 CROSS_COMPILE = aarch64-none-elf- SUFFIX = 8 -CIRCUITPY_MIN_GCC_VERSION ?= 10 else ifeq ($(CHIP_VARIANT), "bcm2835") CFLAGS += -mcpu=arm1176jzf-s -DBCM_VERSION=2835 CROSS_COMPILE = arm-none-eabi- diff --git a/ports/broadcom/mpconfigport.mk b/ports/broadcom/mpconfigport.mk index 543e174683617..b4b3e2ebf8192 100644 --- a/ports/broadcom/mpconfigport.mk +++ b/ports/broadcom/mpconfigport.mk @@ -25,3 +25,9 @@ USB_NUM_ENDPOINT_PAIRS = 8 USB_HIGHSPEED = 1 CIRCUITPY_BUILD_EXTENSIONS ?= disk.img.zip,kernel8.img + +ifeq ($(CHIP_VARIANT), "bcm2711") +CIRCUITPY_MIN_GCC_VERSION ?= 10 +else ifeq ($(CHIP_VARIANT), "bcm2837") +CIRCUITPY_MIN_GCC_VERSION ?= 10 +endif