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

Add support for macOS/arm64 #275

Closed
BatchDrake opened this issue Feb 2, 2025 · 5 comments
Closed

Add support for macOS/arm64 #275

BatchDrake opened this issue Feb 2, 2025 · 5 comments

Comments

@BatchDrake
Copy link

The newest macOS runners in GitHub are arm64 only. While other libraries and brew dependencies install themselves for arm64, this action keeps installing the x86_64 version in macOS. Are there plans for adding this arm64 support soon?

@pcolby
Copy link

pcolby commented Feb 5, 2025

Hi @BatchDrake, ARM64 is already supported on macOS - I have a few projects that produce ARM64 builds using install-qt-action.

To expand, as I understand it, install-qt-action uses aqtinstall to install Qt. And aqtinstall, in turn, fetches the Qt binaries from download.qt.io (replicating the behaviour of the Qt Online Installer). And download.qt.io does not host separate AMD64 and ARM64 binaries for macOS, but rather, hosts "universal" binaries that include both. For example, the binaries for Qt 6.8.2 on macOS are here. Note they include X86_64-ARM64 in their names, because they include both.

For CMake-based projects, to build for macOS ARM64, simply install Qt via the this action, then set CMAKE_OSX_ARCHITECTURES accordingly, before invoking cmake.

Here's a sample step I use for macOS builds in one of my FLOSS projects, just to give you a sense of what's possible:

      - name: Choose target architectures
        id: arch
        run: |
          # Qt only supports x86-64 (not arm64) prior to Qt 6.2.0. See https://www.qt.io/blog/qt-on-apple-silicon
          if [[ '${{ matrix.qt }}' =~ ^(5|6\.[01])\. ]]; then arch=x86_64
          # GitHub runners' (homebrew'd) gcc's only support support x86-64 prior to macos-14, and only arm64 after.
          # Note: if we attempt to use multiple archs, gcc will warn, but continue, resulting in later failures.
          elif [[ '${{ matrix.cc }}' == 'gcc' ]]; then
            if [[ '${{ matrix.os }}' == 'macos-13' ]]; then arch='x86_64'; else arch='arm64'; fi
          # Otherwise, default to universal binaries, where possible.
          else arch='arm64;x86_64'; fi
          tee -a "$GITHUB_ENV" <<< "CMAKE_OSX_ARCHITECTURES=${arch}"
          tee -a "$GITHUB_OUTPUT" <<< "buildId=${arch//;/-}"

I hope that helps ☺

Cheers.

@pzhlkj6612
Copy link
Contributor

Thanks for your help, @pcolby.


To expand, as I understand it, install-qt-action uses aqtinstall to install Qt.

Right.

Here's a sample step I use for macOS builds in one of my FLOSS projects

Maybe the installation config in your YAML is also important:

      - name: Install Qt
        uses: jurplel/install-qt-action@v4
        with:
          version: ${{ matrix.qt }}
          modules: ${{ startsWith(matrix.qt, '6') && 'qtconnectivity' || '' }}
          documentation: true
          doc-archives: >-
            ${{ (startsWith(matrix.qt, '5.10.') || startsWith(matrix.qt, '5.11.')) && 'qt' ||
                (startsWith(matrix.qt, '5') && 'qtcore qtbluetooth' || 'qtcore') }}
          doc-modules: ${{ startsWith(matrix.qt, '6') && 'qtbluetooth' || '' }}
          aqtversion: '>=3.2.0' # 3.2.0+ required for Qt 6.8+ support; https://github.com/miurahr/aqtinstall/issues/843

# from: https://github.com/pcolby/dokit/blob/617499c13132db613dafb8c187069e107354ad87/.github/workflows/build.yaml#L254-L264

And it would be better to use permalinks:


To @BatchDrake and @pcolby: The "install-qt-action" action prints arguments of each "aqtinstall" call during its running, so you can debug it by directly using "aqtinstall" yourself and report new bugs in their repository: https://github.com/miurahr/aqtinstall

@pcolby
Copy link

pcolby commented Feb 7, 2025

And it would be better to use permalinks: ...

Thanks @pzhlkj6612, that's a great tip I will use from now on! 😊

@BatchDrake
Copy link
Author

Hi, and thanks for your helpful answers! Now everything builds as expected.

In the end it was a GitHub runner issue, Homebrew either fails to install x86-64 libraries or they get installed somewhere else and the library paths are wrong. Either way I am sure it can be fixed one way or another. A workaround that may work for some could be to link against arm64 alone, this is what I am currently doing until I figure this out.

@pzhlkj6612
Copy link
Contributor

@BatchDrake, good to hear that! And I think you can report the bug in GitHub's repository: https://github.com/actions/runner-images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants