I'm trying to build and apply a pass on OSX using llvm 3.8.
I installed llvm 3.8 using brew with this formula: $brew install llvm38
Inside the pass I have the following:
static RegisterPass<SwiftPass> X("pass", "My Pass");
My Makefile to build the pass looks like this:
LIB_NAME = pass$(SUFIX)
LDFLAGS = $(shell $(LLVM_PATH)llvm-config --ldflags)
CXXFLAGS = -g -Wall -fno-rtti -fPIC -std=c++11 -shared -dynamiclib $(shell $(LLVM_PATH)llvm-config --cxxflags --system-libs --libs core executionengine interpreter mc support nativecodegen)
COMPILER = clang++
all: $(LIB_NAME)
$(LIB_NAME): $(OBJ)
$(COMPILER) $(CXXFLAGS) $(LDFLAGS) $^ -o $@
If gives me a few clang: warning: -l[some lib]: 'linker' input unused
. It also gives me:
clang: warning: argument unused during compilation: '-shared'
clang: warning: argument unused during compilation: '-dynamiclib'
But it outputs a .dylib and .o so I proceed to try it out. So now that I have a pass I can apply it to my .bc file and for this I use a Makefile like this (I omited the definitions for brevity):
$(LLVM_OPT) -load $(PASSFILE) $(PASSNAME) $(NAME).bc -o $(NAME).afterMyPass.bc
This translates to:
opt -load pass.dylib -pass int.bc -o int.afterMyPass.bc
And returns this to me:
opt: Unknown command line argument '-pass'. Try: '/usr/local/Cellar/llvm38/3.8.0/lib/llvm-3.8/bin/opt -help'
opt: Did you mean '-slsr'?
make: *** [pass] Error 1
My guess is that this is caused by the unused arguments during compilation but I don't know why they are unused in the first place since they are required to build a shared library.
What am I doing wrong and how can I fix this?