Skip to content

Conversation

maribu
Copy link
Member

@maribu maribu commented Apr 25, 2025

Contribution description

build system: introduce bug_% feature category

This introduces a new feature category to declare which bugs are present
in a given build that we cannot fix in RIOT, but need to work around.
These bugs may be silicon bugs, software bugs in ROM, software bugs in
binary blobs needed for a platform, or bugs in the toolchain.

These features behave the same way as arch_% features: Every provided
bug is always used, so that we can inspect FEATURES_USED to check
which bugs need to be worked around.

build system: use thread-safe stdio

This makes use of the new bug modeling to declare all platforms that
can use newlib and have no reentrancy hooks as affected by the
non-thread-safe stdio bug. (Which is every platform but ESP* and AVR,
the former because the reentrancy hooks are provided, the latter because
we do not and never will support newlib on them.)

Building on that, the mpaland-printf package is used when newlib is used
and the bug is present. This way we can rely on the stdio being
thread-safe on every platform and not causing random crashes at
run time.

sys/newlib: drop workaround for stdio

This drops a workaround that initialized newlib's reentrancy structure
on boot to reduce the chances of crashes when using the non-thread-safe
(unless reentrancy hooks are provided) stdio implementation of newlib.

Now that the newlib stdio implementation is only ever used if it is
thread-safe, we no longer need a workaround that reduces the chance
of crashes on concurrent use of stdio.

Testing procedure

Now the package mpaland-printf should be pulled in for all non-ESP boards when newlib is used. E.g.

for board in hifive1b same54-xpro native32 native64 arduino-mega2560 esp32-mh-et-live-minikit esp8266-esp-12x z1 nucleo-l011k4; do
    printf '\n%s\n===================\n' $board
    echo "Features:"
    make BOARD=$board --no-print-directory -C examples/basic/hello-world info-features-used | grep -E 'newlib|libc'
    echo "Packages:"
    make BOARD=$board --no-print-directory -C examples/basic/hello-world info-packages
done
hifive1b
===================
Features:
bug_newlib_broken_stdio
newlib
Packages:
mpaland-printf

same54-xpro
===================
Features:
bug_newlib_broken_stdio
newlib
Packages:
cmsis
mpaland-printf

native32
===================
Features:
Packages:

native64
===================
Features:
Packages:

arduino-mega2560
===================
Features:
Packages:

esp32-mh-et-live-minikit
===================
Features:
newlib
Packages:
esp32_sdk

esp8266-esp-12x
===================
Features:
newlib
Packages:
esp8266_sdk

z1
===================
Features:
bug_newlib_broken_stdio
Packages:
mpaland-printf

nucleo-l011k4
===================
Features:
bug_newlib_broken_stdio
picolibc
Packages:
cmsis

With this, the test in tests/sys/snprintf now should also pass for each and every board, except for ESP32 boards. The reason is that, since ESP* provides the reentrancy hooks, newlib's stdio is thread-safe on those. So we do not pull in the alternative printf. For ESP8266 boards newlib is configured to use the non-nano stdio, which passes the test. For ESP32 newlib-nano is used, which does not implement all format specifiers and, therefore, fails the test.

Issues/PRs references

Depends on and includes:

@github-actions github-actions bot added Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: build system Area: Build system Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Area: cpu Area: CPU/MCU ports Area: sys Area: System labels Apr 25, 2025
@crasbe crasbe added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Apr 25, 2025
@riot-ci
Copy link

riot-ci commented Apr 25, 2025

Murdock results

✔️ PASSED

4a84f6f tests/sys/snprintf: use printf_long_long

Success Failures Total Runtime
10536 0 10536 20m:02s

Artifacts

@maribu maribu force-pushed the sys/newlib/fix-stdio branch from 9a524a2 to f058796 Compare April 25, 2025 11:09
@github-actions github-actions bot added the Area: pkg Area: External package ports label Apr 25, 2025
@crasbe crasbe added CI: full build disable CI build filter CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 25, 2025
@crasbe
Copy link
Contributor

crasbe commented Apr 25, 2025

We should probably give this a full build without fast fail, otherwise you'll be chasing your tail for days 😅

@maribu maribu added State: waiting for other PR State: The PR requires another PR to be merged first and removed CI: full build disable CI build filter CI: no fast fail don't abort PR build after first error labels Apr 25, 2025
@maribu
Copy link
Member Author

maribu commented Apr 25, 2025

We should probably give this a full build without fast fail, otherwise you'll be chasing your tail for days 😅

