1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00
RIOT/pkg/mpaland-printf/Makefile.include
Marian Buschsieweke 3415656a4a
sys/newlib_syscalls_default: wrap newlib's assert implementation
This avoids inconsistent output when external code gets linked in that
directly links against newlib's assert implementation (e.g. binary blobs
or packages that do not add `core/lib/include` to the include paths).

This also greatly benefits wrapping printf, as newlib's `__assert_func()`
directly links to internal printf functions of newlib.

Co-authored-by: crasbe <crasbe@gmail.com>
2025-08-21 12:08:10 +02:00

34 lines
1.3 KiB
Makefile

# wrap stdio functions to use mpaland's printf instead of the one from the
# standard C lib
LINKFLAGS += -Wl,-wrap=printf
LINKFLAGS += -Wl,-wrap=fprintf
LINKFLAGS += -Wl,-wrap=dprintf
LINKFLAGS += -Wl,-wrap=sprintf
LINKFLAGS += -Wl,-wrap=snprintf
LINKFLAGS += -Wl,-wrap=vprintf
LINKFLAGS += -Wl,-wrap=vfprintf
LINKFLAGS += -Wl,-wrap=vdprintf
LINKFLAGS += -Wl,-wrap=vsprintf
LINKFLAGS += -Wl,-wrap=vsnprintf
LINKFLAGS += -Wl,-wrap=putchar
LINKFLAGS += -Wl,-wrap=puts
# By wrapping the newlib only `_printf_common` symbol to the undefined
# `__wrap__printf_common` symbol, linking will fail if any reference to
# `_printf_common` remains. Since `_printf_common` is only used by newlib's
# stdio, we will catch any instance of both mpaland-printf and newlib's stdio
# being both linked in.
LINKFLAGS += -Wl,-wrap=_printf_common
LINKFLAGS += -Wl,-wrap=_fprintf_r
LINKFLAGS += -Wl,-wrap=_printf_r
LINKFLAGS += -Wl,-wrap=iprintf
LINKFLAGS += -Wl,-wrap=fiprintf
# Workaround for bug in the newlib headers shipped with e.g. Ubuntu 24.04 LTS
# not defining PRId64 / PRIu64 / PRIx64 / PRIo64 in <inttypes.h> due to an issue
# in <machine/_default_types.h>. Tested to cause no regression on fixed newlib
# headers.
ifneq (,$(filter newlib,$(FEATURES_USED)))
CFLAGS += -D__int64_t_defined=1
endif