From a473cfd71b3106343f6f367f5040fcf8c3551ca9 Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Tue, 20 Dec 2022 19:49:35 +0100 Subject: [PATCH] Kernel/aarch64: Add -mstrict-align flag to Kernel build The ARM CPU is set up to trap on unaligned accesses, however the compiler will still generate them if this flag is not set. We also need the -Wno-cast-align as there are some files in AK that don't build without the flag. --- Kernel/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 2f5400b3da..5b2f447e65 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -671,6 +671,10 @@ endif() if ("${SERENITY_ARCH}" STREQUAL "aarch64") add_compile_options(-fno-threadsafe-statics) + + # Unaligned memory access will cause a trap, so to make sure the compiler doesn't generate + # those unaligned accesses, this flag is added. + add_compile_options(-mstrict-align -Wno-cast-align) endif() add_compile_definitions(KERNEL)