Can cython be compiled with icc?

后端 未结 1 867
攒了一身酷
攒了一身酷 2021-01-13 02:19

I am trying to build cython from source with icc compiler on Ubuntu 14.04 as my python is compiled with Intel icc compiler.

When I tried to install cython using

相关标签:
1条回答
  • 2021-01-13 03:02

    CC=icc is not enough to build with icc. You should also link with icc (https://stackoverflow.com/a/10891764/196561; icc will add its internal libraries to ELF file), so find name of linker variable for your setup.py, probably LD and set it to icc too LD=icc (default is probably gcc).

    Actually it is LINKCC - https://github.com/cython/cython/blob/970c2fc0e676ca22016e14147ada0edba937dc6b/Cython/Build/BuildExecutable.py

    CC = get_config_var('CC', os.environ.get('CC', ''))
    CFLAGS = get_config_var('CFLAGS') + ' ' + os.environ.get('CFLAGS', '')
    LINKCC = get_config_var('LINKCC', os.environ.get('LINKCC', CC))
    

    So, correct build for cython with icc should be with CC=icc LINKCC=icc, don't know how variables should be passed into setup.py, check How to tell distutils to use gcc? or try

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

    Update: According to message from gansub, "LDSHARED=icc" env. variable will help to build cython: "You need to set the environment variable LDSHARED=icc" - http://chat.stackoverflow.com/transcript/message/31231907#31231907 and https://stackoverflow.com/a/37914227

    Update from Syrtis Major: There is article "Thread Parallelism in Cython*" https://software.intel.com/en-us/articles/thread-parallelism-in-cython by Nguyen, Loc Q (Intel), December 15, 2016 with recommendation of LDSHARED="icc -shared" CC=icc:

    To explicitly use the Intel icc to compile this application, execute the setup.py file with the following command:

     $ LDSHARED="icc -shared" CC=icc python setup.py build_ext --inplace
    
    0 讨论(0)
提交回复
热议问题