_core.so: undefined symbol

154 views
Skip to first unread message

Franck

unread,
Dec 23, 2009, 6:55:11 AM12/23/09
to llvm-py: Python Bindings for LLVM
Hi,

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

Baptiste Lepilleur

unread,
Dec 25, 2009, 12:49:21 PM12/25/09
to llv...@googlegroups.com
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)...

The patch for C code is attached. It also requires running the 2to3 tool to update python sources (mostly print statement change) in the top-directory:
c:\Python31\Tools\Scripts\2to3.py . -w

---
E:\prg\third-parties\llvm-py-3.1\test>c:\Python31\python.exe intrinsic.py
; ModuleID = 'test'

define void @showme() {
entry:
  %0 = call i32 @llvm.bswap.i32(i32 42)           ; <i32> [#uses=0]
}

declare i32 @llvm.bswap.i32(i32) nounwind readnone

; ModuleID = 'test'

define void @showme() {
entry:
  %0 = call i32 @llvm.bswap.i32(i32 42)           ; <i32> [#uses=0]
}

declare i32 @llvm.bswap.i32(i32) nounwind readnone

define float @mysin(float %x) {
entry:
  %cosx = call float @llvm.cos.f32(float %x)      ; <float> [#uses=1]
  %cos2 = call float @llvm.powi.f32(float %cosx, i32 2) ; <float> [#uses=1]
  %onemc2 = fsub float 1.000000e+000, %cos2       ; <float> [#uses=1]
  %sin = call float @llvm.sqrt.f32(float %onemc2) ; <float> [#uses=1]
  ret float %sin
}

declare float @llvm.sqrt.f32(float) nounwind readonly

declare float @llvm.powi.f32(float, i32) nounwind readonly

declare float @llvm.cos.f32(float) nounwind readonly

---


2009/12/25 Baptiste Lepilleur <baptiste....@gmail.com>
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>
patch-py3k.patch

Baptiste Lepilleur

unread,
Dec 25, 2009, 11:15:35 AM12/25/09
to llv...@googlegroups.com
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,

Franck Pommereau

unread,
Dec 26, 2009, 2:41:13 PM12/26/09
to llv...@googlegroups.com
> 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)...

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

Franck

unread,
Jan 4, 2010, 6:09:09 AM1/4/10
to llvm-py: Python Bindings for LLVM
Hi,

> 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

andyl

unread,
Jan 12, 2010, 9:35:38 AM1/12/10
to llvm-py: Python Bindings for LLVM
Hi Franck, Hi list,
I also suffered from this ffi_type_sint16 error. 1st starting from
python 2.6.2 i just compiled python 2.6.4 and reinstalled llvm-py
without success.
Then I recompiled the llvm with the ./configure option --disable-
libffi and recompiled llvm-py. Now I can import the llvm.core module.

hope it helps,
andyl

Franck Pommereau

unread,
Jan 12, 2010, 12:54:21 PM1/12/10
to llv...@googlegroups.com
> Then I recompiled the llvm with the ./configure option --disable-
> libffi and recompiled llvm-py. Now I can import the llvm.core module.

Ideed it works! Thanks a lot! :-)

Cheers,
Franck

Reply all
Reply to author
Forward
0 new messages