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:
parent
b64f8a22a3
commit
ff3bee24b9
@ -479,6 +479,14 @@ ifneq (,$(filter posix_select,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
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)))
|
||||
USEMODULE += bitfield
|
||||
USEMODULE += random
|
||||
|
@ -4,11 +4,15 @@ USEMODULE += cortexm_common
|
||||
# include common periph code
|
||||
USEMODULE += cortexm_common_periph
|
||||
|
||||
# all cortex MCU's use newlib as libc
|
||||
USEMODULE += newlib
|
||||
|
||||
# use the nano-specs of Newlib when available
|
||||
USEMODULE += newlib_nano
|
||||
ifeq (1,$(PICOLIBC))
|
||||
# Use Picolibc when explicitly selected
|
||||
USEMODULE += picolibc
|
||||
else
|
||||
# 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:
|
||||
USEMODULE += periph
|
||||
|
17
makefiles/libc/picolibc.mk
Normal file
17
makefiles/libc/picolibc.mk
Normal 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
|
@ -85,6 +85,7 @@ PSEUDOMODULES += newlib
|
||||
PSEUDOMODULES += newlib_gnu_source
|
||||
PSEUDOMODULES += newlib_nano
|
||||
PSEUDOMODULES += openthread
|
||||
PSEUDOMODULES += picolibc
|
||||
PSEUDOMODULES += pktqueue
|
||||
PSEUDOMODULES += posix_headers
|
||||
PSEUDOMODULES += printf_float
|
||||
|
@ -8,7 +8,7 @@ STDIO_MODULES = \
|
||||
stdio_uart \
|
||||
#
|
||||
|
||||
ifneq (,$(filter newlib,$(USEMODULE)))
|
||||
ifneq (,$(filter newlib picolibc,$(USEMODULE)))
|
||||
ifeq (,$(filter $(STDIO_MODULES),$(USEMODULE)))
|
||||
USEMODULE += stdio_uart
|
||||
endif
|
||||
|
@ -68,10 +68,18 @@ ifneq (,$(filter newlib,$(USEMODULE)))
|
||||
include $(RIOTMAKE)/libc/newlib.mk
|
||||
endif
|
||||
|
||||
ifneq (,$(filter picolibc,$(USEMODULE)))
|
||||
include $(RIOTMAKE)/libc/picolibc.mk
|
||||
endif
|
||||
|
||||
ifneq (,$(filter newlib_syscalls_default,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/newlib_syscalls_default/Makefile.include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter picolibc_syscalls_default,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/picolibc_syscalls_default/Makefile.include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter arduino,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/arduino/Makefile.include
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user