<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 17, 2016, at 6:45 PM, PeiLIU via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi, I have some questions about the compilation of the llvm.<div class="">First,  why the majority of the results of compilation are static library ( *.a files in the $(LLVM_HOME)/Release+Asserts/lib/), Why don't generate dynamic link library (.so files in the directory).</div></div></div></blockquote><div><br class=""></div><div>We can turn the question around: why would we? ;)</div><div>Dynamic library are making the compiler really slower, that’s the main reason I believe.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""> The exception is the file libLTO.a and libLTO.so, why the library LTO were generated for static and dynamic both?</div></div></div></blockquote><div><br class=""></div><div>Are you sure it is libLTO.a and not libLLVMLTO.a?</div><div>These are different: libLLVMLTO.a contains only the LTO API, while libLTO.so contains all of LLVM and the LTO API in order for linkers to dynamically load LLVM to perform LTO.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""> How to control the generation of the library file, could it be controlled in the file Makefile.config? One item of the Makefile.config is as follow.</div><div class=""><div class=""><br class=""></div><div class=""># Do we want to build a shared library and link the tools with it?</div><div class="">ENABLE_SHARED := 0</div></div></div></div></blockquote><div><br class=""></div><div>I believe you want the CMake option -DBUILD_SHARED_LIBS=ON</div><div><br class=""></div><div>See the doc for the various configuration around shared libraries: <a href="http://www.llvm.org/docs/CMake.html" class="">http://www.llvm.org/docs/CMake.html</a></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Second, I followed the pass specification of the llvm (<a href="http://llvm.org/docs/WritingAnLLVMPass.html" class="">http://llvm.org/docs/WritingAnLLVMPass.html</a>) and wrote my own pass to do something. However, why did it generate the dynamic library (*.so) just like the example of the specification of LLVMHello.so rather than a static library because it used the same Makefile.config file with the build of the LLVM?</div></div></div></blockquote><div><br class=""></div><div>I assume you mean CMakeList.txt instead of Makefile.config?</div><div><br class=""></div><div>The important part is that to have your pass dynamically loadable, it is configured with `add_llvm_loadable_module` in your cmake file, while LLVM libraries are added with add_llvm_library.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Third, How can I get my own pass build together with the LLVM, generate *.a file in the directory of $(LLVM_HOME)/Release+Asserts/lib/?</div></div></div></blockquote><div><br class=""></div><div>I suggest that you start with this tutorial from last year Dev Meeting: <a href="http://llvm.org/devmtg/2015-10/#tutorial1" class="">http://llvm.org/devmtg/2015-10/#tutorial1</a> (slides and video are online).</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div></div></body></html>