No, actually the memory requirements will go down with this. Unless... both printf variants get linked in into the same app.

See #21439 for a fix of that.

@maribu maribu force-pushed the sys/newlib/fix-stdio branch from f058796 to 31f945b Compare April 25, 2025 11:24
@Enoch247
Copy link
Contributor

in one of your commit messages and in the description of this PR you have every misspelled.

This way we can rely on the stdio being thread-safe on evyer platform and not causing random crashes at run time.

@maribu maribu force-pushed the sys/newlib/fix-stdio branch 2 times, most recently from 473d6ca to 933acf3 Compare April 27, 2025 07:03
@github-actions github-actions bot removed the Area: pkg Area: External package ports label Apr 27, 2025
@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms labels Aug 20, 2025
Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

Unfortunately, something seems to fail on the first board I've tested this with:

$ make -C tests/sys/snprintf BOARD=adafruit-feather-nrf52840-sense clean flash term    
make: Entering directory '/home/mikolai/TUD/Code/RIOT/tests/sys/snprintf'
rm -rf /home/mikolai/TUD/Code/RIOT/tests/sys/snprintf/bin/adafruit-feather-nrf52840-sense/pkg-build/cmsis
rm -rf /home/mikolai/TUD/Code/RIOT/tests/sys/snprintf/bin/adafruit-feather-nrf52840-sense/pkg-build/mpaland-printf
Building application "tests_snprintf" for "adafruit-feather-nrf52840-sense" with CPU "nrf52".

"make" -C /home/mikolai/TUD/Code/RIOT/pkg/cmsis/ 
"make" -C /home/mikolai/TUD/Code/RIOT/pkg/mpaland-printf/ 
"make" -C /home/mikolai/.riot/pkg/mpaland-printf -f /home/mikolai/TUD/Code/RIOT/pkg/mpaland-printf/mpaland-printf.mk
"make" -C /home/mikolai/TUD/Code/RIOT/boards
"make" -C /home/mikolai/TUD/Code/RIOT/boards/common/adafruit-nrf52-bootloader
"make" -C /home/mikolai/TUD/Code/RIOT/boards/common/init
"make" -C /home/mikolai/TUD/Code/RIOT/boards/adafruit-feather-nrf52840-sense
"make" -C /home/mikolai/TUD/Code/RIOT/core
"make" -C /home/mikolai/TUD/Code/RIOT/core/lib
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf52
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/cortexm_common
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/cortexm_common/periph
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf52/periph
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf52/vectors
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf5x_common
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf5x_common/periph
"make" -C /home/mikolai/TUD/Code/RIOT/drivers
"make" -C /home/mikolai/TUD/Code/RIOT/drivers/periph_common
"make" -C /home/mikolai/TUD/Code/RIOT/sys
"make" -C /home/mikolai/TUD/Code/RIOT/sys/auto_init
"make" -C /home/mikolai/TUD/Code/RIOT/sys/auto_init/usb
"make" -C /home/mikolai/TUD/Code/RIOT/sys/div
"make" -C /home/mikolai/TUD/Code/RIOT/sys/event
"make" -C /home/mikolai/TUD/Code/RIOT/sys/fmt
"make" -C /home/mikolai/TUD/Code/RIOT/sys/isrpipe
"make" -C /home/mikolai/TUD/Code/RIOT/sys/libc
"make" -C /home/mikolai/TUD/Code/RIOT/sys/luid
"make" -C /home/mikolai/TUD/Code/RIOT/sys/malloc_thread_safe
"make" -C /home/mikolai/TUD/Code/RIOT/sys/newlib_syscalls_default
"make" -C /home/mikolai/TUD/Code/RIOT/sys/preprocessor
"make" -C /home/mikolai/TUD/Code/RIOT/sys/stdio
"make" -C /home/mikolai/TUD/Code/RIOT/sys/stdio_uart
"make" -C /home/mikolai/TUD/Code/RIOT/sys/test_utils/interactive_sync
"make" -C /home/mikolai/TUD/Code/RIOT/sys/test_utils/print_stack_usage
"make" -C /home/mikolai/TUD/Code/RIOT/sys/tsrb
"make" -C /home/mikolai/TUD/Code/RIOT/sys/usb/usbus
"make" -C /home/mikolai/TUD/Code/RIOT/sys/usb/usbus/cdc/acm
"make" -C /home/mikolai/TUD/Code/RIOT/sys/usb_board_reset
   text    data     bss     dec     hex filename
  21252     128    4524   25904    6530 /home/mikolai/TUD/Code/RIOT/tests/sys/snprintf/bin/adafruit-feather-nrf52840-sense/tests_snprintf.elf
stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
sleep 10
[INFO] uf2conv.py not found - fetching it from GitHub now
CC= CFLAGS= make -C /home/mikolai/TUD/Code/RIOT/dist/tools/uf2
[INFO] uf2conv.py successfully fetched!
SoftDevice version S140 6.1.1 found.
/home/mikolai/TUD/Code/RIOT/dist/tools/uf2/uf2conv.py -f 0xADA52840 /home/mikolai/TUD/Code/RIOT/tests/sys/snprintf/bin/adafruit-feather-nrf52840-sense/tests_snprintf.hex --base 0x26000
Converted to uf2, output size: 43008, start address: 0x26000
Flashing /media/mikolai/FTHRSNSBOOT (nRF52840-Feather-Sense)
Wrote 43008 bytes to /media/mikolai/FTHRSNSBOOT/NEW.UF2
sleep 2
/home/mikolai/TUD/Code/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200" -ln "/tmp/pyterm-mikolai" -rn "2025-08-21_10.12.25-tests_snprintf-adafruit-feather-nrf52840-sense"  
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2025-08-21 10:12:25,059 # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
2025-08-21 10:12:26,061 # Help: Press s to start test, r to print it is ready
r
2025-08-21 10:12:27,896 # READY
s
2025-08-21 10:12:28,776 # START
2025-08-21 10:12:28,782 # main(): This is RIOT! (Version: 2025.10-devel-176-g18dac1-HEAD)
2025-08-21 10:12:28,785 # Testing snprintf() implementation...
2025-08-21 10:12:28,789 # Expected: "16045690984050070327"
2025-08-21 10:12:28,790 # Got:      ""
2025-08-21 10:12:28,793 # Expected: "deadbeefaffe1337"
2025-08-21 10:12:28,795 # Got:      ""
2025-08-21 10:12:28,798 # Expected: "0xdeadbeefaffe1337"
2025-08-21 10:12:28,800 # Got:      ""
2025-08-21 10:12:28,803 # Expected: "DEADBEEFAFFE1337"
2025-08-21 10:12:28,804 # Got:      ""
2025-08-21 10:12:28,808 # Expected: "0XDEADBEEFAFFE1337"
2025-08-21 10:12:28,809 # Got:      ""
2025-08-21 10:12:28,813 # Expected: "1572555756765777411467"
2025-08-21 10:12:28,814 # Got:      ""
2025-08-21 10:12:28,818 # Expected: "01572555756765777411467"
2025-08-21 10:12:28,820 # Got:      ""
2025-08-21 10:12:28,824 # Expected: "-9223372036854775807"
2025-08-21 10:12:28,825 # Got:      ""
2025-08-21 10:12:28,829 # Expected: "-9223372036854775807"
2025-08-21 10:12:28,830 # Got:      ""
2025-08-21 10:12:28,832 # TEST FAILED!
2025-08-21 10:12:28,839 # { "threads": [{ "name": "main", "stack_size": 1536, "stack_used": 440}]}

The test succeeds on current master. I'll try to debug later today.

I've also noted that https://github.com/RIOT-OS/RIOT/blob/18dac11c668e13bf428ac694083efc8ff177c866/tests/sys/snprintf/Makefile.board.dep already pulls in mpaland_printf iff newlib is selected. Should that be dropped within this PR?

Comment on lines +933 to +934
help: newlib's stdio is not inherently thread-safe, but depends on the
reentrancy hooks to be provided for correct operation. When
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is the reason we cannot provide such reentrancy hooks for newlib in RIOT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually could provide reentrancy hooks (just nobody did so yet). There even is a stale PR somewhere for it.

But that will be a hard sell unless it is opt-in due to the large RAM requirements (per thread!) it has. (The stale PR adds an opt-in module for reentrant newlib, if I recall correctly.)

The main reason people enable reentrancy in newlib is to have malloc() / free() and friends thread-safe, which we already have with a much leaner implementation. The second reason is to have stdio thread-safe.

Reentrancy would also give you thread safety for a number of other standard C lib functions that operate on shared resources, but those are rarely ever used in the context of RIOT. (E.g. our VFS system fully bypasses the standard C lib anyway.) Once we have thread-safe stdio, there will be few use cases that would actually benefit from reentrancy, and some might rather rework the code than to pay the per-thread RAM overhead of newlib's reentrancy mechanism.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the explanation! Would be great to have this noted down somewhere in the documentation for future reference, but I can't even find pages on neither newlib nor picolibc o.O

