From e56410b404ce5663a394bd404274b9f719232d4e Mon Sep 17 00:00:00 2001 From: lat9nq Date: Thu, 26 May 2022 21:23:11 -0400 Subject: [PATCH 1/3] ci/windows: Split up cmake command Improves readability. --- .ci/scripts/windows/docker.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/windows/docker.sh b/.ci/scripts/windows/docker.sh index 584b9b39fc..d1a0d6ab94 100755 --- a/.ci/scripts/windows/docker.sh +++ b/.ci/scripts/windows/docker.sh @@ -5,7 +5,14 @@ cd /yuzu ccache -s mkdir build || true && cd build -cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_QT_TRANSLATION=ON +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" \ + -DDISPLAY_VERSION=$1 \ + -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \ + -DENABLE_QT_TRANSLATION=ON \ + -DUSE_CCACHE=ON \ + -GNinja \ ninja ccache -s From fef3d8acb51e6a23a73b7f3d2fbf21a80c41351c Mon Sep 17 00:00:00 2001 From: lat9nq Date: Sun, 29 May 2022 03:32:16 -0400 Subject: [PATCH 2/3] CMakeModules: Add MinGWClangCross Facilitates what programs we need for cross-compiling to Windows from Linux using LLVM's compilers. Based on MinGWCross --- CMakeModules/MinGWClangCross.cmake | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 CMakeModules/MinGWClangCross.cmake diff --git a/CMakeModules/MinGWClangCross.cmake b/CMakeModules/MinGWClangCross.cmake new file mode 100644 index 0000000000..ccf4dbf405 --- /dev/null +++ b/CMakeModules/MinGWClangCross.cmake @@ -0,0 +1,55 @@ +set(MINGW_PREFIX /usr/x86_64-w64-mingw32/) +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX}) +set(SDL2_PATH ${MINGW_PREFIX}) +set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-) + +# Specify the cross compiler +set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}clang) +set(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}clang++) +set(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres) +set(CMAKE_C_COMPILER_AR ${MINGW_TOOL_PREFIX}ar) +set(CMAKE_CXX_COMPILER_AR ${MINGW_TOOL_PREFIX}ar) +set(CMAKE_C_COMPILER_RANLIB ${MINGW_TOOL_PREFIX}ranlib) +set(CMAKE_CXX_COMPILER_RANLIB ${MINGW_TOOL_PREFIX}ranlib) + +# Mingw tools +set(STRIP ${MINGW_TOOL_PREFIX}strip) +set(WINDRES ${MINGW_TOOL_PREFIX}windres) +set(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config) + +# ccache wrapper +option(USE_CCACHE "Use ccache for compilation" OFF) +if(USE_CCACHE) + find_program(CCACHE ccache) + if(CCACHE) + message(STATUS "Using ccache 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 ccache found") + endif(CCACHE) +endif(USE_CCACHE) + +# Search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + + +# Echo modified cmake vars to screen for debugging purposes +if(NOT DEFINED ENV{MINGW_DEBUG_INFO}) + message("") + message("Custom cmake vars: (blank = system default)") + message("-----------------------------------------") + message("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}") + message("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}") + message("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}") + message("* WINDRES : ${WINDRES}") + message("* ENV{PKG_CONFIG} : $ENV{PKG_CONFIG}") + message("* STRIP : ${STRIP}") + message("* USE_CCACHE : ${USE_CCACHE}") + message("") + # So that the debug info only appears once + set(ENV{MINGW_DEBUG_INFO} SHOWN) +endif() From c42fde2a373f676b5464168a8df14b22c6b46755 Mon Sep 17 00:00:00 2001 From: lat9nq Date: Sun, 29 May 2022 03:35:08 -0400 Subject: [PATCH 3/3] ci/windows: Build using Clang Uses the MinGWClangCross toolchain script to build yuzu. Disables our bundled SDL2 to use the system ones that have been modified to not use `-mwindows`. Also set's `-e` to stop the script on an error (as opposed to packaging nothing). Uses LLVM's linker for linking yuzu. Adds -femulated-tls due to a libstdc++ incompatibility between GCC and Clang in vulkan_common. --- .ci/scripts/windows/docker.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/windows/docker.sh b/.ci/scripts/windows/docker.sh index d1a0d6ab94..f53d837d1f 100755 --- a/.ci/scripts/windows/docker.sh +++ b/.ci/scripts/windows/docker.sh @@ -1,19 +1,27 @@ #!/bin/bash -ex +set -e + cd /yuzu ccache -s mkdir build || true && cd build +LDFLAGS="-fuse-ld=lld" +# -femulated-tls required due to an incompatibility between GCC and Clang +# TODO(lat9nq): If this is widespread, we probably need to add this to CMakeLists where appropriate cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" \ + -DCMAKE_CXX_FLAGS="-femulated-tls" \ + -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWClangCross.cmake" \ -DDISPLAY_VERSION=$1 \ -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON \ -DENABLE_QT_TRANSLATION=ON \ -DUSE_CCACHE=ON \ - -GNinja \ -ninja + -DYUZU_USE_BUNDLED_SDL2=OFF \ + -DYUZU_USE_EXTERNAL_SDL2=OFF \ + -GNinja +ninja yuzu yuzu-cmd ccache -s