diff --git a/scripts/mk_unix_dist.py b/scripts/mk_unix_dist.py index 4df68d4c7..4ec98db05 100644 --- a/scripts/mk_unix_dist.py +++ b/scripts/mk_unix_dist.py @@ -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 diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 1af384242..4ec3d5dbd 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -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'