Skip to content

Commit 2d77e8f

Browse files
authored
Merge pull request #636 from danshapero/m1-fixes
Fix compilation failures on Mac M1 machines
2 parents d5f82d3 + a98bb32 commit 2d77e8f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

pyop2/compilation.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434

3535
import os
36+
import platform
3637
import shutil
3738
import subprocess
3839
import sys
@@ -369,9 +370,17 @@ class MacCompiler(Compiler):
369370
"""
370371

371372
def __init__(self, cppargs=[], ldargs=[], cpp=False, comm=None):
372-
opt_flags = ['-march=native', '-O3', '-ffast-math']
373-
if configuration['debug']:
374-
opt_flags = ['-O0', '-g']
373+
machine = platform.uname().machine
374+
opt_flags = ["-O3", "-ffast-math"]
375+
if machine == "arm64":
376+
# See https://stackoverflow.com/q/65966969
377+
opt_flags.append("-mcpu=apple-a14")
378+
elif machine == "x86_64":
379+
opt_flags.append("-march=native")
380+
381+
if configuration["debug"]:
382+
opt_flags = ["-O0", "-g"]
383+
375384
cc = "mpicc"
376385
stdargs = ["-std=c99"]
377386
if cpp:

0 commit comments

Comments
 (0)