From 11896868d676e752eff0e175c287c4662784a787 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Fri, 11 Aug 2023 12:31:20 +0200 Subject: [PATCH] CMake: Clean up AArch64 compiler flags Two non-functional changes: - Remove pointless `-latomic` flag. It was specified via `add_compile_options`, which only affects compilation and not linking, so the library was never actually linked into the kernel. In fact, we do not even build `libatomic` for our toolchain. - Do not disable `-Wnonnull`. The warning-causing code was fixed at some point. This commit also removes `-mstrict-align` from the userland. Our target AArch64 hardware natively supports unaligned accesses without a significant performance penalty. Allowing the compiler to insert unaligned accesses into aligned-as-written code allows for some performance optimizations in fact. We keep this option turned on in the kernel to preserve correctness for MMIO, as that might be sensitive to alignment. --- Kernel/CMakeLists.txt | 5 +---- Meta/CMake/serenity_compile_options.cmake | 6 ------ 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 723bbee089..d62768a568 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -490,10 +490,7 @@ elseif("${SERENITY_ARCH}" STREQUAL "aarch64") ) # Otherwise linker errors e.g undefined reference to `__aarch64_cas8_acq_rel' - add_compile_options(-mno-outline-atomics -latomic) - - # FIXME: Remove this once compiling MemoryManager.cpp doesn't give the nonnull error anymore. - add_compile_options(-Wno-nonnull) + add_compile_options(-mno-outline-atomics) # NOTE: These files cannot use a stack protector and sanitizers, as these will cause accesses to global variables to be inserted # by the compiler. The CPU cannot access global variables without the MMU as the kernel is linked for a virtual address in high memory. diff --git a/Meta/CMake/serenity_compile_options.cmake b/Meta/CMake/serenity_compile_options.cmake index 1c94e0c999..dbe88f7384 100644 --- a/Meta/CMake/serenity_compile_options.cmake +++ b/Meta/CMake/serenity_compile_options.cmake @@ -39,9 +39,3 @@ 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 "aarch64") - # 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()