Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building and running llvm-py on Mac OS X

I was trying to build llvm-py on Mac OS X.

This is what I tried to do, I needed to download 11vm-2.7, and the README file has this comment: Make sure '--enable-pic' is passed to LLVM's 'configure'

  1. Download llvm 2.7.
  2. Build llvm 2.7: Run ./configure --prefix=LLVM_DIRECTORY --enable-pic
  3. Download llvm-py 0.6.
  4. Build llvm-py 0.6: Run python setup.py build --llvm-config=LLVM_DIRECTORY/bin/llvm-config

Everything compiles without errors, but when I tried to run test file, I got this error message.

ImportError: 'dlopen(/Library/Python/2.7/site-packages/llvm/_core.so, 2): Symbol not found: __ZTVN4llvm16ExtractValueInstE\n Referenced from: /Library/Python/2.7/site-packages/llvm/_core.so\n Expected in: flat namespace\n in /Library/Python/2.7/site-packages/llvm/_core.so'

The message error seems to say that there is a missing function "llvmExtractValueInst" with flat namemspace issue. What's wrong with this?

In llvm 2.7, the Makefile.rules has this line

SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \ -dynamiclib

I tried to remove the flat_namespace, but I got compilation error.

ADDED

Following locojay's answer, I could build brew and llvmpy.

export REQUIRES_RTTI=1
brew install llvm --rtti
sudo pip install git+https://github.com/llvmpy/llvmpy

However, when I tried to execute the examples in the test directory, I still got different kind of error-

test> python example.py 
Traceback (most recent call last):
  File "example.py", line 4, in <module>
    from llvm import *
  File "/Library/Python/2.7/site-packages/llvm/__init__.py", line 11, in <module>
    from llvm import _core
ImportError: dlopen(/Library/Python/2.7/site-packages/llvm/_core.so, 2): Symbol not found: __ZN4llvm10DataLayout2IDE
  Referenced from: /Library/Python/2.7/site-packages/llvm/_core.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/llvm/_core.so 

This is the result when I run otool -L /Library/Python/2.7/site-packages/llvm/_core.so

/Library/Python/2.7/site-packages/llvm/_core.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
like image 886
prosseek Avatar asked Jan 30 '12 02:01

prosseek


People also ask

Does macOS have LLVM?

All of Apple's operating systems, iOS, macOS, tvOS and watchOS, are built with LLVM technologies.

Does Xcode include LLVM?

Xcode also includes the LLVM GCC compiler, which uses the GCC compiler front end for maximum compatibility, and the LLVM back end, which takes advantage of LLVM's advanced code generator.


1 Answers

have a look @ docs of llvmpy

For LLVM 3.2, make sure that environment variable REQUIRES_RTTI=1 is defined when running make. Otherwise, you may see "undefined symbol: _ZTIN4llvm24PassRegistrationListenerE". Please refer to http://llvm.org/docs/Packaging.html#c-features for details.

so for me this worked

export REQUIRES_RTTI=1
brew install llvm --rtti
pip install git+https://github.com/llvmpy/llvmpy

I guess one can always give anaconda a try in the worst case....

like image 166
jassinm Avatar answered Sep 23 '22 19:09

jassinm