Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple M1 Support for MacOS #9441

Merged
merged 20 commits into from
May 24, 2021
Merged

Apple M1 Support for MacOS #9441

merged 20 commits into from
May 24, 2021

Commits on May 22, 2021

  1. Apple M1 Support for MacOS

    This commit adds support for compiling Dolphin for ARM on MacOS so that it can
    run natively on the M1 processors without running through Rosseta2 emulation
    providing a 30-50% performance speedup and less hitches from Rosseta2.
    
    It consists of several key changes:
    
    - Adding support for W^X allocation(MAP_JIT) for the ARM JIT
    - Adding the machine context and config info to identify the M1 processor
    - Additions to the build system and docs to support building universal binaries
    - Adding code signing entitlements to access the MAP_JIT functionality
    - Updating the MoltenVK libvulkan.dylib to a newer version with M1 support
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    4ecb308 View commit details
    Browse the repository at this point in the history
  2. Apple M1: Build, Analytics, and Memory Management

    Analytics:
    - Incorporated fix to allow the full set of analytics that was recommended by
      spotlightishere
    
    BuildMacOSUniversalBinary:
    - The x86_64 slice for a universal binary is now built for 10.12
    - The universal binary build script now can be configured though command line
      options instead of modifying the script itself.
    - os.system calls were replaced with equivalent subprocess calls
    - Formatting was reworked to be more PEP 8 compliant
    - The script was refactored to make it more modular
    - The com.apple.security.cs.disable-library-validation entitlement was removed
    
    Memory Management:
    - Changed the JITPageWrite*Execute*() functions to incorporate support for
      nesting
    
    Other:
    - Fixed several small lint errors
    - Fixed doc and formatting mistakes
    - Several small refactors to make things clearer
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    948764d View commit details
    Browse the repository at this point in the history
  3. Apple M1: OS version checking for MAP_JIT

    - Added MacOS version checking around MAP_JIT to prepare code for x86 MAP_JIT
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    4542038 View commit details
    Browse the repository at this point in the history
  4. Apple M1: Refactor ArmCPUDetect.cpp

    Merges two nested #ifndefs into a single #if around hw cap includes.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    61448a9 View commit details
    Browse the repository at this point in the history
  5. Apple M1: Enable hardened runtime

    - Fixed error that was causing the hardened runtime from being enabled
    - Refactored BuildMacOSUniversalBinary.py based on code style recommendations
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    8cb86e7 View commit details
    Browse the repository at this point in the history
  6. Apple M1: MacOS 11.2 mprotect restrictions

    In MacOS 11.2 mprotect can no longer change the access protection settings of
    pages that were previously marked as executable to anything but PROT_NONE. This
    commit works around this new restriction by bypassing the mprotect based write
    protection and instead relying on the write protection provided by MAP_JIT.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    4ff4292 View commit details
    Browse the repository at this point in the history
  7. Apple M1: More robust build for universal binaries

    - Fixed a typo in the Readme.md
    - Made the recursiveMergeBinaries function handle divergent binary file trees
      better.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    0851693 View commit details
    Browse the repository at this point in the history
  8. Apple M1: x86_64 MAP_JIT

    - Enabled MAP_JIT on x86_64 after confirming that pthread_jit* calls are only
    required for MAP_JIT pages on Apple Silicon
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    38861f6 View commit details
    Browse the repository at this point in the history
  9. Apple M1: Fix bug that could cause crash with MMU

    Added a Common::JITPageWriteDisableExecuteEnable() that could be missed when
    a memory exception is triggered by the running game.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    f92ccd5 View commit details
    Browse the repository at this point in the history
  10. Apple M1: Removed unavailable CPU core dialog box

    Removed the unavailable CPU core dialog box that asked users to change their
    selected CPU core to one that is available. Instead, Dolphin now just overrides
    the core to the default, and logs that it performed the override.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    f567fd9 View commit details
    Browse the repository at this point in the history
  11. Apple M1: Update MoltenVK

    - Updated MoltenVK library in external to 1.2.170.0 (fixes swapchain crash)
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    bcb3c7d View commit details
    Browse the repository at this point in the history
  12. Apple M1: Only add x86 compile flags to x86 builds

    - Removed -mssse3 flag from arm64 builds
    - Removed -march=core2 from arm64 builds
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    12c4398 View commit details
    Browse the repository at this point in the history
  13. Apple M1: Support non-Xcode based universal builds

    This change adds the -G and --build_type arguments to the
    BuildMacOSUniversalBinaray.py build script to allow the CMake generator and
    build type to be specified for universal binary builds.
    
    The defaults are:
    -G "Unix Makefiles"
    --build_type "Release"
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    9163312 View commit details
    Browse the repository at this point in the history
  14. Readme: Update macOS build instructions

    1) Place information about universal builds after single architecture builds
       since universal builds are harder to setup the environment for.
    2) Specify that new arguments should be provided instead of direct script
       modification for universal builds.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    7a44a7e View commit details
    Browse the repository at this point in the history
  15. Apple M1: Enable CMake cross compilation

    Modify the build script to use CMake's cross compilation infrastructure instead
    of running CMake natively in x86_64 and arm64 mode to configure the two project
    files. This should fix the builds with CMake executables installed through
    homebrew and should pave the way for building universal binaries on x86_64
    systems.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    b72c47f View commit details
    Browse the repository at this point in the history
  16. Apple M1: Improved handling of paths

    Incorporated changes suggested by Kode54 to use the CMake prefix path, instead
    of relying on pkg-config directory paths.
    
    Added the prefix paths from the other architectures build to the CMake ignore
    path so that CMake doesn't pick up libraries from the wrong architecture if
    they are in the user's search path.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    1015cdc View commit details
    Browse the repository at this point in the history
  17. Apple M1: Fix code signing regression

    This commit fixes a regression in 2ba88d5 that
    would cause an app bundle to not be resigned after merging the two single
    architecture builds.
    
    Also, applies formatting suggestions from Leo Lam
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    76130d8 View commit details
    Browse the repository at this point in the history
  18. Apple M1: RAII Wrapper for JITPageWrite*Execute*()

    Added RAII wrapper around the the JITPageWriteEnableExecuteDisable() and
    JITPageWriteDisableExecuteEnable() to make it so that it is harder to forget to
    pair the calls in all code branches as suggested by leoetlino.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    76ed931 View commit details
    Browse the repository at this point in the history
  19. Apple M1: Detect incompatible universal merges

    Adds a step to detect when the Intel and arm64 build trees cannot be merged
    safely. This can occur when each side has files/folders that are named the same
    but are of different types or symlinks that are the same name but need to point
    to different locations for each architecture.
    
    Before this change, this would just fail silently.
    skylersaleh committed May 22, 2021
    Configuration menu
    Copy the full SHA
    abea411 View commit details
    Browse the repository at this point in the history

Commits on May 24, 2021

  1. Apple M1: Update AutoUpdate PlatformID

    Adds a new PlatformID for universal builds. This will allow single architecture
    builds to be updated through the single architecture path, and universal builds
    to be updated with universal builds.
    skylersaleh committed May 24, 2021
    Configuration menu
    Copy the full SHA
    210f6e7 View commit details
    Browse the repository at this point in the history