1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

CMake: Use CMAKE_POSITION_INDEPENDENT_CODE instead of explicit -fpic

This makes CMake pass `-fpie` instead of `-fpic` to the compiler when
building the Kernel and userland *executables*. This allows the compiler
to make certain optimizations based on the fact that the code will be
used in an executable, such as not having to emit `.localalias` symbols.
This leads to a 450 KiB decrease in the size of the Kernel binary.
This commit is contained in:
Daniel Bertalan 2023-08-27 12:13:47 +02:00
parent 4defa401d3
commit 1f747b9132
3 changed files with 3 additions and 3 deletions

View file

@ -30,7 +30,7 @@ add_definitions(-D_DYNAMIC_LOADER)
set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LIBC_SOURCES2} ${LIBC_SOURCES3} ${LIBSYSTEM_SOURCES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nostdlib -pie -fpic -DNO_TLS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nostdlib -pie -fpie -DNO_TLS")
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
# On aarch64 the stack protector would be accessed before the Loader can relocate itself.