I'm trying to use llvm-py but I get an error when loading llvm.core
(llvm._core is actually the problem):
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import llvm.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/franck/work/python/llvm/2.6/build/lib/python2.6/site-
packages/llvm/core.py", line 38, in <module>
import llvm._core as _core # C wrappers
ImportError: /home/franck/work/python/llvm/2.6/build/lib/python2.6/
site-packages/llvm/_core.so: undefined symbol: ffi_type_sint16
I compiled llvm-py r85 against llvm-2.6 (with --enable-pic), I've
installed everything under
LLVMHOME=/home/franck/work/python/llvm/2.6/build
and extended my environment with
export LD_LIBRARY_PATH=$LLVMHOME/lib
export PYTHONPATH=$LLVMHOME/lib/python2.6/site-packages:
$PYTHONPATH
export PATH=$LLVMHOME/bin:$PATH
I find no missing library in _core.so:
$ ldd build/lib/python2.6/site-packages/llvm/_core.so
linux-gate.so.1 => (0xb80c3000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7580000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7491000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb748c000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7466000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7457000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb72f4000)
/lib/ld-linux.so.2 (0xb80c4000)
My system is Ubuntu 9.04 (Jaunty) with Linux 2.6.28-17.
The same kind of installation using llvm-py-0.5, llvm-2.4 and
Python-2.5, does not have the same problem and work correctly.
Does anyone have an idea? I can send more information if you tell me
what could help.
Many thanks in advance!
Cheers,
Franck
Compiling with python 3.1 on Windows, I get the following warning which is likely the source of your error:
llvm/_core.c(67) : warning C4013: 'PyString_FromString' undefined; assuming extern returning int
AFAIK, the str type as been removed in python 3.x and such code must be changed to either use the bytes type of the unicode type: PyBytes_FromString or PyUnicode_FromString() depending on weither binary data or text is being manipulated.
Though this probably means introducting new wrapping macro for _wrap_obj2str and the like to distinguish between bytes/unicode types. At a first glance, it seems that str is used for text (name, repr...) most of the time, so it is probably easier to introduce a bytes type for the rare occasion where is used. Though, I'm fairly new to llvm-pypy so I don't know if there is any API that actually use bytes...
Also, according to http://docs.python.org/dev/3.0/howto/cporting.html#cporting-howto, the module initialization needs to be modified.
2009/12/23 Franck <franck.p...@gmail.com>
Hi,
I'm currently away, I'll test your patch as I come back and tell you
about the result.
Thanks for your help!
Franck
> I've made the changes I discussed previously and tests seems to work fine,
> though I'm not sure tests exist for all modified API (e.g. module from
> bitcode)...
I've just tested your patch and unfortunately I get exactly the same
error as previously. (Still using Python 2.6, so I didn't use 2to3.py)
Thanks anyway for your help!
Cheers,
Franck
hope it helps,
andyl
Ideed it works! Thanks a lot! :-)
Cheers,
Franck