Building Game Porting Toolkit on Sequoia

Like many folks here, I've recently attempted to build Apple's Game Porting Toolkit on my machine and ran into compiler errors, but instead of going the usual route of downloading the prebuilt package (kindly provided by GCenX), I decided to see if I could force it to build (since it was obviously buildable at some point). Down below is the list of things I had to do to make it work.

Disclaimer: There are several dirty hacks I had to attempt to force the system to do what I needed. Use at your own risk.

  • Don't forget to run all brew commands from a Rosetta prompt:

    arch -x86_64 zsh
    
  • Install openssl

    This one is easy. Just run

    brew tap rbenv/tap
    brew install rbenv/tap/openssl@1.1
    
  • Install Command Line Tools 15.1

    This specific version is required since newer versions come with the linker that is not compatible with the custom compiler (game-porting-toolkit-compiler) that GPTK is using. However, by default 15.1 tools won't install on Sequoia since the installer complains that macOS version is too new. Obviously, Apple has their reasons to not allow this, but all we need is a compiler which should be mostly indifferent to the OS version.

    To trick the installer, we need to change OS requirement of the installer package. You can do it in four easy steps:

    1. Copy Command Line Tools.pkg from the mounted Command_Line_Tools_for_Xcode_15.1.dmg to some other directory.

    2. Expand the installer package:

      pkgutil --expand "Command Line Tools.pkg" CLT
      

      You might be prompted to install Command Line Tools when you call pkgutil, just install any version.

    3. Go to the newly created CLT folder and edit the Distribution file (it may appear as executable but it's just an xml). You would want to change allowed-os-versions to something greater than 15. Removing this section altogether might also work.

    4. When done, re-wrap the package:

      pkgutil --flatten CLT "Command Line Tools 2.pkg"
      

    Congratulations, now you should be able to install 15.1 tools on your OS! If you had to install newer Command Line Tools for pkgutil, delete them before installing 15.1:

    sudo rm -rf /Library/Developer/CommandLineTools
    
  • Next step is to make Homebrew accept the outdated 15.1 tools, as by default it'll complain that they're outdated or corrupted. To shut it up, open

    /usr/local/Homebrew/Library/Homebrew/extend/os/Mac/diagnostic.rb
    

    and remove references to check_if_supported_sdk_available from a couple of fatal build check collections.

    Note - by default, Homebrew will auto-update on any invocation, which will overwrite any changes you've made to its internals. To disable this behavior, before running any brew commands in the terminal, run

    export HOMEBREW_NO_AUTO_UPDATE=1
    

    After these manipulations, Homebrew might still complain about outdated Command Line Tools, but it won't be a fatal error anymore.

  • Finally, we need to downgrade MinGW to 11.0.1, since the latest version spits out compiler errors when compiling Wine. Unfortunately, Homebrew does a bad job tracking versions of MinGW, so there is no automatic way to do it. Instead, you have to manually download and install old MinGW 11.0.1 formula from the Homebrew git repository. I used the commit from Sep 16, 2023:

    https://github.com/Homebrew/homebrew-core/blob/b95f4f9491394af667943bd92b081046ba3406f2/Formula/m/mingw-w64.rb

    Download the file above, save it in your current working directory, and then run

    brew install ./mingw-w64.rb
    

    If you had a newer version of MinGW already installed from the previous build attempts, you can unlink it before installing the one above:

    brew unlink mingw-w64
    
  • With Command Line Tools 15.1 and MinGW 11.0.1 you should now be able to build GPTK without errors:

    brew -v install apple/apple/game-porting-toolkit
    

In the end, steps above worked for me, although more things could break in the future. I'm leaving the instructions here just to show that it's still possible to build GPTK manually instead of relying on third parties, but with all the hoops I had to jump through I can't really recommend it.

Building Game Porting Toolkit on Sequoia
 
 
Q