I’m working though [http://llvm.org/docs/WritingAnLLVMPass.html][1], trying to write a very simple pass. I’ve written the pass and compiled it (thanks in part to the Stackoverflow community) but now I’m having trouble running it…
The documentation reads:
To test it, follow the example at the end of the Getting Started Guide
to compile “Hello World” to LLVM. We can now run the bitcode file
(hello.bc) for the program through our transformation like this (or
course, any bitcode file will work):$ opt -load ../../../Debug+Asserts/lib/Hello.so -hello < hello.bc >
/dev/null Hello: __main Hello: puts Hello: main The ‘-load’ option
specifies that ‘opt’ should load your pass as a shared object, which
makes ‘-hello’ a valid command line argument (which is one reason you
need to register your pass). Because the hello pass does not modify
the program in any interesting way, we just throw away the result of
opt (sending it to /dev/null).
However when I run the command I get the following issue:
mymachine$./opt -load ../../../Debug+Asserts/lib/Hello.so -hello < hello.bc > /dev/null
Error opening '../../../Debug+Asserts/lib/Hello.so':
dlopen(../../../Debug+Asserts/lib/Hello.so, 9): image not found
-load request ignored. opt: Unknown command line argument '-hello'.
Try: './opt -help' opt: Did you mean '-help'?
Any ideas? I’m running OSX and I suspect that is part of the issue…
It turns out the the command I wanted (from the bin directory) was:
and I understand the .dylib is the OSX equivalent of .so – but this was largely guesswork…