From 1e4319d7b9208d2ccb105c8a3853ecf97f600e4c Mon Sep 17 00:00:00 2001 From: Osmium Sorcerer Date: Wed, 23 Sep 2026 16:16:28 +0000 Subject: Adjust release compilation and linking flags Remove -pipe because this option is dubious and doesn't do anything. Get rid of unwind tables. They instrument call sites (synchronous) and any instruction boundary (asynchronous). In the release build, they only inflate the size of the executable. Synchronous tables are necessary for C++ exceptions, but, thankfully (and I can't praise the developers enough) AO2 Client doesn't use them at all. Add RELRO and NOW to the linker. While I've already removed PLT at code generation phase with -fno-plt, turns out, ld still stupidly performs lazy linking: the symbols are moved to GOT, but not immediately resolved. That was an oversight of mine, so bring back full RELRO. Add packing of relative relocations. These are moved to a separate compact section, where they're encoded more efficiently. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dba482..b3786d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,8 +140,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") - target_compile_options(Attorney_Online PRIVATE -O3 -pipe -fno-plt -fno-semantic-interposition -fvisibility=hidden -flto -fno-rtti -fno-exceptions -Werror=odr -Werror=strict-aliasing) - target_link_options(Attorney_Online PRIVATE -Wl,-O2 -Wl,--as-needed -flto -fuse-ld=lld) + target_compile_options(Attorney_Online PRIVATE -O3 -fno-plt -fno-semantic-interposition -fvisibility=hidden -flto -fno-rtti -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Werror=odr -Werror=strict-aliasing) + target_link_options(Attorney_Online PRIVATE -Wl,-O2 -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto -fuse-ld=lld) endif() target_compile_definitions(Attorney_Online PRIVATE AO_BUILD_PROFILE="${CMAKE_BUILD_TYPE}") -- cgit