[cmake] whole-program LTO, prefer lld on clang (#2581)
Reviewed-on: #2581
This commit is contained in:
parent
cc50571275
commit
c77ad128b9
4 changed files with 30 additions and 24 deletions
|
@ -147,7 +147,11 @@ if (MSVC OR ANDROID)
|
||||||
set(EXT_DEFAULT ON)
|
set(EXT_DEFAULT ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ${EXT_DEFAULT} "ENABLE_SDL2;NOT MSVC" OFF)
|
if (ENABLE_SDL2)
|
||||||
|
# TODO(crueter): Cleanup, each dep that has a bundled option should allow to choose between bundled, external, system
|
||||||
|
CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" OFF "NOT MSVC" OFF)
|
||||||
|
option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 build" "${MSVC}")
|
||||||
|
endif()
|
||||||
|
|
||||||
cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF)
|
cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF)
|
||||||
|
|
||||||
|
@ -185,8 +189,6 @@ option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ${EXT_DEFAULT})
|
||||||
# TODO(crueter): CI this?
|
# TODO(crueter): CI this?
|
||||||
option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON)
|
option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON)
|
||||||
|
|
||||||
# TODO(crueter): Cleanup, each dep that has a bundled option should allow to choose between bundled, external, system
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 build" "${MSVC}" "ENABLE_SDL2" OFF)
|
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Enable dedicated room functionality" ON "NOT ANDROID" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Enable dedicated room functionality" ON "NOT ANDROID" OFF)
|
||||||
|
|
||||||
|
@ -197,6 +199,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)
|
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)
|
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 "Your compiler does not support interprocedural optimization (IPO). Re-run CMake with -DYUZU_ENABLE_LTO=OFF.")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${COMPILER_SUPPORTS_LTO})
|
||||||
|
endif()
|
||||||
|
|
||||||
option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" ON)
|
option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" ON)
|
||||||
|
|
||||||
|
@ -884,19 +894,25 @@ if (MSVC AND CXX_CLANG)
|
||||||
link_libraries(llvm-mingw-runtime)
|
link_libraries(llvm-mingw-runtime)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_USE_FASTER_LD AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if (YUZU_USE_FASTER_LD)
|
||||||
# We will assume that if the compiler is GCC, it will attempt to use ld.bfd by default.
|
# clang should always use lld
|
||||||
# Try to pick a faster linker.
|
|
||||||
find_program(LLD lld)
|
find_program(LLD lld)
|
||||||
find_program(MOLD mold)
|
|
||||||
|
|
||||||
if (MOLD AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1")
|
if (LLD)
|
||||||
message(NOTICE "Selecting mold as linker")
|
set(LINKER lld)
|
||||||
add_link_options("-fuse-ld=mold")
|
|
||||||
elseif (LLD)
|
|
||||||
message(NOTICE "Selecting lld as linker")
|
|
||||||
add_link_options("-fuse-ld=lld")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# GNU appears to work better with mold
|
||||||
|
# TODO: mold has been slow lately, see if better options exist (search for gold?)
|
||||||
|
if (CXX_GCC)
|
||||||
|
find_program(MOLD mold)
|
||||||
|
if (MOLD AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1")
|
||||||
|
set(LINKER mold)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(NOTICE "Selecting ${LINKER} as linker")
|
||||||
|
add_link_options("-fuse-ld=${LINKER}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set runtime library to MD/MDd for all configurations
|
# Set runtime library to MD/MDd for all configurations
|
||||||
|
|
|
@ -175,12 +175,10 @@ android {
|
||||||
"-DYUZU_USE_CPM=ON",
|
"-DYUZU_USE_CPM=ON",
|
||||||
"-DCPMUTIL_FORCE_BUNDLED=ON",
|
"-DCPMUTIL_FORCE_BUNDLED=ON",
|
||||||
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
|
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
|
||||||
"-DYUZU_ENABLE_LTO=ON",
|
|
||||||
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
|
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
|
||||||
"-DBUILD_TESTING=OFF",
|
"-DBUILD_TESTING=OFF",
|
||||||
"-DYUZU_TESTS=OFF",
|
"-DYUZU_TESTS=OFF",
|
||||||
"-DDYNARMIC_TESTS=OFF",
|
"-DDYNARMIC_TESTS=OFF"
|
||||||
"-DDYNARMIC_ENABLE_LTO=ON"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
abiFilters("arm64-v8a")
|
abiFilters("arm64-v8a")
|
||||||
|
|
|
@ -1274,8 +1274,4 @@ if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||||
target_precompile_headers(core PRIVATE precompiled_headers.h)
|
target_precompile_headers(core PRIVATE precompiled_headers.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_ENABLE_LTO)
|
|
||||||
set_property(TARGET core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
create_target_directory_groups(core)
|
create_target_directory_groups(core)
|
||||||
|
|
|
@ -399,10 +399,6 @@ if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||||
target_precompile_headers(video_core PRIVATE precompiled_headers.h)
|
target_precompile_headers(video_core PRIVATE precompiled_headers.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_ENABLE_LTO)
|
|
||||||
set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (ANDROID AND ARCHITECTURE_arm64)
|
if (ANDROID AND ARCHITECTURE_arm64)
|
||||||
target_link_libraries(video_core PRIVATE adrenotools)
|
target_link_libraries(video_core PRIVATE adrenotools)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue