mirror of https://github.com/google/benchmark.git
Fix cross compilation for macOS ARM builds in `cibuildwheel` (#1334)
This commit contains a fix for macOS ARM64 wheel buils in Google Benchmark's wheel building CI. Previously, while `cibuildwheel` itself properly identified the need for cross-compilations and produced valid ARM platform wheels, the included shared library containing the Python bindings built by `bazel` was built for x86, resulting in immediate errors upon import. To fix this, logic was added to the setup.py file that adds the "--cpu=darwin_arm64" and "--macos_cpus=arm64" switches to the `bazel build` command if 1) The current system platform is macOS Darwin running on the x86_64 architecture, and 2) The ARCHFLAGS environment variable, set by wheel build systems like conda and cibuildwheel, contains the tag "arm64". This way, bazel correctly sets the target CPU to ARM64, and produces functional wheels for the macOS ARM line of CPUs.
This commit is contained in:
parent
d0fbf8ac23
commit
6d51a119ff
6
setup.py
6
setup.py
|
@ -93,6 +93,12 @@ class BuildBazelExtension(build_ext.build_ext):
|
|||
elif sys.platform == "darwin" and platform.machine() == "x86_64":
|
||||
bazel_argv.append("--macos_minimum_os=10.9")
|
||||
|
||||
# ARCHFLAGS is always set by cibuildwheel before macOS wheel builds.
|
||||
archflags = os.getenv("ARCHFLAGS", "")
|
||||
if "arm64" in archflags:
|
||||
bazel_argv.append("--cpu=darwin_arm64")
|
||||
bazel_argv.append("--macos_cpus=arm64")
|
||||
|
||||
self.spawn(bazel_argv)
|
||||
|
||||
shared_lib_suffix = '.dll' if IS_WINDOWS else '.so'
|
||||
|
|
Loading…
Reference in New Issue