cython可以用icc编译吗?

Can cython be compiled with icc?

我正在尝试在 Ubuntu 14.04 上使用 icc 编译器从源代码构建 cython,因为我的 python 是使用 Intel icc 编译器编译的。

当我尝试使用 pip3 install cython 然后 运行 cython 安装 cython 时出现以下错误

Traceback (most recent call last):
File "/usr/local/bin/cython", line 9, in <module>
load_entry_point('Cython==0.24', 'console_scripts', 'cython')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.4/dist-packages/Cython/Compiler/Main.py", line 28, in <module>
from .Scanning import PyrexScanner, FileSourceDescriptor
ImportError: /usr/local/lib/python3.4/dist-packages/Cython/Compiler/Scanning.cpython-34m.so: undefined symbol: __intel_sse2_strchr 

如何使用 icc 编译器从源代码安装 cython?

我试过了,还是不行

来自cython目录(从github下载)

python3.4setup.pyCC=icc

我收到以下消息 -

/home/aa/libPython/cython/Cython/Distutils/build_ext.py:20: UserWarning:    
Cython.Distutils.build_ext does not properly handle dependencies and is deprectated. Use Cython.Build.build_ext instead.
"Cython.Distutils.build_ext does not properly handle dependencies "
 Unable to find pgen, not compiling formal grammar.
 invalid command name 'CC=icc'

CC=icc 不足以用 icc 构建。您还应该 link 与 icc ( icc 将其内部库添加到 ELF 文件),因此为您的 setup.py 找到 linker 变量的名称,可能 LD 并将其设置为 icc LD=icc(默认可能是 gcc)。

其实是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))

因此,使用 icc 的 cython 的正确构建应该使用 CC=icc LINKCC=icc,不知道如何将变量传递到 setup.py,检查 How to tell distutils to use gcc? 或尝试

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

更新:根据来自 gansub 的消息,“LDSHARED=icc”环境。变量将有助于构建 cython:“您需要设置环境变量 LDSHARED=icc” - https://chat.whosebug.com/transcript/message/31231907#31231907 and

来自 Syrtis Major 的更新:Nguyen 的文章“Cython 中的线程并行*”https://software.intel.com/en-us/articles/thread-parallelism-in-cython,Loc Q(英特尔),2016 年 12 月 15 日,推荐 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