Skip to content

Support building x64-osx on arm64 macOS hosts (Rosetta) - #297

Closed
3nids wants to merge 7 commits into
open-vcpkg:mainfrom
3nids:osx-cross-python3
Closed

3nids wants to merge 7 commits into
open-vcpkg:mainfrom
3nids:osx-cross-python3

Conversation

@3nids

@3nids 3nids commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Allows building x64-osx-dynamic packages on an arm64 macOS machine (--host-triplet=arm64-osx-dynamic --triplet=x64-osx-dynamic), running the x86_64 target tools under Rosetta. The motivation is building qtwebengine + py-pyqt6 + py-pyqt6-webengine without an Intel runner.

On macOS, vcpkg's toolchain sets CMAKE_CROSSCOMPILING=OFF for arm64 -> x64 (the target binaries can run), but VCPKG_CROSSCOMPILING is still on. That mismatch breaks several ports here:

  • python3: CPython's configure refuses --host=x86_64-apple-darwin --build=aarch64-apple-darwin ("cross build not supported"). On a macOS host the port now configures as a native build.
  • vcpkg-python-scripts: the py-* ports run the target python, but gpep517, installer, setuptools and wheel are host dependencies, so the build fails with No module named gpep517. In a cross build the host site-packages (pure Python only) is appended to PYTHONPATH. This only works because the target python can run on the build machine, so it is not a general answer to Crosscompiling python extensions using host python #39.
  • python3 (pipe2): with a macOS 27 SDK on macOS 26, CPython 3.12 detects pipe2, links it weakly and calls it unguarded, so os.pipe() and subprocess segfault. ac_cv_func_pipe2=no on macOS avoids it. This is not cross-specific; it affects native builds with a newer SDK than the running OS.
  • py-pyqt6, py-pyqt6-webengine, py-qscintilla: sipbuild needs a target qmake, which doesn't exist in a cross build (qtbase builds no host tools). New helper vcpkg_python_get_qmake returns the installed qmake if present, otherwise a wrapper that runs the host qmake with the target qt.conf, the same way vcpkg_qmake_configure does.

The last commit bumps port-version of the touched ports.

Tested on macOS 26.6 / Xcode 27.2 on an arm64 host, vcpkg master afa249f12, release-only triplets (x64-osx-dynamic-release target, arm64-osx-dynamic-release host). qtwebengine[webengine,webchannel,pdf] (3.7 h, no changes to its port), py-pyqt6 (qtdeclarative, qtwebengine) and py-pyqt6-webengine all built. All 346 Mach-O files in the target tree are x86_64-only with no build-directory paths in load commands, PyQt6.QtWebEngine{Core,Widgets,Quick} import under arch -x86_64, and a QWebEnginePage loads a page and evaluates JavaScript.

Not tested: this repository's CI (there is no cross job), debug builds, other ports with C extensions (numpy, scipy, ...), non-macOS cross builds. Native builds should be unaffected apart from the pipe2 change, but I have not re-run them with these changes. I can add a cross job to macos.yml if wanted.

@m-kuhn m-kuhn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far, before merging please add tests for (macos) cross builds, probably as replacement for the existing intel builds

@3nids

3nids commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Replaced by #299 with the same commits. The branch moved to this repository so that #300 can be stacked on it.

@3nids 3nids closed this Nov 4, 2026
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

Successfully merging this pull request may close these issues.

2 participants