From 01757c21ea8dec8de49f7397c656b00aacde5d6a Mon Sep 17 00:00:00 2001 From: "Boss.sfc" Date: Sat, 23 Aug 2025 18:53:24 +0700 Subject: [PATCH] fix: Linux compilation There were linking errors Signed-off-by: Boss.sfc --- CMakeModules/MSVCCache.cmake | 30 +++++++++++++-------------- dist/icons/controller/controller.qrc | 6 +++--- src/citron/CMakeLists.txt | 25 +++++++++++++++++++++- src/citron_cmd/CMakeLists.txt | 25 +++++++++++++++++++++- src/dedicated_room/CMakeLists.txt | 31 ++++++++++++++++++++++++---- 5 files changed, 93 insertions(+), 24 deletions(-) diff --git a/CMakeModules/MSVCCache.cmake b/CMakeModules/MSVCCache.cmake index ba0d22d9e..a4770862f 100644 --- a/CMakeModules/MSVCCache.cmake +++ b/CMakeModules/MSVCCache.cmake @@ -1,15 +1,15 @@ -# SPDX-FileCopyrightText: 2022 yuzu Emulator Project -# SPDX-License-Identifier: GPL-3.0-or-later - -# buildcache wrapper -OPTION(USE_CCACHE "Use buildcache for compilation" OFF) -IF(USE_CCACHE) - FIND_PROGRAM(CCACHE buildcache) - IF (CCACHE) - MESSAGE(STATUS "Using buildcache found in PATH") - SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) - SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) - ELSE(CCACHE) - MESSAGE(WARNING "USE_CCACHE enabled, but no buildcache executable found") - ENDIF(CCACHE) -ENDIF(USE_CCACHE) +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +# buildcache wrapper +OPTION(USE_CCACHE "Use buildcache for compilation" OFF) +IF(USE_CCACHE) + FIND_PROGRAM(CCACHE buildcache) + IF (CCACHE) + MESSAGE(STATUS "Using buildcache found in PATH") + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) + ELSE(CCACHE) + MESSAGE(WARNING "USE_CCACHE enabled, but no buildcache executable found") + ENDIF(CCACHE) +ENDIF(USE_CCACHE) diff --git a/dist/icons/controller/controller.qrc b/dist/icons/controller/controller.qrc index 8d5261c38..1b8e26c64 100644 --- a/dist/icons/controller/controller.qrc +++ b/dist/icons/controller/controller.qrc @@ -6,10 +6,10 @@ SPDX-License-Identifier: GPL-2.0-or-later applet_dual_joycon.png - applet_dual_joycon_dark.png - applet_dual_joycon_midnight.png + applet_dual_joycon_dark.png + applet_dual_joycon_midnight.png applet_handheld.png - applet_handheld_dark.png + applet_handheld_dark.png applet_handheld_midnight.png applet_pro_controller.png applet_pro_controller_dark.png diff --git a/src/citron/CMakeLists.txt b/src/citron/CMakeLists.txt index a5bc98957..1eaff5b4b 100644 --- a/src/citron/CMakeLists.txt +++ b/src/citron/CMakeLists.txt @@ -388,7 +388,30 @@ elseif(WIN32) endif() endif() -target_link_libraries(citron PRIVATE common core input_common frontend_common network video_core) +# Robust static linking and linker selection under GCC LTO +if (NOT MSVC) + # Use GNU ld.bfd for GCC LTO plugin-aware archive resolution + target_link_options(citron PRIVATE -fuse-ld=bfd) + + # Force-include critical static archives and resolve cycles + if (ENABLE_WEB_SERVICE) + target_compile_definitions(citron PRIVATE -DENABLE_WEB_SERVICE) + target_link_libraries(citron PRIVATE + "-Wl,--start-group" + "-Wl,--whole-archive" common core input_common frontend_common network video_core web_service "-Wl,--no-whole-archive" + "-Wl,--end-group" + ) + else() + target_link_libraries(citron PRIVATE + "-Wl,--start-group" + "-Wl,--whole-archive" common core input_common frontend_common network video_core "-Wl,--no-whole-archive" + "-Wl,--end-group" + ) + endif() +else() + target_link_libraries(citron PRIVATE common core input_common frontend_common network video_core) +endif() + target_link_libraries(citron PRIVATE Boost::headers glad Qt${QT_MAJOR_VERSION}::Widgets) target_link_libraries(citron PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) diff --git a/src/citron_cmd/CMakeLists.txt b/src/citron_cmd/CMakeLists.txt index 5ca550afb..b0b3aa1b1 100644 --- a/src/citron_cmd/CMakeLists.txt +++ b/src/citron_cmd/CMakeLists.txt @@ -28,7 +28,30 @@ add_executable(citron-cmd citron.rc ) -target_link_libraries(citron-cmd PRIVATE common core input_common frontend_common) +# Robust static linking and linker selection under GCC LTO +if (NOT MSVC) + # Use GNU ld.bfd for GCC LTO plugin-aware archive resolution + target_link_options(citron-cmd PRIVATE -fuse-ld=bfd) + + # Force-include critical static archives and resolve cycles + if (ENABLE_WEB_SERVICE) + target_compile_definitions(citron-cmd PRIVATE -DENABLE_WEB_SERVICE) + target_link_libraries(citron-cmd PRIVATE + "-Wl,--start-group" + "-Wl,--whole-archive" common core input_common frontend_common network web_service "-Wl,--no-whole-archive" + "-Wl,--end-group" + ) + else() + target_link_libraries(citron-cmd PRIVATE + "-Wl,--start-group" + "-Wl,--whole-archive" common core input_common frontend_common network "-Wl,--no-whole-archive" + "-Wl,--end-group" + ) + endif() +else() + target_link_libraries(citron-cmd PRIVATE common core input_common frontend_common) +endif() + target_link_libraries(citron-cmd PRIVATE glad) if (MSVC) target_link_libraries(citron-cmd PRIVATE getopt) diff --git a/src/dedicated_room/CMakeLists.txt b/src/dedicated_room/CMakeLists.txt index f42b5a711..67651eec8 100644 --- a/src/dedicated_room/CMakeLists.txt +++ b/src/dedicated_room/CMakeLists.txt @@ -7,10 +7,33 @@ add_executable(citron-room citron_room.rc ) -target_link_libraries(citron-room PRIVATE common network) -if (ENABLE_WEB_SERVICE) - target_compile_definitions(citron-room PRIVATE -DENABLE_WEB_SERVICE) - target_link_libraries(citron-room PRIVATE web_service) +# Robust static linking order using GNU ld group to resolve cycles +if (NOT MSVC) + # Use GNU ld.bfd for GCC LTO archives (ld.lld cannot consume GCC LTO plugin objects) + target_link_options(citron-room PRIVATE -fuse-ld=bfd) + + # Robust static linking under LTO: force-include these archives and allow cyclic resolution + if (ENABLE_WEB_SERVICE) + target_compile_definitions(citron-room PRIVATE -DENABLE_WEB_SERVICE) + target_link_libraries(citron-room PRIVATE + "-Wl,--start-group" + "-Wl,--whole-archive" common network core web_service "-Wl,--no-whole-archive" + "-Wl,--end-group" + ) + else() + target_link_libraries(citron-room PRIVATE + "-Wl,--start-group" + "-Wl,--whole-archive" common network core "-Wl,--no-whole-archive" + "-Wl,--end-group" + ) + endif() +else() + # Fallback for MSVC (no --start-group/--end-group) + target_link_libraries(citron-room PRIVATE common network core) + if (ENABLE_WEB_SERVICE) + target_compile_definitions(citron-room PRIVATE -DENABLE_WEB_SERVICE) + target_link_libraries(citron-room PRIVATE web_service) + endif() endif() target_link_libraries(citron-room PRIVATE mbedtls mbedcrypto)