Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error on M2 pro chip #52

Closed
MKoesters opened this issue Feb 19, 2024 · 10 comments
Closed

Compile error on M2 pro chip #52

MKoesters opened this issue Feb 19, 2024 · 10 comments

Comments

@MKoesters
Copy link

Hi,

I'm trying to install IsoSpecPy from pypi.
It errors out with:

error: unknown target CPU 'apple-m1'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4
error: command '/usr/bin/clang' failed with exit code 1

I get the same error when downloading the source and compiling.

Is IsoSpecPy even supported on Apples ARM chips?

Best,
Manuel

@MatteoLacki
Copy link
Owner

Hi,

I just installed it on Mac with M2 chip (don't have a simulator for M1 though, not even the real thing) and successfully run.
Just to be sure: did you install x-tools command line tools with xcode-select install in the terminal? For me, without it the first install failed, albeit because of a different error than yours.

Best,

@MKoesters
Copy link
Author

MKoesters commented Feb 22, 2024

Hi,

I'm also using a Mac with a M2 chip, however the error mentions M1 (I guess its just about the ARM arch).
xcode is installed and up to date, I'll assume its a issue of my machine/setup/whatever and try to fix it somehow.

Edit:
This is the compile command which is failing:

clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/Users/manuel/.virtualenvs/ursgal2/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c IsoSpec++/python-build.cpp -o build/temp.macosx-10.9-universal2-cpython-39/IsoSpec++/python-build.o -mtune=native -march=native -O3 -std=c++17

-arch is used twice, once with arm64, once with x86_64.
If I remove the x86_64 part, it is working.
Maybe Rosetta is interfering somehow and wants it as x86?

Best,
Manuel

@MatteoLacki
Copy link
Owner

MatteoLacki commented Feb 22, 2024 via email

@michalsta
Copy link
Collaborator

Okay, it definitely looks like some sort of compiler misconfiguration. We definitely didn't code the build system to deal with Rosetta, so that'll probably need to be fixed. But: what exactly are you trying to achieve, that is what's the use-case here? Are you trying to compile it natively on Apple silicon (which should work BTW) and Rosetta (apparently) is getting in the way, or are you trying to produce something that can work inside Rosetta?

@MKoesters
Copy link
Author

MKoesters commented Feb 22, 2024

I'm simply trying to install IsoSpecPy via pip (and via setup.py after cloning this repo)
Both resulted in the same error.
Here is the full code I'm running

mkvirtualenv IsoSpecPy --python 3.9
pip install isospecpy # (or pip install . for the source code)
Collecting isospecpy
  Using cached IsoSpecPy-2.2.1.tar.gz (2.2 MB)
  Preparing metadata (setup.py) ... done
Collecting cffi (from isospecpy)
  Using cached cffi-1.16.0-cp39-cp39-macosx_11_0_arm64.whl.metadata (1.5 kB)
Collecting pycparser (from cffi->isospecpy)
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Using cached cffi-1.16.0-cp39-cp39-macosx_11_0_arm64.whl (176 kB)
Building wheels for collected packages: isospecpy
  Building wheel for isospecpy (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.9-universal2-cpython-39
      creating build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/Formulas.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/Advanced.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/PeriodicTbl.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/confs_passthrough.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/IsoSpecPyOld.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/IsoSpecPy.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/Distributions.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/isoFFI.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      copying IsoSpecPy/approximations.py -> build/lib.macosx-10.9-universal2-cpython-39/IsoSpecPy
      running build_ext
      Check flags: True []
      Check flags: True ['-mtune=native']
      Check flags: True ['-mtune=native', '-march=native']
      Check flags: True ['-mtune=native', '-march=native', '-O3']
      Check flags: True ['-mtune=native', '-march=native', '-O3', '-std=c++17']
      building 'IsoSpecCppPy' extension
      creating build/temp.macosx-10.9-universal2-cpython-39
      creating build/temp.macosx-10.9-universal2-cpython-39/IsoSpec++
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/Users/manuel/.virtualenvs/IsoSpecPy/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c IsoSpec++/python-build.cpp -o build/temp.macosx-10.9-universal2-cpython-39/IsoSpec++/python-build.o -mtune=native -march=native -O3 -std=c++17
      error: unknown target CPU 'apple-m1'
      note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for isospecpy
  Running setup.py clean for isospecpy
Failed to build isospecpy
ERROR: Could not build wheels for isospecpy, which is required to install pyproject.toml-based projects

[notice] A new release of pip is available: 23.3.2 -> 24.0
[notice] To update, run: pip install --upgrade pip

@MatteoLacki
Copy link
Owner

Maybe the version of python you have is not for ARM but x86 and that is why rosetta kicks in?

@MKoesters
Copy link
Author

Maybe the version of python you have is not for ARM but x86 and that is why rosetta kicks in?

Guess its both

(IsoSpecPy) ➜  ~ file `which python`
/Users/manuel/.virtualenvs/IsoSpecPy/bin/python: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/Users/manuel/.virtualenvs/IsoSpecPy/bin/python (for architecture x86_64):	Mach-O 64-bit executable x86_64
/Users/manuel/.virtualenvs/IsoSpecPy/bin/python (for architecture arm64):	Mach-O 64-bit executable arm64

I'll see when I have time to fix this, when I'll do, I'll make sure to post the fix and the reasons why this happened to me

@MatteoLacki
Copy link
Owner

MatteoLacki commented Feb 23, 2024 via email

@michalsta
Copy link
Collaborator

michalsta commented Feb 23, 2024

OK, I think I see what's going on now: the build system is trying to produce a multiarch binary, and the march/mtune=native messes up the cross-compilation for x86. I've removed these flags on MacOS: well, it's not exactly a server system so squeezing every last bit of performance isn't as important there.

Can you try checking out the current version2_2 branch, and seeing if it works now?

@MKoesters
Copy link
Author

OK, I think I see what's going on now: the build system is trying to produce a multiarch binary, and the march/mtune=native messes up the cross-compilation for x86. I've removed these flags on MacOS: well, it's not exactly a server system so squeezing every last bit of performance isn't as important there.

Can you try checking out the current version2_2 branch, and seeing if it works now?

Yes, that branch works without any problems.
Thanks for the quick fix :)

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

No branches or pull requests

3 participants