diff --git a/CMakeModules/GentooCross.cmake b/CMakeModules/GentooCross.cmake new file mode 100644 index 0000000000..69e9afc69b --- /dev/null +++ b/CMakeModules/GentooCross.cmake @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +set(CROSS_TARGET "powerpc64le" CACHE STRING "Cross-compilation target (aarch64, powerpc64le, riscv64, etc)") + +set(CMAKE_SYSROOT /usr/${CROSS_TARGET}-unknown-linux-gnu) + +set(CMAKE_C_COMPILER ${CROSS_TARGET}-unknown-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER ${CROSS_TARGET}-unknown-linux-gnu-g++) + +# search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# search headers and libraries in the target environment +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_FIND_ROOT_PATH /usr/${CROSS_TARGET}-unknown-linux-gnu) diff --git a/docs/CrossCompile.md b/docs/CrossCompile.md index 2c7bcf654d..d5c55bb143 100644 --- a/docs/CrossCompile.md +++ b/docs/CrossCompile.md @@ -1,5 +1,118 @@ # Cross Compile +## Gentoo + +Gentoo's cross-compilation setup is relatively easy, provided you're already familiar with portage. + +### Crossdev + +First, emerge crossdev via `sudo emerge -a sys-devel/crossdev`. + +Now, set up the environment depending on the target architecture; e.g. + +```sh +sudo crossdev powerpc64le +sudo crossdev aarch64 +``` + +### QEMU + +Installing a qemu user setup is recommended for testing. To do so, you will need the relevant USE flags: + +```sh +app-emulation/qemu static-user qemu_user_targets_ppc64le qemu_user_targets_aarch64 +``` + +Note that to use cross-emerged libraries, you will need to tell qemu where the sysroot is. You can do this with an alias: + +```sh +alias qemu-ppc64le="qemu-ppc64le -L /usr/powerpc64le-unknown-linux-gnu" +alias qemu-aarch64="qemu-aarch64 -L /usr/aarch64-unknown-linux-gnu" +``` + +### Dependencies + +Some packages have broken USE flags on other architectures; you'll also need to set up python targets. In `/usr/-unknown-linux-gnu/etc/portage/package.use`: + +```sh +>=net-misc/curl-8.16.0-r1 ssl + +*/* PYTHON_TARGETS: python3_13 PYTHON_SINGLE_TARGET: python3_13 +*/* pam + +sys-apps/util-linux pam su +app-shells/bash -readline +>=dev-libs/libpcre2-10.47 unicode +>=x11-libs/libxkbcommon-1.12.3 X +>=sys-libs/zlib-1.3.1-r1 minizip +>=app-alternatives/gpg-1-r3 ssl +>=app-crypt/gnupg-2.5.13-r2 ssl + +dev-libs/* -introspection +media-libs/harfbuzz -introspection +dev-libs/quazip -qt5 qt6 +``` + +Dependencies should be about the same [as normal Gentoo](./Deps.md), but removing gamemode and renderdoc is recommended. Keep in mind that when emerging, you want to use `emerge--unknown-linux-gnu`, e.g. `emerge-powerpc64le-unknown-linux-gnu`. + +Enable GURU in the cross environment (as root): + +```sh +mkdir -p /usr/powerpc64le-unknown-linux-gnu/etc/portage/repos.conf +cat << EOF > /usr/powerpc64le-unknown-linux-gnu/etc/portage/repos.conf/guru.conf +[guru] +location = /var/db/repos/guru +auto-sync = no +priority = 1 +EOF +``` + +Now emerge your dependencies: + +```sh +sudo emerge-powerpc64le-unknown-linux-gnu -aU app-arch/lz4 app-arch/zstd app-arch/unzip \ + dev-libs/libfmt dev-libs/libusb dev-libs/mcl dev-libs/sirit dev-libs/oaknut \ + dev-libs/unordered_dense dev-libs/boost dev-libs/openssl dev-libs/discord-rpc \ + dev-util/spirv-tools dev-util/spirv-headers dev-util/vulkan-headers \ + dev-util/vulkan-utility-libraries dev-util/glslang \ + media-libs/libva media-libs/opus media-video/ffmpeg \ + media-libs/VulkanMemoryAllocator media-libs/libsdl2 media-libs/cubeb \ + net-libs/enet net-libs/mbedtls \ + sys-libs/zlib \ + dev-cpp/nlohmann_json dev-cpp/simpleini dev-cpp/cpp-httplib dev-cpp/cpp-jwt dev-cpp/catch \ + net-wireless/wireless-tools \ + dev-qt/qtbase:6 dev-libs/quazip \ + virtual/pkgconfig +``` + +### Building + +A toolchain is provided in `CMakeModules/GentooCross.cmake`. To use it: + +```sh +cmake -S . -B build/ppc64 -DCMAKE_TOOLCHAIN_FILE=CMakeModules/GentooCross.cmake -G Ninja -DCROSS_TARGET=powerpc64le -DENABLE_OPENGL=OFF +``` + +Now build as normal: + +```sh +cmake --build build/ppc64 -j$(nproc) +``` + +### Alternatively + +Only emerge the absolute necessities: + +```sh +sudo emerge-powerpc64le-unknown-linux-gnu -aU media-video/ffmpeg media-libs/libsdl2 dev-qt/qtbase:6 +``` + +Then set `YUZU_USE_CPM=ON`: + +```sh +cmake -S . -B build/ppc64 -DCMAKE_TOOLCHAIN_FILE=CMakeModules/GentooCross.cmake -G Ninja -DCROSS_TARGET=powerpc64le -DENABLE_OPENGL=OFF -DYUZU_USE_CPM=ON +``` + ## ARM64 A painless guide for cross compilation (or to test NCE) from a x86_64 system without polluting your main. @@ -18,6 +131,7 @@ Now you got a PowerPC sysroot - quickly decompress it somewhere, say `/home/user There is a script to automatically do all of this under `./tools/setup-cross-sysroot.sh` Specify: + - `YUZU_USE_CPM`: Set this to `ON` so packages can be found and built if your sysroot doesn't have them. - `YUZU_USE_EXTERNAL_FFMPEG`: Set this to `ON` as well. diff --git a/externals/powah/CMakeLists.txt b/externals/powah/CMakeLists.txt index 68587ae10d..f5301b2946 100644 --- a/externals/powah/CMakeLists.txt +++ b/externals/powah/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(powah INTERFACE) target_include_directories(powah INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_options(powah INTERFACE -Wno-unused-parameter) add_executable(powah_tests tests.cpp) create_target_directory_groups(powah_tests) diff --git a/externals/powah/powah_emit.hpp b/externals/powah/powah_emit.hpp index c3f110b103..167a2c6945 100644 --- a/externals/powah/powah_emit.hpp +++ b/externals/powah/powah_emit.hpp @@ -5,10 +5,10 @@ #include #include #include -#include -#include +#include #include #include +#include //#ifndef __cpp_lib_unreachable namespace std { diff --git a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp index dd1083532d..ee2386adf1 100644 --- a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp +++ b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/src/dynarmic/src/dynarmic/backend/ppc64/reg_alloc.cpp b/src/dynarmic/src/dynarmic/backend/ppc64/reg_alloc.cpp index 3e524571b0..2aa02777f9 100644 --- a/src/dynarmic/src/dynarmic/backend/ppc64/reg_alloc.cpp +++ b/src/dynarmic/src/dynarmic/backend/ppc64/reg_alloc.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "dynarmic/backend/ppc64/reg_alloc.h" #include "dynarmic/backend/ppc64/abi.h"