From f04a2b81be9367750352999845d731486541d78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Tue, 12 Dec 2023 17:13:30 +0100 Subject: [PATCH] Meta: Disable `-Wcast-align` warning on RISC-V Also explicitly specify `-mstrict-align` (The current default `-mcpu` on gcc doesn't support unaligned accesses, so aligned memory accesses are already implicitly required). The `-Wcast-align` warning seems to oversensitive as it flags code like this: https://godbolt.org/z/c8481o8aa This used to be added for aarch64 in a473cfd71b, but was later removed in 11896868d6. --- Meta/CMake/serenity_compile_options.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Meta/CMake/serenity_compile_options.cmake b/Meta/CMake/serenity_compile_options.cmake index e43597012f..ba9816e659 100644 --- a/Meta/CMake/serenity_compile_options.cmake +++ b/Meta/CMake/serenity_compile_options.cmake @@ -46,3 +46,9 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$") link_directories(${TOOLCHAIN_ROOT}/lib/clang/${LLVM_MAJOR_VERSION}/lib/${SERENITY_ARCH}-pc-serenity/) endif() +if ("${SERENITY_ARCH}" STREQUAL "riscv64") + # Unaligned memory access will cause a trap, so to make sure the compiler doesn't generate + # those unaligned accesses, the strict-align flag is added. + # FIXME: Remove -Wno-cast-align when we are able to build everything without this warning turned on. + add_compile_options(-mstrict-align -Wno-cast-align) +endif()