pythran: Unable to configure CC and CXX in pythranrc and gcc 7 bug with pythran+numpy
System configuration
- Arch Linux
- gcc-7.1.1 and gcc-5.4.0
- numpy==1.13.0
- pythran==0.8.0
- python==2.7.13
First of all, allow me to rant that it should be mentioned somewhere in the README that pythran only works in a medium version gcc > 4.9 and gcc < 6(??). I lost quite a lot of time trying to pythranize with gcc==4.7.2 and gcc==7.1.1 (super old and super new) - does not work at all (for traceback, see https://paste.pound-python.org/show/bA0TjMrAWP54PcKOU375/ ).Thanks to folks at IRC channel #pythran I was able to figure this out.
Issue
Pythran works when I try
$ CC=gcc-5 CXX=g++-5 pythran nd_local_maxima.py
on the test case.
However when I try to make this choice of compiler permanent by modifying your pythran-linux2.cfg template and putting it in $HOME/.pythranrc as follows:
[compiler]
defines=USE_GMP
undefs=
include_dirs=
libs=gmp gmpxx
library_dirs=
cflags=-std=c++11 -fno-math-errno -w -fwhole-program -fvisibility=hidden
ldflags=-fvisibility=hidden -Wl,-strip-all
blas=cblas
CC=gcc-5
CXX=g++-5
Note that, leaving blas
option empty gave me some other weird error. On running:
$ pythran nd_local_maxima.py -v
yields a type error.
running build_ext
running build_src
build_src
building extension "nd_local_maxima" sources
build_src: building npy-pkg config files
new_compiler returns distutils.unixccompiler.UnixCCompiler
INFO customize UnixCCompiler
customize UnixCCompiler using build_ext
********************************************************************************
distutils.unixccompiler.UnixCCompiler
linker_exe = u'gcc-5'
compiler_so = u'gcc-5 -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fPIC'
archiver = ['ar', 'rc']
preprocessor = u'gcc-5 -E'
linker_so = ['gcc', '-pthread', '-shared', '-Wl,-O1,--sort-common,--as-needed,-z,relro']
compiler_cxx = u'g++-5'
ranlib = None
compiler = u'gcc-5 -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong'
libraries = []
library_dirs = ['/usr/lib']
include_dirs = ['/usr/include/python2.7']
********************************************************************************
new_compiler returns distutils.unixccompiler.UnixCCompiler
INFO customize UnixCCompiler
customize UnixCCompiler using build_ext
********************************************************************************
distutils.unixccompiler.UnixCCompiler
linker_exe = u'gcc-5'
compiler_so = u'gcc-5 -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fPIC'
archiver = ['ar', 'rc']
preprocessor = u'gcc-5 -E'
linker_so = ['gcc', '-pthread', '-shared', '-Wl,-O1,--sort-common,--as-needed,-z,relro']
compiler_cxx = u'g++-5'
ranlib = None
compiler = u'gcc-5 -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong'
libraries = []
library_dirs = ['/usr/lib']
include_dirs = ['/usr/include/python2.7']
********************************************************************************
Traceback (most recent call last):
File "/scratch/avmo/opt/fluidsim-merge/bin/pythran", line 11, in <module>
sys.exit(run())
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/pythran/run.py", line 133, in run
**compile_flags(args))
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/pythran/toolchain.py", line 360, in compile_pythranfile
**kwargs)
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/pythran/toolchain.py", line 331, in compile_pythrancode
**kwargs)
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/pythran/toolchain.py", line 293, in compile_cxxcode
output_binary, **kwargs)
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/pythran/toolchain.py", line 263, in compile_cxxfile
'--build-temp', buildtmp,
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/numpy/distutils/command/build_ext.py", line 206, in run
self._cxx_compiler = compiler.cxx_compiler()
File "/scratch/avmo/opt/fluidsim-merge/lib/python2.7/site-packages/numpy/distutils/ccompiler.py", line 633, in CCompiler_cxx_compiler
cxx.compiler_so = [cxx.compiler_cxx[0]] + cxx.compiler_so[1:]
TypeError: can only concatenate list (not "unicode") to list
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (15 by maintainers)
Commits related to this issue
- Fix for issue #687 — committed to ashwinvis/pythran by ashwinvis 7 years ago
- Python 3 compatible fix for #687 — committed to ashwinvis/pythran by ashwinvis 7 years ago
- Fix for issue #687 Python 3 compatible fix for #687 — committed to ashwinvis/pythran by ashwinvis 7 years ago
- Merge pull request #688 from ashwinvis/master Fix for issue #687 — committed to serge-sans-paille/pythran by serge-sans-paille 7 years ago
… I’ll make a minimal test case out of this and submit it again 😕
Hi @ashwinvis,
Rant accepted. the gcc > 4.9, has documented somewhere here http://pythonhosted.org/pythran/MANUAL.html. I should make this more explicit; The gcc < 6 is a bug, I’ll try to reproduce this.
I’ll investigate the config file error too, that should not happen.