Browse Source

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.
Sönke Holz 1 năm trước cách đây
mục cha
commit
f04a2b81be

+ 6 - 0
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/)
     link_directories(${TOOLCHAIN_ROOT}/lib/clang/${LLVM_MAJOR_VERSION}/lib/${SERENITY_ARCH}-pc-serenity/)
 endif()
 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()