2021-01-02 16:36:20 +01:00
|
|
|
# include module specific includes
|
|
|
|
INCLUDES += -I$(RIOTCPU)/avr8_common/include \
|
|
|
|
-isystem$(RIOTCPU)/avr8_common/avr_libc_extra/include \
|
|
|
|
-isystem$(RIOTCPU)/avr8_common/avr_libc_extra/include/vendor
|
|
|
|
|
2021-09-28 12:35:43 +02:00
|
|
|
ifneq (,$(filter printf_float,$(USEMODULE)))
|
|
|
|
LINKFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
|
|
|
|
endif
|
|
|
|
|
cpu/avr8_common/flash_utils: use C and linker for aliases
`flash_<funcname>()` is implemented by `<funcname>_P()` provided by
the AVR libc on AVR targets. Previously, the preprocessor was used
to do the aliasing, but this causes issues with LLVM: The signatures of
e.g. `printf_P()` expects `const char *`, whereas flash utils expects
`FLASH_ATTR const char *`. For GCC this will just implicitly drop the
`FLASH_ATTR`, while it requires an explicit cast for LLVM.
To implement the explicit cast, `static inline` function wrappers
where used instead where possible. But for the variadic functions
(e.g. `printf(fmt, ...)`) the linker is used to provide the aliases,
as there is no way to pass the variadic functions throw in C. The
alternative would be to implement `flash_printf()` by calling
`vprintf_P()`, but that increased ROM size quite a bit.
Finally, a work around for a bug in Ubuntu's toolchain has been added:
An unused function that calls to `printf_P()`, `fprintf_P()` and
`snprintf_P()`. Since this function is garbage collected anyway, it
has no impact on the generated ELF file.
2023-11-10 11:13:22 +01:00
|
|
|
# Add aliases for flash_printf, flash_fprintf, flash_snprintf:
|
|
|
|
LINKFLAGS += -Wl,--defsym=flash_printf=printf_P
|
|
|
|
LINKFLAGS += -Wl,--defsym=flash_fprintf=fprintf_P
|
|
|
|
LINKFLAGS += -Wl,--defsym=flash_snprintf=snprintf_P
|
2021-03-07 21:35:19 +01:00
|
|
|
include $(RIOTMAKE)/arch/avr8.inc.mk
|