From df29466cbb196562532639b33e3585b7d82cd5f0 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Wed, 17 Sep 2025 22:28:03 -0300 Subject: [PATCH] [lto] fix building with Clang under Ubutnu * based off: https://stackoverflow.com/questions/73011966/unable-to-compile-c-program-with-clang-14 Signed-off-by: Caio Oliveira --- CMakeLists.txt | 8 ++++++++ src/core/CMakeLists.txt | 4 ---- src/video_core/CMakeLists.txt | 4 ---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 411de4620b..6c9530459a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,14 @@ CMAKE_DEPENDENT_OPTION(YUZU_CMD "Compile the eden-cli executable" ON "ENABLE_SDL CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile crash dump (Minidump) support" OFF "WIN32 OR LINUX" OFF) option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF) +if(YUZU_ENABLE_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT COMPILER_SUPPORTS_LTO) + if(NOT COMPILER_SUPPORTS_LTO) + message(FATAL_ERROR "LTO is not supported, disable YUZU_ENABLE_LTO!") + endif() + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +endif() option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" ON) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6b64ab7820..3aad2c4b29 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1274,8 +1274,4 @@ if (YUZU_USE_PRECOMPILED_HEADERS) target_precompile_headers(core PRIVATE precompiled_headers.h) endif() -if (YUZU_ENABLE_LTO) - set_property(TARGET core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) -endif() - create_target_directory_groups(core) diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 642494016e..27c8ed9c1d 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -399,10 +399,6 @@ if (YUZU_USE_PRECOMPILED_HEADERS) target_precompile_headers(video_core PRIVATE precompiled_headers.h) endif() -if (YUZU_ENABLE_LTO) - set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) -endif() - if (ANDROID AND ARCHITECTURE_arm64) target_link_libraries(video_core PRIVATE adrenotools) endif()