2019-09-25 22:13:08 +02:00
|
|
|
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
|
2022-11-04 13:07:01 +01:00
|
|
|
ifeq ($(shell echo "int main(){} void _exit(int n) {(void)n;while(1);}" | LC_ALL=C $(LINK) -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)
|
2019-09-25 22:13:08 +02:00
|
|
|
CFLAGS += -fshort-wchar
|
|
|
|
LINKFLAGS += -Wl,--no-wchar-size-warning
|
|
|
|
endif
|
2021-02-15 10:51:51 +01:00
|
|
|
else
|
2021-03-01 13:47:53 +01:00
|
|
|
BUILDDEPS += _missing-picolibc
|
2019-09-25 22:13:08 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2021-03-01 13:47:53 +01:00
|
|
|
.PHONY: _missing-picolibc
|
|
|
|
|
|
|
|
_missing-picolibc:
|
2022-05-30 12:38:19 +02:00
|
|
|
@$(Q)echo "picolibc was selected to be build but no picolibc.specs could be found"
|
2021-03-01 13:47:53 +01:00
|
|
|
@$(Q)echo "you might want to install "picolibc" for "$(TARGET_ARCH)""
|
|
|
|
@$(Q)echo "or add "FEATURES_BLACKLIST += picolibc" to Makefile)"
|
2021-08-05 20:52:15 +02:00
|
|
|
@$(COLOR_ECHO) "$(COLOR_RED)check your installation or build configuration.$(COLOR_RESET)"
|
2021-03-01 13:47:53 +01:00
|
|
|
@$(Q)exit 1
|
|
|
|
|
2019-09-25 22:13:08 +02:00
|
|
|
ifeq (1,$(USE_PICOLIBC))
|
|
|
|
LINKFLAGS += -specs=picolibc.specs
|
|
|
|
CFLAGS += -specs=picolibc.specs
|
2020-07-31 01:26:34 +02:00
|
|
|
ifeq (,$(filter printf_float scanf_float,$(USEMODULE)))
|
2020-08-24 20:35:01 +02:00
|
|
|
CFLAGS += -DPICOLIBC_INTEGER_PRINTF_SCANF
|
|
|
|
LINKFLAGS += -DPICOLIBC_INTEGER_PRINTF_SCANF
|
2020-07-31 01:26:34 +02:00
|
|
|
endif
|
2022-11-11 23:37:09 +01:00
|
|
|
# For some reason segments with RWX permissions will be created with
|
|
|
|
# picolibc. But since (as of now) RIOT only supports disabling the execute of
|
|
|
|
# all RAM via the `mpu_noexec_ram` module, permissions of the segments are
|
|
|
|
# ignored anyway. So for now, we just simply disable the warning.
|
|
|
|
LINKER_SUPPORTS_NOWARNRWX ?= $(shell echo "int main(){} void _exit(int n) {(void)n;while(1);}" | LC_ALL=C $(LINK) -xc - -o /dev/null -lc -Wall -Wextra -pedantic -Wl,--no-warn-rwx-segments 2> /dev/null && echo 1 || echo 0)
|
|
|
|
ifeq (1,$(LINKER_SUPPORTS_NOWARNRWX))
|
|
|
|
LINKFLAGS += -Wl,--no-warn-rwx-segments
|
|
|
|
endif
|
2019-09-25 22:13:08 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
LINKFLAGS += -lc
|