Linker error building on macOS
drewcassidy opened this issue · 4 comments
When attempting to build the example on macOS 11, I get the following error:
$ pip install .
Processing /Users/drewcassidy/Projects/python_example
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: python-example
Building wheel for python-example (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /Users/drewcassidy/Projects/python_example/env/bin/python3 /Users/drewcassidy/Projects/python_example/env/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/01/8l9_pc0j3sg_0x2_ydzz4mzr0000gn/T/tmpdbjdwhmu
cwd: /private/var/folders/01/8l9_pc0j3sg_0x2_ydzz4mzr0000gn/T/pip-req-build-_a8us1o1
Complete output (11 lines):
running bdist_wheel
running build
running build_ext
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.8/Headers -arch arm64 -arch x86_64 -I/usr/local/opt/llvm/include -I/usr/local/opt/gettext/include -I/Users/drewcassidy/Projects/python_example/env/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c flagcheck.cpp -o flagcheck.o -std=c++17
building 'python_example' extension
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.8/Headers -arch arm64 -arch x86_64 -I/usr/local/opt/llvm/include -I/usr/local/opt/gettext/include -DVERSION_INFO=0.0.1 -I/private/var/folders/01/8l9_pc0j3sg_0x2_ydzz4mzr0000gn/T/pip-build-env-nm37cieu/overlay/lib/python3.8/site-packages/pybind11/include -I/Users/drewcassidy/Projects/python_example/env/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c src/main.cpp -o build/temp.macosx-10.14.6-x86_64-3.8/src/main.o -std=c++17 -mmacosx-version-min=10.14 -fvisibility=hidden -g0 -stdlib=libc++
clang++ -bundle -undefined dynamic_lookup -Wl,-headerpad,0x1000 -arch arm64 -arch x86_64 -L/usr/local/opt/llvm/lib -L/usr/local/opt/gettext/lib -I/usr/local/opt/llvm/include -I/usr/local/opt/gettext/include build/temp.macosx-10.14.6-x86_64-3.8/src/main.o -o build/lib.macosx-10.14.6-x86_64-3.8/python_example.cpython-38-darwin.so -mmacosx-version-min=10.14 -stdlib=libc++
ld: warning: ignoring file /usr/local/opt/llvm/lib/libc++.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: in '/usr/local/opt/llvm/lib/libunwind.dylib', building for macOS-arm64 but attempting to link with file built for macOS-x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang++' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for python-example
Failed to build python-example
ERROR: Could not build wheels for python-example which use PEP 517 and cannot be installed directly
It seems like its trying to do a cross platform build, but a dylib is is only available on x86-64, and with how opaque the build options are with pip/setuptools I don't know how to tell it to just build for x86-64. Is this something that could be fixed in the setup.py file?
I have the same problem too.
Are you using the Universal2 installer from Python.org? Setuptools inherits the flags from the Python build, so it seems to be also trying to build universal, but you are picking up llvm libs from homebrew /opt (macports, perhaps? Or a custom build? homebrew goes into EDIT: Nevermind, it's /usr/local
on Intel macOS)/usr/local/opt
, that's usually homebrew), and only the system libs are also universal. If you use Python from homebrew, that should work just fine, as it's not universal. But mixing them does not work.
I think you can set the environment variable ARCHFLAGS to -arch x86_64
to override.
(Be sure to checkout my edits above)
thanks, I didn't realize that, I thought something about the way setup.py is setup was forcing a fat binary build