clang vs gcc: installing python-qpid-proton
I need to install python-qpid-proton in a Python virtualenv with pip. The behavior is different when using gcc to install it versus using clang. With clang the proton library does not build as it can't find openssl/ssl.h. It builds if DYLD_LIBRARY_PATH=/opt/local/lib is exported. After a successful build using clang, proton can't find SSL libraries. With gcc the proton library builds successfully and finds the right (MacPorts provided) SSL libraries. I'm using python3.6, gcc6, and clang4.0 from MacPorts. More details of steps where it works and where it doesn't work are provided below. After some digging I came across this observation: gcc's include search paths have /opt/local/include but clang's do not. ~/tmp $ `/opt/local/bin/gcc -print-prog-name=cc1plus` -v ignoring nonexistent directory "/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.3.0/../../../../../x86_64-apple-darwin16/include" #include "..." search starts here: #include <...> search starts here: /opt/local/include/gcc6/c++/ /opt/local/include/gcc6/c++//x86_64-apple-darwin16 /opt/local/include/gcc6/c++//backward /opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.3.0/include /opt/local/include /opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.3.0/include-fixed /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. ^C ~/tmp $ echo | /opt/local/bin/clang++ -Wp,-v -stdlib=libc++ -x c++ - -fsyntax-only clang -cc1 version 4.0.1 based upon LLVM 4.0.1 default target x86_64-apple-darwin16.6.0 ignoring nonexistent directory "/usr/include/c++/v1" ignoring nonexistent directory "/usr/local/include" #include "..." search starts here: #include <...> search starts here: /opt/local/libexec/llvm-4.0/bin/../include/c++/v1 /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.1/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. Questions: * Is this the main issue that clang does not work? * How can I get python-qpid-proton to build and install with clang? Thanks, Hamza Sheikh Twitter: @aikchar === Does Not Build === Last login: Fri Jul 28 10:51:58 on ttys003 ~/tmp $ which python3.6 /opt/local/bin/python3.6 ~/tmp $ which clang /opt/local/bin/clang ~/tmp $ python3.6 -m virtualenv clang-no-build-virtualenv Using base prefix '/opt/local/Library/Frameworks/Python.framework/Versions/3.6' New python executable in ${HOME}/tmp/clang-no-build-virtualenv/bin/python3.6 Also creating executable in ${HOME}/tmp/clang-no-build-virtualenv/bin/python Installing setuptools, pip, wheel...done. ~/tmp $ source clang-no-build-virtualenv/bin/activate (clang-no-build-virtualenv) ~/tmp $ env CC=clang pip install --no-cache python-qpid-proton Collecting python-qpid-proton Downloading python-qpid-proton-0.17.0.tar.gz (389kB) 100% || 399kB 2.1MB/s Installing collected packages: python-qpid-proton Running setup.py install for python-qpid-proton ... error Complete output from command ${HOME}/tmp/clang-no-build-virtualenv/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/pip-build-hf6qoms6/python-qpid-proton/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/pip-8zzchop4-record/install-record.txt --single-version-externally-managed --compile --install-headers ${HOME}/tmp/clang-no-build-virtualenv/bin/../include/site/python3.6/python-qpid-proton: running install running build running build_ext running configure Did not find libqpid-proton via pkg-config: Building the bundled proton-c sources into the extension Using openssl version 1.0.2l (found via pkg-config) creating build creating build/temp.macosx-10.12-x86_64-3.6 creating build/temp.macosx-10.12-x86_64-3.6/var creating build/temp.macosx-10.12-x86_64-3.6/var/folders creating build/temp.macosx-10.12-x86_64-3.6/var/folders/qf creating build/temp.macosx-10.12-x86_64-3.6/var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp creating build/temp.macosx-10.12-x86_64-3.6/var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T cc -c /var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/clock_gettimec8sguqyd.c -o build/temp.macosx-10.12-x86_64-3.6/var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/clock_gettimec8sguqyd.o /var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/clock_gettimec8sguqyd.c:1:1: warning: return type defaults to 'int' [-Wimplicit-int] main (int argc, char **argv) { ^~~~ /var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/clock_gettimec8sguqyd.c: In function 'main': /var/folders/qf/tzk5k9d92gndyjvgstv_cfz4gp/T/clock_gettimec8sguqyd.c:2:5: warning: implicit declaration of function 'clock_gettime' [-Wimplicit-function-declaration] clock_gettime(); ^ cc
Re: clang vs gcc: installing python-qpid-proton
It's news to me that MacPorts gcc has /opt/local/include in its default search path, and my first response is that I would not want it to do that, especially if as you say MacPorts clang doesn't do the same thing. So I would consider this a bug in MacPorts gcc that I would want to fix. Does anyone know how to fix it? Yes, that seems like the reason why MacPorts gcc is able to find MacPorts openssl and clang is not. The usual way to get a compiler to find MacPorts software is to supply -isystem/opt/local/include in CPPFLAGS and -L/opt/local/lib in LDFLAGS. Different build systems may have different requirements. I'm not familiar with how pip does it.
Re: clang vs gcc: installing python-qpid-proton
On Fri, Jul 28, 2017 at 12:10 PM, Ryan Schmidt wrote: > The usual way to get a compiler to find MacPorts software is to supply > -isystem/opt/local/include in CPPFLAGS and -L/opt/local/lib in LDFLAGS. > Different build systems may have different requirements. I'm not familiar > with how pip does it. Thank you. This fixed the issue and both clang and gcc behave the same way: Proton gets installed and finds the right SSL libraries. [0] https://trac.macports.org/ticket/40656 (clang-may-work-virtualenv) ~/tmp $ env CC=clang CPPFLAGS='-isystem/opt/local/include' LDFLAGS='-L/opt/local/lib' pip install --no-cache python-qpid-proton Collecting python-qpid-proton Downloading python-qpid-proton-0.17.0.tar.gz (389kB) 100% || 399kB 3.6MB/s Installing collected packages: python-qpid-proton Running setup.py install for python-qpid-proton ... done Successfully installed python-qpid-proton-0.17.0 (clang-may-work-virtualenv) ~/tmp $ python Python 3.6.2 (default, Jul 20 2017, 14:03:58) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import proton >>> from proton.utils import BlockingConnection, SyncRequestResponse >>> SyncRequestResponse(BlockingConnection('amqps://USERNAME_REDACTED:PASSWORD_REDACTED@IP_REDACTED:5672/qmf.default.direct', >>> timeout=5, target='qmf.default.direct', sasl_enabled=True, >>> allowed_mechs='PLAIN'), 'qmf.default.direct') >>> Assertion failed: (r == 0), function k5_mutex_lock, file ../../include/k5-thread.h, line 366. Abort trap: 6 (clang-may-work-virtualenv) ~/tmp $ otool -L clang-may-work-virtualenv/lib/python3.6/site-packages/_cproton.cpython-36m-darwin.so clang-may-work-virtualenv/lib/python3.6/site-packages/_cproton.cpython-36m-darwin.so: /opt/local/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) /opt/local/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) /opt/local/lib/libsasl2.dylib (compatibility version 3.0.0, current version 3.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2) (gcc-may-work-virtualenv) ~/tmp $ env CC=gcc CPPFLAGS='-isystem/opt/local/include' LDFLAGS='-L/opt/local/lib' pip install --no-cache python-qpid-proton Collecting python-qpid-proton Downloading python-qpid-proton-0.17.0.tar.gz (389kB) 100% || 399kB 3.1MB/s Installing collected packages: python-qpid-proton Running setup.py install for python-qpid-proton ... done Successfully installed python-qpid-proton-0.17.0 (gcc-may-work-virtualenv) ~/tmp $ python Python 3.6.2 (default, Jul 20 2017, 14:03:58) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import proton >>> from proton.utils import BlockingConnection, SyncRequestResponse >>> SyncRequestResponse(BlockingConnection('amqps://USERNAME_REDACTED:PASSWORD_REDACTED@IP_REDACTED:5672/qmf.default.direct', >>> timeout=5, target='qmf.default.direct', sasl_enabled=True, >>> allowed_mechs='PLAIN'), 'qmf.default.direct') >>> Assertion failed: (r == 0), function k5_mutex_lock, file ../../include/k5-thread.h, line 366. Abort trap: 6 (gcc-may-work-virtualenv) ~/tmp $ otool -L gcc-may-work-virtualenv/lib/python3.6/site-packages/_cproton.cpython-36m-darwin.so gcc-may-work-virtualenv/lib/python3.6/site-packages/_cproton.cpython-36m-darwin.so: /opt/local/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) /opt/local/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) /opt/local/lib/libsasl2.dylib (compatibility version 3.0.0, current version 3.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2) /opt/local/lib/libgcc/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)