[llvm-dev] Questions about the methods of compilation.
Mehdi Amini via llvm-dev
llvm-dev at lists.llvm.org
Thu Nov 17 23:56:21 PST 2016
> On Nov 17, 2016, at 6:45 PM, PeiLIU via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi, I have some questions about the compilation of the llvm.
> 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).
We can turn the question around: why would we? ;)
Dynamic library are making the compiler really slower, that’s the main reason I believe.
> The exception is the file libLTO.a and libLTO.so, why the library LTO were generated for static and dynamic both?
Are you sure it is libLTO.a and not libLLVMLTO.a?
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.
> 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.
> # Do we want to build a shared library and link the tools with it?
> ENABLE_SHARED := 0
I believe you want the CMake option -DBUILD_SHARED_LIBS=ON
See the doc for the various configuration around shared libraries: http://www.llvm.org/docs/CMake.html
> Second, I followed the pass specification of the llvm (http://llvm.org/docs/WritingAnLLVMPass.html <http://llvm.org/docs/WritingAnLLVMPass.html>) 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?
I assume you mean CMakeList.txt instead of Makefile.config?
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.
> 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/?
I suggest that you start with this tutorial from last year Dev Meeting: http://llvm.org/devmtg/2015-10/#tutorial1 (slides and video are online).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev