PeiLIU via llvm-dev
2016-Nov-18 02:45 UTC
[llvm-dev] Questions about the methods of compilation.
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). The exception is the file libLTO.a and libLTO.so, why the library LTO were generated for static and dynamic both? 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 Second, I followed the pass specification of the llvm ( 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? 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/? Thank you, very appreciate. Best -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161118/7c17c506/attachment.html>
Mehdi Amini via llvm-dev
2016-Nov-18 07:56 UTC
[llvm-dev] Questions about the methods of compilation.
> 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 := 0I 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). — Mehdi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161117/9afa4843/attachment.html>
Krzysztof Parzyszek via llvm-dev
2016-Nov-18 17:38 UTC
[llvm-dev] Questions about the methods of compilation.
On 11/18/2016 1:56 AM, Mehdi Amini via llvm-dev wrote:> We can turn the question around: why would we? ;)Last time I built LLVM/clang on FreeBSD/PPC64, the code size was too large for it to link. I had to switch to using shared libraries to make it work. I'm guessing that this is not a common issue, but maybe the day is coming... :) -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Apparently Analagous Threads
- [LLVMdev] The Next Win32 File System Problem
- Problem with the way BUILD_SHARED_LIBS=ON handled in llvm 3.8
- [LLVMdev] The Next Win32 File System Problem
- Build libLTO.a instead of libLTO.dylib with Cmake
- [LLVMdev] Patch to enable LLVM to build successfully with shared library support disabled