From 1d13c4ccd1df70e5f71c75075f729874303fe889 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 27 Dec 2021 10:21:47 -0600 Subject: [PATCH] Centralize LONGINT_IMPL handling This closes #5782 --- ports/atmel-samd/mpconfigport.mk | 16 ---------------- ports/cxd56/mpconfigport.mk | 5 ----- ports/espressif/mpconfigport.mk | 5 ----- ports/litex/mpconfigport.mk | 5 ----- ports/mimxrt10xx/mpconfigport.mk | 12 ------------ ports/nrf/mpconfigport.mk | 5 ----- ports/raspberrypi/mpconfigport.mk | 16 ---------------- ports/stm/mpconfigport.mk | 1 - py/circuitpy_defns.mk | 17 ----------------- py/circuitpy_mpconfig.mk | 28 ++++++++++++++++++++++++++++ 10 files changed, 28 insertions(+), 82 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 223a60d796..9d238834fe 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -2,22 +2,6 @@ # parameters that vary based on chip and/or board. LD_TEMPLATE_FILE = boards/common.template.ld -# 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. - -ifeq ($(LONGINT_IMPL),NONE) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none -endif - -ifeq ($(LONGINT_IMPL),MPZ) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong -endif - INTERNAL_LIBM = 1 # Number of USB endpoint pairs. diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk index 865c170aaa..8787c55bcc 100644 --- a/ports/cxd56/mpconfigport.mk +++ b/ports/cxd56/mpconfigport.mk @@ -3,11 +3,6 @@ USB_HIGHSPEED = 1 # Number of USB endpoint pairs. USB_NUM_ENDPOINT_PAIRS = 6 -# 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. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - # Longints can be implemented as mpz, as longlong, or not LONGINT_IMPL = MPZ diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index e78e7b2705..312b05dc40 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -1,8 +1,3 @@ -# 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. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - # Internal math library is substantially smaller than toolchain one INTERNAL_LIBM = 1 diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index ce6ed08841..57f5113b69 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -1,8 +1,3 @@ -# 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. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - # Internal math library is substantially smaller than toolchain one INTERNAL_LIBM = 1 diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index ed9446d0e7..e7e7abe141 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -1,17 +1,5 @@ LD_FILE = $(FLASH).ld $(CHIP_FAMILY).ld imxrt10xx.ld -ifeq ($(LONGINT_IMPL),NONE) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none -endif - -ifeq ($(LONGINT_IMPL),MPZ) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong -endif - INTERNAL_LIBM = 1 USB_HIGHSPEED = 1 diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 55ade5562f..6f432c55ae 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -2,11 +2,6 @@ # parameters that vary based on chip and/or board. LD_TEMPLATE_FILE = boards/common.template.ld -# 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. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - INTERNAL_LIBM = 1 # Number of USB endpoint pairs. diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index bc8a26de7b..1dfb345f5d 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -1,19 +1,3 @@ -# 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. - -ifeq ($(LONGINT_IMPL),NONE) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none -endif - -ifeq ($(LONGINT_IMPL),MPZ) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong -endif - # All raspberrypi ports have longints. LONGINT_IMPL = MPZ diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index 6729a747b5..ba383d41d2 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -1,4 +1,3 @@ -MPY_TOOL_LONGINT_IMPL ?= -mlongint-impl=mpz LONGINT_IMPL ?= MPZ INTERNAL_LIBM ?= 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index e883481675..ea2aa01f03 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -85,23 +85,6 @@ CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool CFLAGS += -DMICROPY_MODULE_FROZEN_MPY endif - -### -# Propagate longint choice from .mk to C. There's no easy string comparison -# in cpp conditionals, so we #define separate names for each. -ifeq ($(LONGINT_IMPL),NONE) -CFLAGS += -DLONGINT_IMPL_NONE -endif - -ifeq ($(LONGINT_IMPL),MPZ) -CFLAGS += -DLONGINT_IMPL_MPZ -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -CFLAGS += -DLONGINT_IMPL_LONGLONG -endif - - ### # Select which builtin modules to compile and include. diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 7f0721264b..042fedb672 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -462,3 +462,31 @@ CFLAGS += -DCIRCUITPY_WATCHDOG=$(CIRCUITPY_WATCHDOG) CIRCUITPY_WIFI ?= 0 CFLAGS += -DCIRCUITPY_WIFI=$(CIRCUITPY_WIFI) + +# 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. +# +# Also propagate longint choice from .mk to C. There's no easy string comparison +# in cpp conditionals, so we #define separate names for each. + +ifeq ($(LONGINT_IMPL),NONE) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none +CFLAGS += -DLONGINT_IMPL_NONE +else ifeq ($(LONGINT_IMPL),MPZ) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz +CFLAGS += -DLONGINT_IMPL_MPZ +else ifeq ($(LONGINT_IMPL),LONGLONG) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong +CFLAGS += -DLONGINT_IMPL_LONGLONG +else +$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)") +endif + +### +ifeq ($(LONGINT_IMPL),NONE) +else ifeq ($(LONGINT_IMPL),MPZ) +else ifeq ($(LONGINT_IMPL),LONGLONG) +else +$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)") +endif