Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write llvm pass in Mac OS X 10.9

Tags:

macos

llvm

I built my pass on Linux and it worked there correctly. Now when I brought in my code to Mac OS X 10.9 on Mac Airbook, its not working anymore. I am describing below the steps I took for building my llvm pass.

My source tree is llvm-3.4 and llv-3.4/tools/clang-3.4

I ran ./configure --prefix=/some-path --enable-targets=host which was successful.

Then I ran make && make install which completed without any errors.

I exported the bin path export PATH=/some-path/bin:$path and checked for which clang which opt and they pointed to my installation.

Now when I tried to load hello pass opt -load /some-path/lib/LLVMHello.dylib -hello <fac.bc >/dev/null I get the following error

Error opening '/some-path/lib/LLVMHello.dylib': dlopen(/some-path/lib/LLVMHello.dylib, 9): Symbol not found: __ZN4llvm12FunctionPass17assignPassManagerERNS_7PMStackENS_15PassManagerTypeE Referenced from: /some-path/lib/LLVMHello.dylib Expected in: flat namespace in /some-path/lib/LLVMHello.dylib -load request ignored. opt: Unknown command line argument '-hello'. Try: '/some-path/bin/opt -help' opt: Did you mean '-help'?

Can someone help me fix this issue or at least point in the right direction.

like image 388
Baruntar Avatar asked Nov 11 '22 12:11

Baruntar


1 Answers

In my case, the dynamic LLVM library, which is required for dynamically loaded passes, was missing. I solved it by configuring LLVM with --enable-shared. I also had --enable-keep-symbols set, but I don't think this is necessary. The full configure command I used:

./configure --enable-shared --enable-keep-symbols

I know I'm a bit late with the answer, but I recently ran into the same problem. And since I spent quite some time solving the issue, I wanted to pass on my findings. Hope it helps.

Cheers, Marcus

like image 146
Marcus Avatar answered Nov 15 '22 13:11

Marcus