diff --git a/.travis.yml b/.travis.yml index 55545c201f..c0a4bcaea7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -176,9 +176,9 @@ jobs: after_failure: - tests/run-tests --print-failures - # unix nanbox (and using Python 2 to check it can run the build scripts) + # unix nanbox/float (and using Python 2 to check it can run the build scripts) - stage: test - env: NAME="unix nanbox port build and tests" + env: NAME="unix nanbox/float port build and tests" install: - sudo apt-get install gcc-multilib libffi-dev:i386 script: @@ -186,19 +186,25 @@ jobs: - make ${MAKEOPTS} -C ports/unix submodules - make ${MAKEOPTS} -C ports/unix PYTHON=python2 deplibs - make ${MAKEOPTS} -C ports/unix PYTHON=python2 VARIANT=nanbox - - make ${MAKEOPTS} -C ports/unix PYTHON=python2 VARIANT=nanbox test_full + - make ${MAKEOPTS} -C ports/unix PYTHON=python2 VARIANT=nanbox test_full || travis_terminate 1 + - make ${MAKEOPTS} -C ports/unix clean + - make ${MAKEOPTS} -C ports/unix CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT" + - make ${MAKEOPTS} -C ports/unix test after_failure: - tests/run-tests --print-failures - # unix stackless + # unix stackless/float with clang - stage: test - env: NAME="unix stackless port build and tests with clang" + env: NAME="unix stackless/float port build and tests with clang" install: - sudo apt-get install clang script: - make ${MAKEOPTS} -C mpy-cross CC=clang - make ${MAKEOPTS} -C ports/unix submodules - make ${MAKEOPTS} -C ports/unix CC=clang CFLAGS_EXTRA="-DMICROPY_STACKLESS=1 -DMICROPY_STACKLESS_STRICT=1" + - make ${MAKEOPTS} -C ports/unix CC=clang test || travis_terminate 1 + - make ${MAKEOPTS} -C ports/unix clean + - make ${MAKEOPTS} -C ports/unix CC=clang CFLAGS_EXTRA="-DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT" - make ${MAKEOPTS} -C ports/unix CC=clang test after_failure: - tests/run-tests --print-failures diff --git a/ports/esp32/Makefile b/ports/esp32/Makefile index 0789455854..bd89e8b0c5 100644 --- a/ports/esp32/Makefile +++ b/ports/esp32/Makefile @@ -382,6 +382,9 @@ OBJ_MP += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o)) OBJ_MP += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) OBJ_MP += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) +# Only enable this for the MicroPython source: ignore warnings from esp-idf. +$(OBJ_MP): CFLAGS += -Wdouble-promotion -Wfloat-conversion + # List of sources for qstr extraction SRC_QSTR += $(SRC_C) $(EXTMOD_SRC_C) $(LIB_SRC_C) $(DRIVERS_SRC_C) # Append any auto-generated sources that are needed by sources listed in SRC_QSTR diff --git a/ports/javascript/Makefile b/ports/javascript/Makefile index 384253e544..4f9dd444be 100644 --- a/ports/javascript/Makefile +++ b/ports/javascript/Makefile @@ -19,7 +19,7 @@ ifdef EMSCRIPTEN CPP += -isystem $(EMSCRIPTEN)/system/include/libc -cxx-isystem $(EMSCRIPTEN)/system/include/libcxx endif -CFLAGS = -m32 -Wall -Werror $(INC) -std=c99 $(COPT) +CFLAGS = -m32 -Wall -Werror -Wdouble-promotion -Wfloat-conversion $(INC) -std=c99 $(COPT) LDFLAGS = -m32 -Wl,-Map=$@.map,--cref -Wl,--gc-sections CFLAGS += -O0 -DNDEBUG diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 8f06c208de..3bf9916e7f 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -40,7 +40,7 @@ INC += -I$(TOP)/lib/tinyusb/hw INC += -I$(TOP)/lib/tinyusb/hw/bsp/teensy_40 CFLAGS_MCU = -mtune=cortex-m7 -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU) +CFLAGS = $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 -nostdlib -mthumb $(CFLAGS_MCU) CFLAGS += -DCPU_$(MCU_SERIES) -DCPU_$(MCU_VARIANT) CFLAGS += -DXIP_EXTERNAL_FLASH=1 \ -DXIP_BOOT_HEADER_ENABLE=1 \ diff --git a/ports/minimal/Makefile b/ports/minimal/Makefile index b44dda7ac8..5801d64087 100644 --- a/ports/minimal/Makefile +++ b/ports/minimal/Makefile @@ -22,12 +22,12 @@ INC += -I$(BUILD) ifeq ($(CROSS), 1) DFU = $(TOP)/tools/dfu.py PYDFU = $(TOP)/tools/pydfu.py -CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion +CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT) LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections else LD = gcc -CFLAGS = -m32 $(INC) -Wall -Werror -std=c99 $(COPT) +CFLAGS = -m32 $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT) LDFLAGS = -m32 -Wl,-Map=$@.map,--cref -Wl,--gc-sections endif diff --git a/ports/powerpc/Makefile b/ports/powerpc/Makefile index d869ebc4f1..7aa4f1449c 100644 --- a/ports/powerpc/Makefile +++ b/ports/powerpc/Makefile @@ -17,7 +17,7 @@ INC += -I. INC += -I$(TOP) INC += -I$(BUILD) -CFLAGS = $(INC) -g -Wall -std=c99 $(COPT) +CFLAGS = $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT) CFLAGS += -mno-string -mno-multiple -mno-vsx -mno-altivec -nostdlib CFLAGS += -mlittle-endian -mstrict-align -msoft-float CFLAGS += -Os diff --git a/ports/qemu-arm/Makefile b/ports/qemu-arm/Makefile index 9641e24254..47a45af61d 100644 --- a/ports/qemu-arm/Makefile +++ b/ports/qemu-arm/Makefile @@ -40,7 +40,7 @@ INC += -I. INC += -I$(TOP) INC += -I$(BUILD) -CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 $(COPT) \ +CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 $(COPT) \ -ffunction-sections -fdata-sections #Debugging/Optimization diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index 38c3491b1c..2ddebd1cff 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -93,7 +93,7 @@ CFLAGS_MCU_l4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 CFLAGS_MCU_h7 = $(CFLAGS_CORTEX_M) -mtune=cortex-m7 -mcpu=cortex-m7 CFLAGS_MCU_wb = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA) +CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -Wdouble-promotion -Wfloat-conversion -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA) CFLAGS += -D$(CMSIS_MCU) CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES)) CFLAGS += $(COPT) @@ -117,7 +117,7 @@ ifeq ($(MICROPY_FLOAT_IMPL),none) CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_NONE else CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT -CFLAGS += -fsingle-precision-constant -Wdouble-promotion +CFLAGS += -fsingle-precision-constant endif endif @@ -238,6 +238,13 @@ SRC_LIBM += lib/libm/ef_sqrt.c endif endif +LIBM_O = $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o)) + +# Too many warnings in libm_dbl, disable for now. +ifeq ($(MICROPY_FLOAT_IMPL),double) +$(LIBM_O): CFLAGS := $(filter-out -Wdouble-promotion -Wfloat-conversion, $(CFLAGS)) +endif + EXTMOD_SRC_C = $(addprefix extmod/,\ modonewire.c \ ) @@ -494,7 +501,7 @@ endif OBJ = OBJ += $(PY_O) OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o)) -OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o)) +OBJ += $(LIBM_O) OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) diff --git a/ports/stm32/mboot/Makefile b/ports/stm32/mboot/Makefile index 9e56733005..89fe97ab22 100755 --- a/ports/stm32/mboot/Makefile +++ b/ports/stm32/mboot/Makefile @@ -54,7 +54,7 @@ CFLAGS_MCU_f7 = $(CFLAGS_CORTEX_M) -mtune=cortex-m7 -mcpu=cortex-m7 CFLAGS_MCU_h7 = $(CFLAGS_CORTEX_M) -mtune=cortex-m7 -mcpu=cortex-m7 CFLAGS_MCU_l4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA) +CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA) CFLAGS += -D$(CMSIS_MCU) CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES)) CFLAGS += $(COPT) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 060b3a9842..8cb95d08f9 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -39,7 +39,7 @@ INC += -I$(BUILD) # compiler settings CWARN = -Wall -Werror -CWARN += -Wpointer-arith -Wuninitialized +CWARN += -Wpointer-arith -Wuninitialized -Wdouble-promotion -Wsign-compare -Wfloat-conversion CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA) # Debugging/Optimization diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index 1d429bc422..301917a613 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -70,7 +70,9 @@ #define MICROPY_REPL_AUTO_INDENT (1) #define MICROPY_HELPER_LEXER_UNIX (1) #define MICROPY_ENABLE_SOURCE_LINE (1) +#ifndef MICROPY_FLOAT_IMPL #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) +#endif #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #ifndef MICROPY_STREAMS_NON_BLOCK #define MICROPY_STREAMS_NON_BLOCK (1) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index d5c41a157c..b56ffcbbc0 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -5,7 +5,7 @@ DEBUG ?= 1 CFLAGS += \ -fprofile-arcs -ftest-coverage \ - -Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wsign-compare \ + -Wformat -Wmissing-declarations -Wmissing-prototypes \ -Wold-style-definition -Wpointer-arith -Wshadow -Wuninitialized -Wunused-parameter \ -DMICROPY_UNIX_COVERAGE diff --git a/ports/windows/Makefile b/ports/windows/Makefile index 595ce2036f..6c89635131 100644 --- a/ports/windows/Makefile +++ b/ports/windows/Makefile @@ -15,7 +15,7 @@ INC += -I$(TOP) INC += -I$(BUILD) # compiler settings -CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) +CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) LDFLAGS = $(LDFLAGS_MOD) -lm $(LDFLAGS_EXTRA) # Debugging/Optimization