From 5723b4f274ace2b4660b4155e06ceda7e85bff3e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 8 Nov 2022 21:45:59 +0400 Subject: [PATCH] Fix conditions for LTO-related options on Linux Currently LTO seem to be always active even when it's not meant to and LTO seem to be broken in debug build. --- options_linux.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/options_linux.cmake b/options_linux.cmake index f0d9a52..a65e803 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -41,7 +41,7 @@ if (DESKTOP_APP_SPECIAL_TARGET) target_link_options(common_options INTERFACE $<$>:-flto=auto> - $<$>:-fuse-linker-plugin> + $<$>:-fwhole-program> ) endif() @@ -63,6 +63,17 @@ if (NOT DESKTOP_APP_USE_PACKAGED) -nostdlib++ ) endif() + if (CMAKE_INTERPROCEDURAL_OPTIMIZATION) + target_link_options(common_options + INTERFACE + -fwhole-program + ) + elseif (NOT DESKTOP_APP_SPECIAL_TARGET) + target_link_options(common_options + INTERFACE + -fno-use-linker-plugin + ) + endif() target_link_options(common_options INTERFACE -rdynamic @@ -77,8 +88,6 @@ if (NOT DESKTOP_APP_USE_PACKAGED OR DESKTOP_APP_SPECIAL_TARGET) ) target_link_options(common_options INTERFACE - $<$:-fno-use-linker-plugin> - $<$>:-fwhole-program> -Wl,-z,relro -Wl,-z,now # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601