From e1a7aa23fdbfbcf5eee0c37d4da223649129c040 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 8 Dec 2023 15:42:41 +1100 Subject: [PATCH] ports: Switch build to use common lib/libm list of source files. Signed-off-by: Damien George --- ports/esp8266/Makefile | 31 +------------ ports/mimxrt/Makefile | 27 +++--------- ports/nrf/Makefile | 62 ++------------------------ ports/qemu-arm/Makefile | 23 +--------- ports/renesas-ra/Makefile | 91 +++------------------------------------ ports/rp2/CMakeLists.txt | 29 +------------ ports/samd/Makefile | 31 +------------ ports/stm32/Makefile | 91 +++------------------------------------ 8 files changed, 33 insertions(+), 352 deletions(-) diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 4f5c2c36e4..32eb39a203 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -127,35 +127,8 @@ SRC_C += \ modespnow.c endif -LIB_SRC_C = $(addprefix lib/,\ - libm/math.c \ - libm/fmodf.c \ - libm/nearbyintf.c \ - libm/ef_sqrt.c \ - libm/erf_lgamma.c \ - libm/kf_rem_pio2.c \ - libm/kf_sin.c \ - libm/kf_cos.c \ - libm/kf_tan.c \ - libm/ef_rem_pio2.c \ - libm/sf_erf.c \ - libm/sf_sin.c \ - libm/sf_cos.c \ - libm/sf_tan.c \ - libm/sf_frexp.c \ - libm/sf_modf.c \ - libm/sf_ldexp.c \ - libm/acoshf.c \ - libm/asinfacosf.c \ - libm/asinhf.c \ - libm/atanf.c \ - libm/atanhf.c \ - libm/atan2f.c \ - libm/log1pf.c \ - libm/roundf.c \ - libm/wf_lgamma.c \ - libm/wf_tgamma.c \ - ) +LIB_SRC_C += $(SRC_LIB_LIBM_C) +LIB_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) SHARED_SRC_C = $(addprefix shared/,\ libc/__errno.c \ diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 542382b6fa..f514b773fd 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -269,26 +269,19 @@ endif # Math library source files ifeq ($(MICROPY_FLOAT_IMPL),double) - LIBM_SRC_C += $(addprefix lib/libm_dbl/,\ - __cos.c __expo2.c __fpclassify.c __rem_pio2.c __rem_pio2_large.c __signbit.c __sin.c __tan.c acos.c acosh.c \ - asin.c asinh.c atan.c atan2.c atanh.c ceil.c copysign.c cos.c cosh.c erf.c exp.c expm1.c floor.c fmod.c \ - frexp.c ldexp.c lgamma.c log.c log10.c log1p.c modf.c nearbyint.c pow.c rint.c round.c scalbn.c sin.c \ - sinh.c tan.c tanh.c tgamma.c trunc.c) + LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_C) # ifeq ($(SUPPORTS_HARDWARE_FP_DOUBLE),1) - LIBM_SRC_C += lib/libm_dbl/thumb_vfp_sqrt.c + LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_HW_C) else - LIBM_SRC_C += lib/libm_dbl/sqrt.c + LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_SW_C) endif else - LIBM_SRC_C += $(addprefix lib/libm/,\ - acoshf.c asinfacosf.c asinhf.c atan2f.c atanf.c atanhf.c ef_rem_pio2.c erf_lgamma.c fmodf.c kf_cos.c \ - kf_rem_pio2.c kf_sin.c kf_tan.c log1pf.c math.c nearbyintf.c roundf.c sf_cos.c sf_erf.c sf_frexp.c sf_ldexp.c \ - sf_modf.c sf_sin.c sf_tan.c wf_lgamma.c wf_tgamma.c) + LIBM_SRC_C += $(SRC_LIB_LIBM_C) ifeq ($(SUPPORTS_HARDWARE_FP_SINGLE),1) - LIBM_SRC_C += lib/libm/thumb_vfp_sqrtf.c + LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_HW_C) else - LIBM_SRC_C += lib/libm/ef_sqrt.c + LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) endif endif @@ -439,15 +432,9 @@ endif # ============================================================================= LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) -LIBM_O = $(addprefix $(BUILD)/, $(LIBM_SRC_C:.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 OBJ += $(PY_O) -OBJ += $(LIBM_O) +OBJ += $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 45e44aed5a..7150aa6399 100644 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -167,69 +167,15 @@ LIBS = \ ifeq ($(MCU_VARIANT), nrf52) -SRC_LIB_C += $(addprefix lib/,\ - libm/math.c \ - libm/fmodf.c \ - libm/nearbyintf.c \ - libm/ef_sqrt.c \ - libm/kf_rem_pio2.c \ - libm/kf_sin.c \ - libm/kf_cos.c \ - libm/kf_tan.c \ - libm/ef_rem_pio2.c \ - libm/sf_sin.c \ - libm/sf_cos.c \ - libm/sf_tan.c \ - libm/sf_frexp.c \ - libm/sf_modf.c \ - libm/sf_ldexp.c \ - libm/asinfacosf.c \ - libm/acoshf.c \ - libm/asinhf.c \ - libm/atanf.c \ - libm/atan2f.c \ - libm/atanhf.c \ - libm/log1pf.c \ - libm/sf_erf.c \ - libm/erf_lgamma.c \ - libm/wf_lgamma.c \ - libm/wf_tgamma.c \ - libm/roundf.c \ - ) +SRC_LIB_C += $(SRC_LIB_LIBM_C) +SRC_LIB_C += $(SRC_LIB_LIBM_SQRT_SW_C) endif ifeq ($(MCU_VARIANT), nrf91) -SRC_LIB_C += $(addprefix lib/,\ - libm/math.c \ - libm/fmodf.c \ - libm/nearbyintf.c \ - libm/ef_sqrt.c \ - libm/kf_rem_pio2.c \ - libm/kf_sin.c \ - libm/kf_cos.c \ - libm/kf_tan.c \ - libm/ef_rem_pio2.c \ - libm/sf_sin.c \ - libm/sf_cos.c \ - libm/sf_tan.c \ - libm/sf_frexp.c \ - libm/sf_modf.c \ - libm/sf_ldexp.c \ - libm/asinfacosf.c \ - libm/acoshf.c \ - libm/asinhf.c \ - libm/atanf.c \ - libm/atan2f.c \ - libm/atanhf.c \ - libm/log1pf.c \ - libm/sf_erf.c \ - libm/erf_lgamma.c \ - libm/wf_lgamma.c \ - libm/wf_tgamma.c \ - libm/roundf.c \ - ) +SRC_LIB_C += $(SRC_LIB_LIBM_C) +SRC_LIB_C += $(SRC_LIB_LIBM_SQRT_SW_C) include drivers/secureboot/secureboot.mk diff --git a/ports/qemu-arm/Makefile b/ports/qemu-arm/Makefile index 9b5cfc4af0..f521a0c5ad 100644 --- a/ports/qemu-arm/Makefile +++ b/ports/qemu-arm/Makefile @@ -88,27 +88,8 @@ SRC_TEST_C = \ test_main.c \ lib/tinytest/tinytest.c \ -LIB_SRC_C += $(addprefix lib/,\ - libm/math.c \ - libm/fmodf.c \ - libm/nearbyintf.c \ - libm/ef_sqrt.c \ - libm/kf_rem_pio2.c \ - libm/kf_sin.c \ - libm/kf_cos.c \ - libm/kf_tan.c \ - libm/ef_rem_pio2.c \ - libm/sf_sin.c \ - libm/sf_cos.c \ - libm/sf_tan.c \ - libm/sf_frexp.c \ - libm/sf_modf.c \ - libm/sf_ldexp.c \ - libm/asinfacosf.c \ - libm/atanf.c \ - libm/atan2f.c \ - libm/roundf.c \ - ) +LIB_SRC_C += $(SRC_LIB_LIBM_C) +LIB_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) OBJ_COMMON = OBJ_COMMON += $(PY_O) diff --git a/ports/renesas-ra/Makefile b/ports/renesas-ra/Makefile index 3512e4a94d..1e9cd2db5b 100644 --- a/ports/renesas-ra/Makefile +++ b/ports/renesas-ra/Makefile @@ -198,98 +198,21 @@ TINYUSB_SRC_C += $(addprefix lib/tinyusb/,\ ) ifeq ($(MICROPY_FLOAT_IMPL),double) -LIBM_SRC_C += $(addprefix lib/libm_dbl/,\ - __cos.c \ - __expo2.c \ - __fpclassify.c \ - __rem_pio2.c \ - __rem_pio2_large.c \ - __signbit.c \ - __sin.c \ - __tan.c \ - acos.c \ - acosh.c \ - asin.c \ - asinh.c \ - atan.c \ - atan2.c \ - atanh.c \ - ceil.c \ - cos.c \ - cosh.c \ - copysign.c \ - erf.c \ - exp.c \ - expm1.c \ - floor.c \ - fmod.c \ - frexp.c \ - ldexp.c \ - lgamma.c \ - log.c \ - log10.c \ - log1p.c \ - modf.c \ - nearbyint.c \ - pow.c \ - rint.c \ - round.c \ - scalbn.c \ - sin.c \ - sinh.c \ - tan.c \ - tanh.c \ - tgamma.c \ - trunc.c \ - ) +LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_C) ifeq ($(SUPPORTS_HARDWARE_FP_DOUBLE),1) -LIBM_SRC_C += lib/libm_dbl/thumb_vfp_sqrt.c +LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_HW_C) else -LIBM_SRC_C += lib/libm_dbl/sqrt.c +LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_SW_C) endif else -LIBM_SRC_C += $(addprefix lib/libm/,\ - math.c \ - acoshf.c \ - asinfacosf.c \ - asinhf.c \ - atan2f.c \ - atanf.c \ - atanhf.c \ - ef_rem_pio2.c \ - erf_lgamma.c \ - fmodf.c \ - kf_cos.c \ - kf_rem_pio2.c \ - kf_sin.c \ - kf_tan.c \ - log1pf.c \ - nearbyintf.c \ - roundf.c \ - sf_cos.c \ - sf_erf.c \ - sf_frexp.c \ - sf_ldexp.c \ - sf_modf.c \ - sf_sin.c \ - sf_tan.c \ - wf_lgamma.c \ - wf_tgamma.c \ - ) +LIBM_SRC_C += $(SRC_LIB_LIBM_C) ifeq ($(SUPPORTS_HARDWARE_FP_SINGLE),1) -LIBM_SRC_C += lib/libm/thumb_vfp_sqrtf.c +LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_HW_C) else -LIBM_SRC_C += lib/libm/ef_sqrt.c +LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) endif endif -LIBM_O = $(addprefix $(BUILD)/, $(LIBM_SRC_C:.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 - DRIVERS_SRC_C += $(addprefix drivers/,\ bus/softspi.c \ bus/softqspi.c \ @@ -470,7 +393,7 @@ endif OBJ += $(PY_O) OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) -OBJ += $(LIBM_O) +OBJ += $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(HAL_SRC_C:.c=.o)) diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt index c68c46cb69..5da54dc1c9 100644 --- a/ports/rp2/CMakeLists.txt +++ b/ports/rp2/CMakeLists.txt @@ -209,33 +209,8 @@ target_sources(pico_float_micropython INTERFACE ${PICO_SDK_PATH}/src/rp2_common/pico_float/float_aeabi.S ${PICO_SDK_PATH}/src/rp2_common/pico_float/float_init_rom.c ${PICO_SDK_PATH}/src/rp2_common/pico_float/float_v1_rom_shim.S - ${MICROPY_DIR}/lib/libm/math.c - ${MICROPY_DIR}/lib/libm/acoshf.c - ${MICROPY_DIR}/lib/libm/asinfacosf.c - ${MICROPY_DIR}/lib/libm/asinhf.c - ${MICROPY_DIR}/lib/libm/atan2f.c - ${MICROPY_DIR}/lib/libm/atanf.c - ${MICROPY_DIR}/lib/libm/atanhf.c - ${MICROPY_DIR}/lib/libm/ef_rem_pio2.c - ${MICROPY_DIR}/lib/libm/ef_sqrt.c - ${MICROPY_DIR}/lib/libm/erf_lgamma.c - ${MICROPY_DIR}/lib/libm/fmodf.c - ${MICROPY_DIR}/lib/libm/kf_cos.c - ${MICROPY_DIR}/lib/libm/kf_rem_pio2.c - ${MICROPY_DIR}/lib/libm/kf_sin.c - ${MICROPY_DIR}/lib/libm/kf_tan.c - ${MICROPY_DIR}/lib/libm/log1pf.c - ${MICROPY_DIR}/lib/libm/nearbyintf.c - ${MICROPY_DIR}/lib/libm/roundf.c - ${MICROPY_DIR}/lib/libm/sf_cos.c - ${MICROPY_DIR}/lib/libm/sf_erf.c - ${MICROPY_DIR}/lib/libm/sf_frexp.c - ${MICROPY_DIR}/lib/libm/sf_ldexp.c - ${MICROPY_DIR}/lib/libm/sf_modf.c - ${MICROPY_DIR}/lib/libm/sf_sin.c - ${MICROPY_DIR}/lib/libm/sf_tan.c - ${MICROPY_DIR}/lib/libm/wf_lgamma.c - ${MICROPY_DIR}/lib/libm/wf_tgamma.c + ${MICROPY_SOURCE_LIB_LIBM} + ${MICROPY_SOURCE_LIB_LIBM_SQRT_SW} ${MICROPY_PORT_DIR}/libm_extra.c ) diff --git a/ports/samd/Makefile b/ports/samd/Makefile index f6409d17e8..4f4c22c57d 100644 --- a/ports/samd/Makefile +++ b/ports/samd/Makefile @@ -142,35 +142,8 @@ ASF4_SRC_C += $(addprefix lib/asf4/$(MCU_SERIES_LOWER)/,\ hpl/nvmctrl/hpl_nvmctrl.c \ ) -LIBM_SRC_C += $(addprefix lib/libm/,\ - acoshf.c \ - asinfacosf.c \ - asinhf.c \ - atan2f.c \ - atanf.c \ - atanhf.c \ - ef_rem_pio2.c \ - ef_sqrt.c \ - erf_lgamma.c \ - fmodf.c \ - kf_cos.c \ - kf_rem_pio2.c \ - kf_sin.c \ - kf_tan.c \ - log1pf.c \ - math.c \ - nearbyintf.c \ - roundf.c \ - sf_cos.c \ - sf_erf.c \ - sf_frexp.c \ - sf_ldexp.c \ - sf_modf.c \ - sf_sin.c \ - sf_tan.c \ - wf_lgamma.c \ - wf_tgamma.c \ - ) +LIBM_SRC_C += $(SRC_LIB_LIBM_C) +LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) TINYUSB_SRC_C += $(addprefix lib/tinyusb/src/,\ class/cdc/cdc_device.c \ diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index a1449e7181..e44a542395 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -189,98 +189,21 @@ SHARED_SRC_C += $(addprefix shared/,\ ) ifeq ($(MICROPY_FLOAT_IMPL),double) -LIBM_SRC_C += $(addprefix lib/libm_dbl/,\ - __cos.c \ - __expo2.c \ - __fpclassify.c \ - __rem_pio2.c \ - __rem_pio2_large.c \ - __signbit.c \ - __sin.c \ - __tan.c \ - acos.c \ - acosh.c \ - asin.c \ - asinh.c \ - atan.c \ - atan2.c \ - atanh.c \ - ceil.c \ - cos.c \ - cosh.c \ - copysign.c \ - erf.c \ - exp.c \ - expm1.c \ - floor.c \ - fmod.c \ - frexp.c \ - ldexp.c \ - lgamma.c \ - log.c \ - log10.c \ - log1p.c \ - modf.c \ - nearbyint.c \ - pow.c \ - rint.c \ - round.c \ - scalbn.c \ - sin.c \ - sinh.c \ - tan.c \ - tanh.c \ - tgamma.c \ - trunc.c \ - ) +LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_C) ifeq ($(SUPPORTS_HARDWARE_FP_DOUBLE),1) -LIBM_SRC_C += lib/libm_dbl/thumb_vfp_sqrt.c +LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_HW_C) else -LIBM_SRC_C += lib/libm_dbl/sqrt.c +LIBM_SRC_C += $(SRC_LIB_LIBM_DBL_SQRT_SW_C) endif else -LIBM_SRC_C += $(addprefix lib/libm/,\ - math.c \ - acoshf.c \ - asinfacosf.c \ - asinhf.c \ - atan2f.c \ - atanf.c \ - atanhf.c \ - ef_rem_pio2.c \ - erf_lgamma.c \ - fmodf.c \ - kf_cos.c \ - kf_rem_pio2.c \ - kf_sin.c \ - kf_tan.c \ - log1pf.c \ - nearbyintf.c \ - roundf.c \ - sf_cos.c \ - sf_erf.c \ - sf_frexp.c \ - sf_ldexp.c \ - sf_modf.c \ - sf_sin.c \ - sf_tan.c \ - wf_lgamma.c \ - wf_tgamma.c \ - ) +LIBM_SRC_C += $(SRC_LIB_LIBM_C) ifeq ($(SUPPORTS_HARDWARE_FP_SINGLE),1) -LIBM_SRC_C += lib/libm/thumb_vfp_sqrtf.c +LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_HW_C) else -LIBM_SRC_C += lib/libm/ef_sqrt.c +LIBM_SRC_C += $(SRC_LIB_LIBM_SQRT_SW_C) endif endif -LIBM_O = $(addprefix $(BUILD)/, $(LIBM_SRC_C:.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 - DRIVERS_SRC_C += $(addprefix drivers/,\ bus/softspi.c \ bus/softqspi.c \ @@ -499,7 +422,7 @@ endif # MICROPY_PY_BLUETOOTH OBJ += $(addprefix $(BUILD)/, $(SRC_O)) OBJ += $(PY_O) OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) -OBJ += $(LIBM_O) +OBJ += $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(HAL_SRC_C:.c=.o))