serenity/Meta/CMake/serenity_compile_options.cmake
Sönke Holz f04a2b81be 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.
2023-12-14 09:02:15 -07:00

55 lines
2.2 KiB
CMake

include(${CMAKE_CURRENT_LIST_DIR}/common_compile_options.cmake)
# The following options are sorted by the "base" name (the part excluding the initial Wno/fno or W/f).
add_compile_options(-Wno-address-of-packed-member)
add_compile_options(-Wcast-qual)
add_compile_options(-Wdeprecated-copy)
add_compile_options(-Wduplicated-cond)
add_compile_options(-Wformat=2)
add_compile_options(-Wimplicit-fallthrough)
add_compile_options(-Wlogical-op)
add_compile_options(-Wmisleading-indentation)
add_compile_options(-Wmissing-declarations)
add_compile_options(-Wnon-virtual-dtor)
add_compile_options(-Wsuggest-override)
add_compile_options(-Wundef)
add_compile_options(-Wunused)
add_compile_options(-Wwrite-strings)
add_compile_options(-fno-delete-null-pointer-checks)
add_compile_options(-ffile-prefix-map=${SerenityOS_SOURCE_DIR}=.)
add_compile_options(-fno-omit-frame-pointer)
add_compile_options(-fsigned-char)
add_compile_options(-fsized-deallocation)
add_compile_options(-fstack-clash-protection)
add_compile_options(-fstack-protector-strong)
add_link_options(-fstack-protector-strong)
add_compile_options(-g1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_link_options(LINKER:-Bsymbolic-non-weak-functions)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-maybe-uninitialized)
add_compile_options(-Wcast-align)
add_compile_options(-Wdouble-promotion)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
add_compile_options(-Wno-atomic-alignment)
add_compile_options(-Wno-unused-const-variable)
add_compile_options(-Wno-unused-private-field)
# Clang doesn't add compiler_rt to the search path when compiling with -nostdlib.
string(REGEX REPLACE "\\.(.*)" "" LLVM_MAJOR_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
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()