3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-22 08:17:37 +00:00

Fix macOS cross-compilation from ARM64 to x86_64 in mk_unix_dist.py and mk_util.py

When macos-latest changed to ARM64 runners, the mac-build-x64 job started
producing arm64 libz3.dylib inside x86_64-tagged wheels, causing import
failures on macOS x86_64.

Root cause: mk_make.py subprocess detects the ARM64 host at module level
(IS_ARCH_ARM64=True), and without --arm64=false override it adds -arch arm64
to SLIBEXTRAFLAGS, overriding the -arch x86_64 set via environment variables.

Fix 1 (mk_unix_dist.py): Pass --arm64=false to mk_make.py subprocess when
building x64 on an ARM64 host, preventing the arm64 flag inheritance.

Fix 2 (mk_util.py): When IS_ARCH_ARM64=False on an ARM64 macOS host, add
-arch x86_64 to SLIBEXTRAFLAGS so the shared library linker also targets
x86_64 (LDFLAGS already receives this flag from the env var).

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-19 18:02:52 +00:00
parent 9c8c9f5eea
commit c4acd2a47e
2 changed files with 9 additions and 0 deletions

View file

@ -140,6 +140,10 @@ def mk_build_dir(path):
opts.append('--python')
if mk_util.IS_ARCH_ARM64:
opts.append('--arm64=true')
elif HOST_IS_ARM64:
# Explicitly disable arm64 when cross-compiling from ARM64 host to x64;
# without this, mk_make.py detects the ARM64 host and adds -arch arm64 flags
opts.append('--arm64=false')
if mk_util.IS_ARCH_ARM64 and LINUX_X64:
# we are on x64 machine but build for arm64
# so we have to do cross compiling on Linux

View file

@ -2756,6 +2756,11 @@ def mk_config():
CXXFLAGS = '%s -arch arm64' % CXXFLAGS
LDFLAGS = '%s -arch arm64' % LDFLAGS
SLIBEXTRAFLAGS = '%s -arch arm64' % SLIBEXTRAFLAGS
elif IS_OSX and os.uname()[4] == 'arm64':
# Cross-compiling from ARM64 host to x86_64: ensure the shared library
# linker also targets x86_64 (LDFLAGS already contains -arch x86_64
# from the environment, but SLIBEXTRAFLAGS is independent)
SLIBEXTRAFLAGS = '%s -arch x86_64' % SLIBEXTRAFLAGS
if IS_OSX:
SLIBFLAGS += ' -Wl,-headerpad_max_install_names'