Skip to content

Linking failing on Apple silicon w/ PyPy #510

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

Open
Cerebus opened this issue May 22, 2025 · 4 comments
Open

Linking failing on Apple silicon w/ PyPy #510

Cerebus opened this issue May 22, 2025 · 4 comments

Comments

@Cerebus
Copy link

Cerebus commented May 22, 2025

Trying to build for PyPy3.10:

$  pip install "numexpr==2.10.2"
[...]
    running build_ext
      building 'numexpr.interpreter' extension
      creating build/temp.macosx-11.0-arm64-pypy310/numexpr
      g++ -pthread -arch arm64 -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/private/var/folders/vj/vkfg28_d3m36zls5s7mf5whh0000gn/T/pip-build-env-io43xb_n/overlay/lib/pypy3.10/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy3.10-7.3.17/envs/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.10-7.3.17/include/pypy3.10 -c numexpr/interpreter.cpp -o build/temp.macosx-11.0-arm64-pypy310/numexpr/interpreter.o
      g++ -pthread -arch arm64 -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/private/var/folders/vj/vkfg28_d3m36zls5s7mf5whh0000gn/T/pip-build-env-io43xb_n/overlay/lib/pypy3.10/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy3.10-7.3.17/envs/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.10-7.3.17/include/pypy3.10 -c numexpr/module.cpp -o build/temp.macosx-11.0-arm64-pypy310/numexpr/module.o
      g++ -pthread -arch arm64 -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/private/var/folders/vj/vkfg28_d3m36zls5s7mf5whh0000gn/T/pip-build-env-io43xb_n/overlay/lib/pypy3.10/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy3.10-7.3.17/envs/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.10-7.3.17/include/pypy3.10 -c numexpr/numexpr_object.cpp -o build/temp.macosx-11.0-arm64-pypy310/numexpr/numexpr_object.o
      g++ -pthread -arch arm64 -DNDEBUG -O2 -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.macosx-11.0-arm64-pypy310/numexpr/interpreter.o build/temp.macosx-11.0-arm64-pypy310/numexpr/module.o build/temp.macosx-11.0-arm64-pypy310/numexpr/numexpr_object.o -o build/lib.macosx-11.0-arm64-pypy310/numexpr/interpreter.pypy310-pp73-darwin.so
      ld: unknown options: -Bsymbolic-functions
      clang++: error: linker command failed with exit code 1 (use -v to see invocation)
      error: command '/usr/bin/g++' failed with exit code 1
      [end of output]

PyPy is built w/ Apple clang, and I've isolated my build env from homebrew's clang & gcc. Building w/ CC=clang CXX=clang++ yields the same linker error.

I'm probably missing an env var. Pointers?

@27rabbitlt
Copy link
Contributor

This seems to be an incompatability problem between pypy and setuptools, see: pypa/distutils#283.

I've tested on my MacOS that if we build from source "pypy3 setup.py build install", it can be solved..

Also, as mentioned in pypa/distutils#283, it seems that upgrading to pypy3.11 would solve the problem.

@Cerebus
Copy link
Author

Cerebus commented May 22, 2025

pypa/distutils#283 is a different error. I can find no references in that repo to this specific linker flag.

Nevertheless:

$ python -V
Python 3.11.11 (0253c85bf5f8, Feb 26 2025, 10:42:49)
[PyPy 7.3.19 with GCC Apple LLVM 15.0.0 (clang-1500.3.9.4)]

> pip list | grep setuptools
setuptools 72.1.0

