jakeret / hope

HOPE: A Python Just-In-Time compiler for astrophysical computations
GNU General Public License v3.0
382 stars 28 forks source link

compilation fails with python3 #8

Closed xantares closed 9 years ago

xantares commented 9 years ago

Hi, on my box a basic example under python3 (3.4.2) does not work:

In [1]: from hope import jit
4.9.1

In [2]: @jit                
def sum(x, y):
        return x + y
   ...: 

In [3]: sum(4,8)            
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
running build_ext
building 'sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0' extension
C compiler: gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC

compile options: '-I/usr/lib/python3.4/site-packages/numpy/core/include -I/usr/include/python3.4m -c'
extra options: '-Wall -Wno-unused-variable -std=c++11'
gcc: /tmp/hopexz2jayp3/sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0.cpp
g++ -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro /tmp/hopexz2jayp3/sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0.o -L/usr/lib -lpython3.4m -o /tmp/hopexz2jayp3/sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0.cpython-34m.so

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-3-2315bad740f1> in <module>()
----> 1 sum(4,8)

/home/xantares/projects/hope/hope/_wrapper.py in _hope_callback(*args)
     64 
     65         def _hope_callback(*args):
---> 66             return self(*args) if self.cache is None else self.cache(*args)
     67         self.callback = _hope_callback
     68         setattr(cache, str(id(self.callback)), fkt)

/home/xantares/projects/hope/hope/_wrapper.py in __call__(self, *args)
     97                 fp.write(code)
     98 
---> 99             _compile(tempfolder, localfilename, self.fkt.__name__)
    100 
    101             self._store_state(tempfolder, localfilename)

/home/xantares/projects/hope/hope/_wrapper.py in _compile(target, localfilename, fkt_name)
    248     if not os.path.isfile(os.path.join(target, "{0}.so".format(localfilename))) or out.find("error:") > -1:
    249         print(out)
--> 250         raise Exception("Error compiling function {0} (compiled to {1})".format(fkt_name, target))
    251 
    252     #TODO: add test case

Exception: Error compiling function sum (compiled to /tmp/hopexz2jayp3)

In [4]: 
Do you really want to exit ([y]/n)? 
xantares@archlinux:~/projects/hope$ g++ -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro /tmp/hopexz2jayp3/sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0.o -L/usr/lib -lpython3.4m -o /tmp/hopexz2jayp3/sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0.cpython-34m.so
g++: error: /tmp/hopexz2jayp3/sum_900a4b7729fa81ded8e12217d97f52982df0978d23240cb0daa79505_0.o: No such file or directory
iankronquist commented 9 years ago

Looking at the error message I don't see any compile time errors. However, this error can also be triggered if this jitted function has already been cached. Have you tried running make clean-build and running the script again?

xantares commented 9 years ago

I just retried this morning after booting up. It definitively fails, it's fine with python2.

cosmo-ethz commented 9 years ago

@iankronquist Even if the function would have been cached before the package should either load the cached version or trigger a recompilation in case the signature, function body or argument types would have changed.

This, however, seems to be something different. It’s something we have to look into it.

xantares commented 9 years ago

ok now

cosmo-ethz commented 9 years ago

After a lot of investigation it's clear to my why this used to fail. On Linux with Py34 it seems that setuptoolsappends cpython-34m. to the shared object library file name. This doesn't occur on Mac OSX nor with Py27. It's fixed now in HOPE but would be interessting to know why this happens.