1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

picolibc: Provide integration into the build system [v3]

Support for picolibc as alternative libc implementation is added with
this commit. For now only cortex-m CPU's are supported.

Enable via PICOLIBC=1

---
v2:
	squash fixes in

v3:
	Remove picolibc integer printf/scanf stuff from sys/Makefile.include,
	it gets set in makefiles/libc/picolibc.mk

fixup for dependency
This commit is contained in:
Koen Zandberg 2019-09-25 22:13:08 +02:00 committed by Keith Packard
parent b64f8a22a3
commit ff3bee24b9
6 changed files with 44 additions and 6 deletions

View File

@ -479,6 +479,14 @@ ifneq (,$(filter posix_select,$(USEMODULE)))
USEMODULE += xtimer USEMODULE += xtimer
endif endif
ifneq (,$(filter picolibc,$(USEMODULE)))
# allow custom picolibc syscalls implementations by adding
# picolibc_syscalls_XXX to USEMODULE
ifeq (,$(filter picolibc_syscalls_%,$(USEMODULE)))
USEMODULE += picolibc_syscalls_default
endif
endif
ifneq (,$(filter posix_sockets,$(USEMODULE))) ifneq (,$(filter posix_sockets,$(USEMODULE)))
USEMODULE += bitfield USEMODULE += bitfield
USEMODULE += random USEMODULE += random

View File

@ -4,11 +4,15 @@ USEMODULE += cortexm_common
# include common periph code # include common periph code
USEMODULE += cortexm_common_periph USEMODULE += cortexm_common_periph
# all cortex MCU's use newlib as libc ifeq (1,$(PICOLIBC))
USEMODULE += newlib # Use Picolibc when explicitly selected
USEMODULE += picolibc
# use the nano-specs of Newlib when available else
USEMODULE += newlib_nano # all cortex MCU's use newlib as libc
USEMODULE += newlib
# use the nano-specs of Newlib when available
USEMODULE += newlib_nano
endif
# Export the peripheral drivers to be linked into the final binary: # Export the peripheral drivers to be linked into the final binary:
USEMODULE += periph USEMODULE += periph

View File

@ -0,0 +1,17 @@
ifneq (,$(filter picolibc,$(USEMODULE)))
# Test if picolibc.specs is available
ifeq ($(shell $(LINK) -specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
USE_PICOLIBC = 1
ifeq ($(shell echo "int main(){} void _exit(int n) {(void)n;while(1);}" | LC_ALL=C $(CC) -xc - -o /dev/null -lc -specs=picolibc.specs -Wall -Wextra -pedantic 2>&1 | grep -q "use of wchar_t values across objects may fail" ; echo $$?),0)
CFLAGS += -fshort-wchar
LINKFLAGS += -Wl,--no-wchar-size-warning
endif
endif
endif
ifeq (1,$(USE_PICOLIBC))
LINKFLAGS += -specs=picolibc.specs
CFLAGS += -specs=picolibc.specs
endif
LINKFLAGS += -lc

View File

@ -85,6 +85,7 @@ PSEUDOMODULES += newlib
PSEUDOMODULES += newlib_gnu_source PSEUDOMODULES += newlib_gnu_source
PSEUDOMODULES += newlib_nano PSEUDOMODULES += newlib_nano
PSEUDOMODULES += openthread PSEUDOMODULES += openthread
PSEUDOMODULES += picolibc
PSEUDOMODULES += pktqueue PSEUDOMODULES += pktqueue
PSEUDOMODULES += posix_headers PSEUDOMODULES += posix_headers
PSEUDOMODULES += printf_float PSEUDOMODULES += printf_float

View File

@ -8,7 +8,7 @@ STDIO_MODULES = \
stdio_uart \ stdio_uart \
# #
ifneq (,$(filter newlib,$(USEMODULE))) ifneq (,$(filter newlib picolibc,$(USEMODULE)))
ifeq (,$(filter $(STDIO_MODULES),$(USEMODULE))) ifeq (,$(filter $(STDIO_MODULES),$(USEMODULE)))
USEMODULE += stdio_uart USEMODULE += stdio_uart
endif endif

View File

@ -68,10 +68,18 @@ ifneq (,$(filter newlib,$(USEMODULE)))
include $(RIOTMAKE)/libc/newlib.mk include $(RIOTMAKE)/libc/newlib.mk
endif endif
ifneq (,$(filter picolibc,$(USEMODULE)))
include $(RIOTMAKE)/libc/picolibc.mk
endif
ifneq (,$(filter newlib_syscalls_default,$(USEMODULE))) ifneq (,$(filter newlib_syscalls_default,$(USEMODULE)))
include $(RIOTBASE)/sys/newlib_syscalls_default/Makefile.include include $(RIOTBASE)/sys/newlib_syscalls_default/Makefile.include
endif endif
ifneq (,$(filter picolibc_syscalls_default,$(USEMODULE)))
include $(RIOTBASE)/sys/picolibc_syscalls_default/Makefile.include
endif
ifneq (,$(filter arduino,$(USEMODULE))) ifneq (,$(filter arduino,$(USEMODULE)))
include $(RIOTBASE)/sys/arduino/Makefile.include include $(RIOTBASE)/sys/arduino/Makefile.include
endif endif