> CC=clang CXX=clang++ pip install "numexpr==2.10.2"
[...]
      building 'numexpr.interpreter' extension
      creating build/temp.macosx-11.0-arm64-pypy311/numexpr
      clang++ -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/private/var/folders/vj/vkfg28_d3m36zls5s7mf5whh0000gn/T/pip-build-env-zj7xlrr1/overlay/lib/pypy3.11/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/envs/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/include/pypy3.11 -c numexpr/interpreter.cpp -o build/temp.macosx-11.0-arm64-pypy311/numexpr/interpreter.o
      clang++ -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/private/var/folders/vj/vkfg28_d3m36zls5s7mf5whh0000gn/T/pip-build-env-zj7xlrr1/overlay/lib/pypy3.11/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/envs/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/include/pypy3.11 -c numexpr/module.cpp -o build/temp.macosx-11.0-arm64-pypy311/numexpr/module.o
      clang++ -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/private/var/folders/vj/vkfg28_d3m36zls5s7mf5whh0000gn/T/pip-build-env-zj7xlrr1/overlay/lib/pypy3.11/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/envs/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/include/pypy3.11 -c numexpr/numexpr_object.cpp -o build/temp.macosx-11.0-arm64-pypy311/numexpr/numexpr_object.o
      clang++ -DNDEBUG -O2 -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.macosx-11.0-arm64-pypy311/numexpr/interpreter.o build/temp.macosx-11.0-arm64-pypy311/numexpr/module.o build/temp.macosx-11.0-arm64-pypy311/numexpr/numexpr_object.o -o build/lib.macosx-11.0-arm64-pypy311/numexpr/interpreter.pypy311-pp73-darwin.so
      ld: unknown options: -Bsymbolic-functions
      clang++: error: linker command failed with exit code 1 (use -v to see invocation)
      error: command '/usr/bin/clang++' failed with exit code 1

@Cerebus
Copy link
Author

Cerebus commented May 22, 2025

Also:

> pwd
~/projects/foss/numexpr

> pip list | grep setuptools
setuptools 80.8.0

> python -V
Python 3.11.11 (0253c85bf5f8, Feb 26 2025, 10:42:49)
[PyPy 7.3.19 with GCC Apple LLVM 15.0.0 (clang-1500.3.9.4)]

>  python setup.py build install
[...]
running build_ext
building 'numexpr.interpreter' extension
g++ -pthread -arch arm64 -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/Users/tmiller/.pyenv/versions/pypy-task-analysis/lib/pypy3.11/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/include/pypy3.11 -c numexpr/interpreter.cpp -o build/temp.macosx-11.0-arm64-pypy311/numexpr/interpreter.o
g++ -pthread -arch arm64 -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/Users/tmiller/.pyenv/versions/pypy-task-analysis/lib/pypy3.11/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/include/pypy3.11 -c numexpr/module.cpp -o build/temp.macosx-11.0-arm64-pypy311/numexpr/module.o
g++ -pthread -arch arm64 -DNDEBUG -O2 -fPIC -DNPY_TARGET_VERSION=NPY_1_23_API_VERSION -I/Users/tmiller/.pyenv/versions/pypy-task-analysis/lib/pypy3.11/site-packages/numpy/_core/include -I/Users/tmiller/.pyenv/versions/pypy-task-analysis/include -I/Users/tmiller/.pyenv/versions/pypy3.11-7.3.19/include/pypy3.11 -c numexpr/numexpr_object.cpp -o build/temp.macosx-11.0-arm64-pypy311/numexpr/numexpr_object.o
g++ -pthread -arch arm64 -DNDEBUG -O2 -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.macosx-11.0-arm64-pypy311/numexpr/interpreter.o build/temp.macosx-11.0-arm64-pypy311/numexpr/module.o build/temp.macosx-11.0-arm64-pypy311/numexpr/numexpr_object.o -o build/lib.macosx-11.0-arm64-pypy311/numexpr/interpreter.pypy311-pp73-darwin.so
ld: unknown options: -Bsymbolic-functions
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/g++' failed with exit code 1

@27rabbitlt
Copy link
Contributor

pypa/distutils#283 (comment)

This comment seems to be the same problem right? Anyways it's not a bug in numexpr side I guess and I don't know why python setup.py build works for me (somehow in this way it won't call g++ with LDFLAG -Bsymbolic-function on my mac).

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

2 participants