title: Building and using a pass for LLVM 3.8 on OSX
body: <p>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: <code>$brew install llvm38</code>
  Inside the pass I have the following:</p>
  
  <pre><code>static RegisterPass&lt;SwiftPass&gt; X("pass", "My Pass");
  </code></pre>
  
  <p>My Makefile to build the pass looks like this:</p>
  
  <pre><code>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 $@
  </code></pre>
  
  <p>If gives me a few <code>clang: warning: -l[some lib]: 'linker' input unused</code>. It also gives me:</p>
  
  <pre><code>clang: warning: argument unused during compilation: '-shared'
  clang: warning: argument unused during compilation: '-dynamiclib'
  </code></pre>
  
  <p>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):</p>
  
  <pre><code>$(LLVM_OPT) -load $(PASSFILE) $(PASSNAME) $(NAME).bc -o $(NAME).afterMyPass.bc
  </code></pre>
  
  <p>This translates to:</p>
  
  <pre><code>opt -load pass.dylib -pass int.bc -o int.afterMyPass.bc
  </code></pre>
  
  <p>And returns this to me:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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. </p>
  
  <p>What am I doing wrong and how can I fix this?</p>