Would you be up for writing out some bits in a follow-up PR?

@mguetschow
Copy link
Contributor

mguetschow commented Aug 21, 2025

Ah sorry for the noise, that's probably the removed printf_long_long support.

Should we rather add printf_long_long to the test application or feature-gate test_int64?

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Aug 21, 2025
@maribu
Copy link
Member Author

maribu commented Aug 21, 2025

Ah sorry for the noise, that's probably the removed printf_long_long support.

No, its IMO not noise. A test failing with default configuration is IMO a genuine bug :)

Should we rather add printf_long_long to the test application or feature-gate test_int64?

I did both. There might be users with tiny boards that can benefit from easily being able to disable printf_long_long in the test, but having the larger test coverage by default is probably better.

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I can confirm the test is passing now for both configurations on the hardware I tested with (nrf52840dk).

@mguetschow
Copy link
Contributor

Please squash :)

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, two nits more

maribu and others added 7 commits August 21, 2025 12:06
- `arch_64bit` depends on long long support (rather than just enabling
  it by default), as otherwise `%p` will not work correctly
  ==> add hard dependency
- On 32 bit platforms support of printing long long is not almost free
  ==> do not enable long long on `arch_32bit` by default
- The ESP SDK contains binary blobs that already link against newlib and
  mpaland-printf is not ABI compatible with newlib's stdio, it is only
  API compatible.
  ==> mark mpaland-printf as incompatible to ESP MCUs

Co-authored-by: crasbe <[email protected]>
This introduces a new feature category to declare which bugs are present
in a given build that we cannot fix in RIOT, but need to work around.
These bugs may be silicon bugs, software bugs in ROM, software bugs in
binary blobs needed for a platform, or bugs in the toolchain.

These features behave the same way as `arch_%` features: Every provided
bug is always used, so that we can inspect `FEATURES_USED` to check
which bugs need to be worked around.

Co-authored-by: crasbe <[email protected]>
This makes use of the new bug modeling to declare all platforms that
can use newlib and have no reentrancy hooks as affected by the
non-thread-safe stdio bug. (Which is every platform but ESP* and AVR,
the former because the reentrancy hooks are provided, the latter because
we do not and never will support newlib on them.)

Building on that, the mpaland-printf package is used when newlib is
used and the bug is present. This way we can rely on the stdio being
thread-safe on every platform and not causing random crashes at run
time.

Co-authored-by: mguetschow <[email protected]>
This drops a workaround that initialized newlib's reentrancy structure
on boot to reduce the chances of crashes when using the non-thread-safe
(unless reentrancy hooks are provided) stdio implementation of newlib.

Now that the newlib stdio implementation is only ever used if it is
thread-safe, we no longer need a workaround that reduces the chance
of crashes on concurrent use of stdio.
That way users can rely on elimation of dead code from the optimizer
instead of having to use preprocessor conditionals when feature-gating
assert implementations behind `!NDEBUG`.

Co-authored-by: benpicco <[email protected]>
Co-authored-by: crasbe <[email protected]>
Co-authored-by: mguetschow <[email protected]>
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 <[email protected]>
This is required to support printing 64 bit numbers, as is done in the
test.

In addition that 64 bit formatting test is feature gated, so that users
can simply comment out the `USEMODULE += printf_long_long` to fit tiny
boards.

Co-authored-by: mguetschow <[email protected]>
@maribu maribu force-pushed the sys/newlib/fix-stdio branch from ecdd4ea to 4a84f6f Compare August 21, 2025 10:08
@maribu maribu added this pull request to the merge queue Aug 21, 2025
Merged via the queue into RIOT-OS:master with commit e26321e Aug 21, 2025
25 checks passed
@maribu
Copy link
Member Author

maribu commented Aug 21, 2025

Yay 🎉

Thanks everyone for bearing with me on this one ❤️

@maribu maribu deleted the sys/newlib/fix-stdio branch August 21, 2025 16:01
@mguetschow
Copy link
Contributor

This resulted in some failing nightly tests, as mpaland-printf prints %p without leading 0x. See the unmerged PR over at mpaland/printf#90.

As the printing format is indeed implementation-defined, the respective tests should probably be adapted to accept output both with and without 0x.

@mguetschow
Copy link
Contributor

Another problem, at least on my machine:

