pyopencl icon indicating copy to clipboard operation
pyopencl copied to clipboard

Installation error on MacOs: wrong architecture is built

Open fjarri opened this issue 7 years ago • 6 comments

The new pybind11 version does not install properly on MacOs 10.13.6. During the compilation the linker produces several warnings:

ld: warning: ld: warning: ignoring file build/temp.macosx-10.13-x86_64-3.6/src/wrap_cl.o, file was built for x86_64 which is not the architecture being linked (i386): build/temp.macosx-10.13-x86_64-3.6/src/wrap_cl.oignoring file build/temp.macosx-10.13-x86_64-3.6/src/wrap_constants.o, file was built for x86_64 which is not the architecture being linked (i386): build/temp.macosx-10.13-x86_64-3.6/src/wrap_constants.o
ld: warning: ignoring file build/temp.macosx-10.13-x86_64-3.6/src/wrap_cl_part_1.o, file was built for x86_64 which is not the architecture being linked (i386): build/temp.macosx-10.13-x86_64-3.6/src/wrap_cl_part_1.o
ld: warning: ignoring file build/temp.macosx-10.13-x86_64-3.6/src/wrap_cl_part_2.o, file was built for x86_64 which is not the architecture being linked (i386): build/temp.macosx-10.13-x86_64-3.6/src/wrap_cl_part_2.o
ld: warning: ignoring file build/temp.macosx-10.13-x86_64-3.6/src/wrap_mempool.o, file was built for x86_64 which is not the architecture being linked (i386): build/temp.macosx-10.13-x86_64-3.6/src/wrap_mempool.o
ld: warning: ignoring file build/temp.macosx-10.13-x86_64-3.6/src/bitlog.o, file was built for x86_64 which is not the architecture being linked (i386): build/temp.macosx-10.13-x86_64-3.6/src/bitlog.o
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks//OpenCL.framework/OpenCL.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (i386): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks//OpenCL.framework/OpenCL.tbd
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (i386): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libSystem.tbd
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libc++.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (i386): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libc++.tbd
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks//OpenCL.framework/OpenCL.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks//OpenCL.framework/OpenCL.tbd
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libc++.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libc++.tbd
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libSystem.tbd

The installation succeeds despite that, but the module cannot be imported:

>>> import pyopencl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bogdan/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pyopencl/__init__.py", line 37, in <module>
    import pyopencl._cl as _cl
ImportError: dlopen(/Users/bogdan/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pyopencl/_cl.cpython-36m-darwin.so, 2): Symbol not found: _clBuildProgram
  Referenced from: /Users/bogdan/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pyopencl/_cl.cpython-36m-darwin.so
  Expected in: flat namespace
 in /Users/bogdan/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pyopencl/_cl.cpython-36m-darwin.so

fjarri avatar Sep 16 '18 03:09 fjarri

That is weird. Are you sure that that is not something to do with your environment? The pybind11 version passes CI on an Apple machine for me:

https://gitlab.tiker.net/inducer/pyopencl/-/jobs/62183

inducer avatar Sep 16 '18 03:09 inducer

It may be my environment, the question is whether it is something the installation script should detect, or something I should fix. Do you have any ideas on how I can debug it?

On a side note, perhaps this ld warning should actually be an error.

fjarri avatar Sep 16 '18 06:09 fjarri

It seems to be trying to build a 32-bit binary. Any clue why it would try to do that?

Could you post a link to the full build log, including the compiler/linker invocations?

inducer avatar Sep 16 '18 19:09 inducer

No idea, the previous PyOpenCL versions do not seem to have this problem (with the same environment). The build log is here: https://gist.github.com/fjarri/70a44c9dafc7f8cbdf6524eb9f02f6c6

fjarri avatar Sep 16 '18 23:09 fjarri

Could you try this branch?

https://gitlab.tiker.net/inducer/pyopencl/merge_requests/48

inducer avatar Sep 16 '18 23:09 inducer

The branch by itself does not help. But I've done some more googling, and it seems that the problem lies in the most recent XCode version (starting from either 9.3 or 9.4). I am not sure how to fix the build for them, but switching to XCode 9.2 plus using the branch makes everything build successfully.

fjarri avatar Sep 17 '18 01:09 fjarri