5

I was able to successfully build cython on Ubuntu 14.04 from source as explained in this SE question/answer Compiling cython From source with icc and I downloaded the source code from here - Cython source code download.

The command to compile cython is

CC=icc LINKCC=icc python3.4 setup.py build

I am enclosing the build log. It is STILL using gcc for linking. Here is a sample of build log.

It appears CC=icc LINKCC=icc does NOT seem to change the linker to icc. It is still using x86_64-linux-gnu-gcc. When I set the environmental variable LDFLAGS = -lirc the environmental variable is being passed to gcc and not to icc. Also when I put print statements in BuildExecutable.py they are not getting called.

icc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c /home/aswin/libPython/Cython-0.24/Cython/Plex/Scanners.c -o build/temp.linux-x86_64-3.4/home/aswin/libPython/Cython-0.24/Cython/Plex/Scanners.o
icc: command line warning #10006: ignoring unknown option '-fwrapv'
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/Cython
creating build/lib.linux-x86_64-3.4/Cython/Plex
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -lirc -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/home/aswin/libPython/Cython-0.24/Cython/Plex/Scanners.o -o build/lib.linux-x86_64-3.4/Cython/Plex/Scanners.cpython-34m.so

How do I fix it ?

Community
  • 1
  • 1
gansub
  • 1,164
  • 3
  • 20
  • 47

2 Answers2

9

You need to override the linker

by setting export LDSHARED="icc -shared". That generates the icc linker. Here is an example of the build log by typing

CC=icc python3.4 setup.py build_ext

Alternatively you can also do the same by typing

LDSHARED="icc -shared" CC=icc python3.4 setup.py build_ex

icc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c /home/a/libPython/Cython-0.24/Cython/Plex/Scanners.c -o build/temp.linux-x86_64-3.4/home/a/libPython/Cython-0.24/Cython/Plex/Scanners.o
icc: command line warning #10006: ignoring unknown option '-fwrapv'
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/Cython
creating build/lib.linux-x86_64-3.4/Cython/Plex
icc -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/home/a/libPython/Cython-0.24/Cython/Plex/Scanners.o -o build/lib.linux-x86_64-3.4/Cython/Plex/Scanners.cpython-34m.so
cythoning /home/a/libPython/Cython-0.24/Cython/Plex/Actions.py to /home/a/libPython/Cython-0.24/Cython/Plex/Actions.c
gansub
  • 1,164
  • 3
  • 20
  • 47
  • gansub, did you set `LDSHARED="icc -shared"` environment variable? How? As `LDSHARED="icc -shared" CC=icc python3.4 setup.py build_ext` ? – osgx Jun 20 '16 at 03:29
  • Can you add this command to your answer? It can be also set with adding it before command LDSHARED=smth.. (just to make answer more useful and clear for future visitors) – osgx Jun 20 '16 at 03:32
  • gansub, is it not linked, or not found? Can you run ldd on some library/executable file with the problem? If it is linked but "not found", You may add path of lib to /etc/ld.so.conf or to LD_LIBRARY_PATH or to [rpath option](https://en.wikipedia.org/wiki/Rpath) of linking step (which is "icc -shared", add the options) – osgx Jun 20 '16 at 11:24
0

You could try to add -static-intel to link options so that all Intel specific functions will be static-linked.

kangshiyin
  • 9,681
  • 1
  • 17
  • 29
  • I read the code link in your prev question. LDFLAS may not be the correct one. but you could check if there's anything useful by `python setup.py --help build_ext` – kangshiyin Jun 19 '16 at 09:30
  • I ran that command and I see extensions for compilers such as --compiler but do not see one for linking – gansub Jun 19 '16 at 09:45
  • I put print statements in this file https://github.com/cython/cython/blob/master/Cython/Build/BuildExecutable.py but this is NOT getting called – gansub Jun 19 '16 at 09:46