Import llvm.core failed

126 views
Skip to first unread message

태훈 김

unread,
Sep 26, 2010, 2:50:18 AM9/26/10
to llv...@googlegroups.com
My environment is:

$ uname -a
Darwin taehun-gim-ui-MacBook-Pro.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386

$ port list llvm
llvm                           @2.7            lang/llvm

I installed LLVM with MacPorts. I downloaded llvm-py 0.6 release and built it as in the user guide, but import llvm.core failed.

$ python
Python 2.6.1 (r261:67515, Dec 17 2009, 00:59:15)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import llvm.core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kth3321/.local/lib/python2.6/site-packages/llvm/core.py", line 38, in <module>
    import llvm._core as _core  # C wrappers
ImportError: dlopen(/Users/kth3321/.local/lib/python2.6/site-packages/llvm/_core.so, 2): Symbol not found: _ffi_type_double
  Referenced from: /Users/kth3321/.local/lib/python2.6/site-packages/llvm/_core.so
  Expected in: flat namespace
 in /Users/kth3321/.local/lib/python2.6/site-packages/llvm/_core.so

Looking at setup.py, call_setup reads the output of llvm-config --ldflags, but the result is not used anywhere. On my machine:

$ llvm-config --ldflags
-L/opt/local/lib  -lpthread -lffi -lm

So I changed:

--- setup.py.orig    2010-09-26 15:46:33.000000000 +0900
+++ setup.py    2010-09-26 15:46:45.000000000 +0900
@@ -84,7 +84,7 @@
          'instrumentation', 'ipa', 'ipo', 'transformutils',
          'asmparser', 'linker', 'support'])
 
-    std_libs    = [ 'pthread', 'm', 'stdc++' ]
+    std_libs    = [ 'pthread', 'm', 'stdc++', 'ffi' ]
     if not ("openbsd" in sys.platform or "freebsd" in sys.platform):
         std_libs.append("dl")
 

And after that it worked fine.

How should this be fixed the right way?

- Taehun Kim

Mahadevan R

unread,
Sep 26, 2010, 4:40:15 AM9/26/10
to llvm-py: Python Bindings for LLVM
Hi,

On Sep 26, 11:50 am, 태훈 김 <kth3...@gmail.com> wrote:
> My environment is:
[snip]
> -    std_libs    = [ 'pthread', 'm', 'stdc++' ]
> +    std_libs    = [ 'pthread', 'm', 'stdc++', 'ffi' ]
>      if not ("openbsd" in sys.platform or "freebsd" in sys.platform):
>          std_libs.append("dl")
>
> And after that it worked fine.
>
> How should this be fixed the right way?

Thanks for the report. This is same as reported in issue #29 [1],
I'll apply that patch.

I don't have access to this platform to verify it. Hopefully libffi
is always available.

Thanks,
-Mahadevan.

[1] http://code.google.com/p/llvm-py/issues/detail?id=29

>
> - Taehun Kim
Reply all
Reply to author
Forward
0 new messages