From c19a9aac90397cb2fa584f47611ecb9227fb6023 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 6 Jun 2025 15:25:22 -0700 Subject: [PATCH 1/2] gcc: Use -mstrict-align by default on riscv Make sure we don't emit unaligned accesses Signed-off-by: Keith Packard --- gcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc b/gcc index 60e8f09a..0de74f65 160000 --- a/gcc +++ b/gcc @@ -1 +1 @@ -Subproject commit 60e8f09ae1bf83ad35453f28ed70f17b5aeb54cc +Subproject commit 0de74f653c1aea637472ba8a651b6a272e8806f0 From 81c64233200bef984a364a2f5828bae17e25dc74 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 6 Jun 2025 15:26:44 -0700 Subject: [PATCH 2/2] riscv: Use -O2 by default for riscv gcc 14.3 has bus compiling with -Os on riscv, use -O2 by default. Is there some way to prevent applications from selecting -Os? Signed-off-by: Keith Packard --- cmake/zephyr/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/zephyr/Kconfig b/cmake/zephyr/Kconfig index 86a70119..9c0400ec 100644 --- a/cmake/zephyr/Kconfig +++ b/cmake/zephyr/Kconfig @@ -23,6 +23,9 @@ config PICOLIBC_DEFAULT help Zephyr SDK >=0.17.1 always uses Picolibc +# libstdc++ is built without exception support in -Os mode +# gcc 14.3 has bugs compiling with -Os on riscv choice COMPILER_OPTIMIZATIONS default SPEED_OPTIMIZATIONS if ("$(TOOLCHAIN_VARIANT_COMPILER)" = "gnu") && CPP_EXCEPTIONS + default SPEED_OPTIMIZATIONS if ("$(TOOLCHAIN_VARIANT_COMPILER)" = "gnu") && RISCV endchoice