<div dir="ltr">Yeah, that is likely due to a difference between the version of LLVM you built LLVMHello.so with and the version used in Android.<div><br></div><div>IIRC, the version used in the toolchain is at prebuilts/clang/linux-x86/host/3.5/bin/clang in the latest version of the Android tree, and it's built from the code in external/clang and external/llvm. The first thing I'd try to do in your case is to build LLVMHello.so from those sources and see if you can get it to run using the toolchain version of clang directly. If you can, then you can port your optimization pass into external/llvm and build it there.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 2:57 PM, Joshua Tuttle <span dir="ltr"><<a href="mailto:jtuttle@i-a-i.com" target="_blank">jtuttle@i-a-i.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Tom,</p>
<p><br>
</p>
<p>Thanks for the reply.</p>
<p><br>
</p>
<p>I have tried the following options in Android.mk</p>
<p><br>
</p>
<p>LOCAL_CLANG := true<br>
<br>
LOCAL_CFLAGS := -Xclang -load -Xclang /home/josh/llvm.tan/lib/LLVMHello.so (I'm using this pass just to see if it will run through)
</p>
<p><br>
</p>
<p>The error I get when tying to compile is as follows:</p>
<p><br>
</p>
<p>target thumb C++: keystore <= system/security/keystore/keystore.cpp<br>
target thumb C++: keystore <= system/security/keystore/keyblob_utils.cpp<br>
error: unable to load plugin '/home/josh/llvm.tan/lib/LLVMHello.so': '/home/josh/llvm.tan/lib/LLVMHello.so: undefined symbol: _ZNK4llvm4Pass11getPassNameEv'<br>
make: *** [out/target/product/nitrogen6x/obj/EXECUTABLES/keystore_intermediates/keystore.o] Error 1<br>
make: *** Waiting for unfinished jobs....<br>
</p>
<p>error: unable to load plugin '/home/josh/llvm.tan/lib/LLVMHello.so': '/home/josh/llvm.tan/lib/LLVMHello.so: undefined symbol: _ZNK4llvm4Pass11getPassNameEv'<br>
make: *** [out/target/product/nitrogen6x/obj/EXECUTABLES/keystore_intermediates/keyblob_utils.o] Error 1<br>
</p>
<p><br>
</p>
<p>I'm assuming this error message is related to some kind of linker problem, but I am not sure why, considering this pass does nothing more than print out function names to the terminal. If I run the compile with out the CFLAGS, it works fine.
<br>
</p>
<p><br>
</p>
<p><br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Tom Roeder <<a href="mailto:tmroeder@google.com" target="_blank">tmroeder@google.com</a>><br>
<b>Sent:</b> Friday, July 18, 2014 5:45 PM<br>
<b>To:</b> Joshua Tuttle<br>
<b>Cc:</b> <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [LLVMdev] Running an LLVM pass during an android compile</font>
<div> </div>
</div><div><div class="h5">
<div>
<div dir="ltr">In Android.mk, have you tried the following options?
<div><br>
</div>
<div>LOCAL_CLANG := true</div>
<div>LOCAL_CFLAGS := <some flags here for clang, e.g., -flto></div>
<div>LOCAL_LDFLAGS := <some flags for clang at link time, e.g., -flto -Wl,--plugin-opt=-mattr=+aes></div>
<div><br>
</div>
<div>If these don't work, could you be more specific about the errors that you get?</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Tom</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Fri, Jul 18, 2014 at 9:04 AM, Joshua Tuttle <span dir="ltr">
<<a href="mailto:jtuttle@i-a-i.com" target="_blank">jtuttle@i-a-i.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>We have developed and tested an optimization pass using LLVM, and have been able to build other software such as gzip while running our pass by passing "clang" and "-Xclang -load -Xclang <path to .so>" as configure options. Now we would like to try and build
 android while running our pass only on certain files. It seems that android has its own version of LLVM built into it, and we haven't been successful with the aforementioned parameters working in the android makefiles. Does anyone know what is necessary to
 get the android version of LLVM to run our pass?</p>
<p><br>
</p>
<p>Thanks,</p>
<p>Josh<br>
</p>
</div>
<div style="font-size:8pt"><br>
<br>
<br>
<hr>
This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express
 written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation,
 Inc. </div>
</div>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>        
<a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div></div></div>
</div><div><div class="h5">
<div style="font-size:8pt"><br>
<br>
<br>
<hr>
This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express
 written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation,
 Inc. </div>
</div></div></div>

</blockquote></div><br></div>