RTEMS Source Builder | RISC-V/GCC 15: Newlib is built allowing unaligned accesses (#144)

Matteo Concas (@matteo.concas) gitlab at rtems.org
Fri Nov 7 17:28:42 UTC 2025



Matteo Concas created an issue: https://gitlab.rtems.org/rtems/tools/rtems-source-builder/-/issues/144



## Summary
Building the 7/rtems-riscv buildset will package a Newlib implementation that can (and will) do unaligned accesses.

This is problematic as some (but not all) RISC-V CPU do not allow unaligned accesses (for example NOEL-V). This can lead to misaligned load exceptions when calling C standard functions like `memcmp()` and `strcmp()`.


## Possible fix

A quick fix is to add `%define _targetcflags -mstrict-align` to `rtems/config/7/rtems-riscv.bset`.

A side effect from this is that all RISC-V BSPs will then have the standard library built with unaligned accesses disabled. This could lead to performance penalties in some CPUs from what I understand.

Personally, I believe having this option on by default is the safest choice. Users are then free to override this option using the command line option.

Maybe a RISC-V specific option could be added, something like `--riscv-misalign=[slow,fast,no]` to make it more obvious it should be something to consider when building a RISC-V toolchain.

<!-- Pre-set options
- milestone
-->

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/tools/rtems-source-builder/-/issues/144
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20251107/89b9c22d/attachment.htm>


More information about the bugs mailing list