$ make -C tests/sys/heap_cmd BOARD=nrf52840dk all
make: Entering directory '/home/mikolai/TUD/Code/RIOT/tests/sys/heap_cmd'
Building application "tests_heap_cmd" for "nrf52840dk" with CPU "nrf52".

"make" -C /home/mikolai/TUD/Code/RIOT/pkg/cmsis/ 
"make" -C /home/mikolai/TUD/Code/RIOT/pkg/mpaland-printf/ 
"make" -C /home/mikolai/.riot/pkg/mpaland-printf -f /home/mikolai/TUD/Code/RIOT/pkg/mpaland-printf/mpaland-printf.mk
"make" -C /home/mikolai/TUD/Code/RIOT/boards
"make" -C /home/mikolai/TUD/Code/RIOT/boards/common/init
"make" -C /home/mikolai/TUD/Code/RIOT/boards/nrf52840dk
"make" -C /home/mikolai/TUD/Code/RIOT/boards/common/nrf52xxxdk
"make" -C /home/mikolai/TUD/Code/RIOT/core
"make" -C /home/mikolai/TUD/Code/RIOT/core/lib
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf52
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/cortexm_common
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/cortexm_common/periph
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf52/periph
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf52/vectors
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf5x_common
"make" -C /home/mikolai/TUD/Code/RIOT/cpu/nrf5x_common/periph
"make" -C /home/mikolai/TUD/Code/RIOT/drivers
"make" -C /home/mikolai/TUD/Code/RIOT/drivers/periph_common
"make" -C /home/mikolai/TUD/Code/RIOT/sys
"make" -C /home/mikolai/TUD/Code/RIOT/sys/auto_init
"make" -C /home/mikolai/TUD/Code/RIOT/sys/div
"make" -C /home/mikolai/TUD/Code/RIOT/sys/isrpipe
"make" -C /home/mikolai/TUD/Code/RIOT/sys/libc
"make" -C /home/mikolai/TUD/Code/RIOT/sys/malloc_thread_safe
"make" -C /home/mikolai/TUD/Code/RIOT/sys/newlib_syscalls_default
"make" -C /home/mikolai/TUD/Code/RIOT/sys/preprocessor
"make" -C /home/mikolai/TUD/Code/RIOT/sys/ps
"make" -C /home/mikolai/TUD/Code/RIOT/sys/shell
"make" -C /home/mikolai/TUD/Code/RIOT/sys/shell/cmds
"make" -C /home/mikolai/TUD/Code/RIOT/sys/stdio
"make" -C /home/mikolai/TUD/Code/RIOT/sys/stdio_uart
"make" -C /home/mikolai/TUD/Code/RIOT/sys/test_utils/interactive_sync
"make" -C /home/mikolai/TUD/Code/RIOT/sys/test_utils/print_stack_usage
"make" -C /home/mikolai/TUD/Code/RIOT/sys/tsrb
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc_nano.a(lib_a-mstats.o): in function `_mstats_r':
/home/pere/src/newlib-salsa/build_nano/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/mstats.c:121: undefined reference to `__wrap_fiprintf'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /home/pere/src/newlib-salsa/build_nano/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/mstats.c:121: undefined reference to `__wrap_fiprintf'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc_nano.a(lib_a-nano-mallstatsr.o): in function `_malloc_stats_r':
/home/pere/src/newlib-salsa/build_nano/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/nano-mallocr.c:523: undefined reference to `__wrap_fiprintf'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /home/pere/src/newlib-salsa/build_nano/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/nano-mallocr.c:525: undefined reference to `__wrap_fiprintf'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /home/pere/src/newlib-salsa/build_nano/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/nano-mallocr.c:527: undefined reference to `__wrap_fiprintf'
collect2: error: ld returned 1 exit status
make: *** [/home/mikolai/TUD/Code/RIOT/tests/sys/heap_cmd/../../../Makefile.include:755: /home/mikolai/TUD/Code/RIOT/tests/sys/heap_cmd/bin/nrf52840dk/tests_heap_cmd.elf] Error 1
make: Leaving directory '/home/mikolai/TUD/Code/RIOT/tests/sys/heap_cmd'

# 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

suggests that this is failing on purpose, but I'm not sure what to make out of this. Apparently that also didn't happen on CI for some reason (maybe it was not properly rebuilding all modules for the test?).

@mguetschow
Copy link
Contributor

As the printing format is indeed implementation-defined, the respective tests should probably be adapted to accept output both with and without 0x.

There we go: #21677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: cpu Area: CPU/MCU ports Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: MSP Platform: This PR/issue effects MSP-based platforms Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants