diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1fab6354..05cf1bf53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -146,6 +146,57 @@ jobs: name: shadps4-macos-sdl-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }} path: upload/ + macos-sdl-arm64: + runs-on: macos-15 + needs: get-info + steps: + - uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Setup latest Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest + + - name: Cache CMake Configuration + uses: actions/cache@v4 + env: + cache-name: ${{ runner.os }}-sdl-arm64-cache-cmake-configuration + with: + path: | + ${{github.workspace}}/build-arm64 + key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + restore-keys: | + ${{ env.cache-name }}- + + - name: Cache CMake Build + uses: hendrikmuhs/ccache-action@v1.2.19 + env: + cache-name: ${{runner.os}}-sdl-arm64-cache-cmake-build + with: + append-timestamp: false + create-symlink: true + key: ${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + variant: sccache + + - name: Configure CMake + run: cmake --fresh -B ${{github.workspace}}/build-arm64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + + - name: Build + run: cmake --build ${{github.workspace}}/build-arm64 --config ${{env.BUILD_TYPE}} --parallel $(sysctl -n hw.ncpu) + + - name: Package and Upload macOS ARM64 SDL artifact + run: | + mkdir upload-arm64 + mv ${{github.workspace}}/build-arm64/shadps4 upload-arm64 + mv ${{github.workspace}}/build-arm64/MoltenVK_icd.json upload-arm64 + mv ${{github.workspace}}/build-arm64/libMoltenVK.dylib upload-arm64 + - uses: actions/upload-artifact@v4 + with: + name: shadps4-macos-arm64-sdl-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }} + path: upload-arm64/ + linux-sdl: runs-on: ubuntu-24.04 needs: get-info @@ -245,7 +296,7 @@ jobs: pre-release: if: github.ref == 'refs/heads/main' && github.repository == 'shadps4-emu/shadPS4' && github.event_name == 'push' - needs: [get-info, windows-sdl, macos-sdl, linux-sdl] + needs: [get-info, windows-sdl, macos-sdl, macos-sdl-arm64, linux-sdl] runs-on: ubuntu-latest steps: - name: Download all artifacts diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index a82a224a3..d186d8a04 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -574,6 +574,7 @@ struct AddressSpace::Impl { #else const auto virtual_size = system_managed_size + system_reserved_size + user_size; #if defined(ARCH_X86_64) + constexpr int map_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED; const auto virtual_base = reinterpret_cast(mmap(reinterpret_cast(SYSTEM_MANAGED_MIN), virtual_size, protection_flags, map_flags, -1, 0)); @@ -581,6 +582,7 @@ struct AddressSpace::Impl { system_reserved_base = reinterpret_cast(SYSTEM_RESERVED_MIN); user_base = reinterpret_cast(USER_MIN); #else + constexpr int map_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE; // Map memory wherever possible and instruction translation can handle offsetting to the // base. const auto virtual_base = @@ -732,7 +734,7 @@ struct AddressSpace::Impl { if (write) { flags |= PROT_WRITE; } -#ifdef ARCH_X86_64 +#if defined(ARCH_X86_64) if (execute) { flags |= PROT_EXEC; } @@ -786,7 +788,7 @@ AddressSpace::~AddressSpace() = default; void* AddressSpace::Map(VAddr virtual_addr, size_t size, u64 alignment, PAddr phys_addr, bool is_exec) { -#if ARCH_X86_64 +#if defined(ARCH_X86_64) const auto prot = is_exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; #else // On non-native architectures, we can simplify things by ignoring the execute flag for the @@ -857,7 +859,7 @@ boost::icl::interval_set AddressSpace::GetUsableRegions() { } void* AddressSpace::TranslateAddress(VAddr ps4_addr) const { -#ifdef ARCH_X86_64 +#if defined(ARCH_X86_64) // On x86_64, PS4 addresses are directly mapped, so we can cast them return reinterpret_cast(ps4_addr); #elif defined(ARCH_ARM64) && defined(__APPLE__)