X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FUsingLibraries.html;h=2973452532960de1b015416aac5d715bbe207267;hb=f8520d564c095e3ee278090b605c4b827604c817;hp=6152f3ac91821054e7dcf62e66f06d29c96f6371;hpb=2161834d013f527b734950f8f73606233be1bba4;p=oota-llvm.git diff --git a/docs/UsingLibraries.html b/docs/UsingLibraries.html index 6152f3ac918..29734525329 100644 --- a/docs/UsingLibraries.html +++ b/docs/UsingLibraries.html @@ -1,28 +1,20 @@ - + - Object Files: Understanding The Result Of LLVM Compilation + Using The LLVM Libraries - -
- Object Files: Understanding The Result Of LLVM Compilation -
- +

Using The LLVM Libraries

  1. Abstract
  2. Introduction
  3. -
  4. File Contents
  5. +
  6. Library Descriptions
  7. +
  8. Library Dependencies
  9. Linkage Rules Of Thumb
      -
    1. Always Link vmcore.o, support.a -
    2. Placeholder +
    3. Always link LLVMCore, LLVMSupport, LLVMSystem +
    4. Never link both archive and re-linked
@@ -31,258 +23,423 @@

Written by Reid Spencer

+

Warning: This document is out of date, for more + information please + see llvm-config or, + if you use CMake, the CMake LLVM + guide.

+ -
Abstract
-
-

This document describes the contents of the many objects files and libraries -that are produced by compiling LLVM. To make use of LLVM this information is -needed in order to understand what files should be linked into your program. +

Abstract

+
+

Amongst other things, LLVM is a toolkit for building compilers, linkers, + runtime executives, virtual machines, and other program execution related + tools. In addition to the LLVM tool set, the functionality of LLVM is + available through a set of libraries. To use LLVM as a toolkit for + constructing tools, a developer needs to understand what is contained in the + various libraries, what they depend on, and how to use them. Fortunately, + there is a tool, llvm-config to aid with this. This document + describes the contents of the libraries and how to use llvm-config + to generate command line options.

+ -
Introduction
-
-

If you're writing a compiler, virtual machine, or any other utility for - LLVM, you'll need to figure out which of the many .a (archive) and .o - (object) files you will need to link with to be successful. An - understanding of the contents of these files and their inter-relationships - will be useful in coming up with an optimal specification for the objects - and libraries to link with. -

-

The purpose of this document is to hopefully reduce some of the trial and - error that the author experienced in using LLVM. -

+

Introduction

+
+

If you're writing a compiler, virtual machine, or any other utility based + on LLVM, you'll need to figure out which of the many libraries files you will + need to link with to be successful. An understanding of the contents of these + libraries will be useful in coming up with an optimal specification for the + libraries to link with. The purpose of this document is to reduce some of + the trial and error that the author experienced in using LLVM.

+

LLVM produces two types of libraries: archives (ending in .a) and + objects (ending in .o). However, both are libraries. Libraries ending + in .o are known as re-linked libraries because they contain all the + compilation units of the library linked together as a single .o file. + Furthermore, several of the libraries have both forms of library. The + re-linked libraries are used whenever you want to include all symbols from the + library. The archive libraries are used whenever you want to only resolve + outstanding symbols at that point in the link without including everything in + the library.

+

If you're using the LLVM Makefile system to link your tools,you will use + the LLVMLIBS make variable. + (see the Makefile Guide for + details). This variable specifies which LLVM libraries to link into your tool + and the order in which they will be linked. You specify re-linked libraries by + naming the library without a suffix. You specify archive libraries by naming + the library with a .a suffix but without the lib prefix. The + order in which the libraries appear in the LLVMLIBS variable + definition is the order in which they will be linked. Getting this order + correct for your tool can sometimes be challenging.

-
File Contents
-
-

The table below provides a summary of the basic contents of each file.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

Library Descriptions

+
+

The table below categorizes each library +

Summary Of LLVM Library And Object Files -

Library

Description

libipo.a - An archive of all interprocedural optimizations. -
libscalaropts.a - An archive of all scalar optimizations. -
libtransforms.aUncategorized transformations.
libtarget.aAn archive containing generic code generator support.
libanalysis.aAn archive containing intraprocedural analyses.
libdatastructure.aAn archive containing DataStructure Analysis.
libinstrument.aIntraprocedural instrumentation and utilities.
libsparcv9regalloc.aSparcV9 graph-coloring register allocator.
libipa.aAn archive containing interprocedural analyses
libtransformutils.aUtility functions for transformations.
libsupport.aGeneral support utilities

Object File

Description

support.oGeneral support utilities
asmparser.oAssembler Parser
bcreader.oBytecode Reader
bcwriter.oBytecode Writer
sched.oSparcV9 instruction scheduler
selectiondag.oAggressive instruction selector for Directed Acyclic Graphs
transformutils.oUtilities for code transformations
ipa.oInterprocedural Analyses
sparcv9select.oSparcV9 instruction selector
cwriter.o"C" Code Writer
profpaths.oPath profiling instrumentation
sparcv9regalloc.oSparcV9 graph-coloring register allocator
instrument.oIntraprocedural instrumentation and utilities.
datastructure.oDataStructure Analysis
codegen.oNative code generation
sparcv9livevar.oSparcV9 Live Variable Analysis
vmcore.oVirtual Machine Core
lli-interpreter.oInterpreter for LLVM ByteCode
lli-jit.o - Just-In-Time Compiler For LLVM ByteCode -
executionengine.oEngine for LLI
debugger.oSource Level Debugging Support
analysis.oGeneral framework for Analysis
sparcv9.oSparcV9 backend
target.oGeneric backend support
transforms.oUncategorized transformations.
x86.oIntel x86 backend
powerpc.oPowerPC backend
scalaropts.oOptimizations For Scalars
ipo.oInterprocedural Optimizations
trace.oSupport For Tracing/Debugging?
profile_rt.oRuntime Library For Profiler
sample.oSample Program ?
stkr_compiler.oStacker Language Compiler Library
stkr_runtime.oStacker Language Runtime Library
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LibraryFormsDescription
Core Libraries
LLVMArchive.aLLVM archive reading and writing
LLVMAsmParser.aLLVM assembly parsing
LLVMBCReader.aLLVM bitcode reading
LLVMBCWriter.aLLVM bitcode writing
LLVMCore.aLLVM core intermediate representation
LLVMDebugger.aSource level debugging support
LLVMLinker.aBitcode and archive linking interface
LLVMSupport.aGeneral support utilities
LLVMSystem.aOperating system abstraction layer
LLVMbzip2.aBZip2 compression library
Analysis Libraries
LLVMAnalysis.aVarious analysis passes.
LLVMDataStructure.oData structure analysis passes.
LLVMipa.aInter-procedural analysis passes.
Transformation Libraries
LLVMInstrumentation.aInstrumentation passes.
LLVMipo.aAll inter-procedural optimization passes.
LLVMScalarOpts.aAll scalar optimization passes.
LLVMTransformUtils.aTransformation utilities used by many passes.
Code Generation Libraries
LLVMCodeGen.oNative code generation infrastructure
LLVMSelectionDAG.oAggressive instruction selector for directed acyclic graphs
Target Libraries
LLVMAlpha.oCode generation for Alpha architecture
LLVMARM.oCode generation for ARM architecture
LLVMCBackend.o'C' language code generator.
LLVMPowerPC.oCode generation for PowerPC architecture
LLVMSparc.oCode generation for Sparc architecture
LLVMTarget.aGeneric code generation utilities.
LLVMX86.oCode generation for Intel x86 architecture
Runtime Libraries
LLVMInterpreter.oBitcode Interpreter
LLVMJIT.oBitcode JIT Compiler
LLVMExecutionEngine.oVirtual machine engine
-

+ + +

Using llvm-config

+
+

The llvm-config tool is a perl script that produces on its output + various kinds of information. For example, the source or object directories + used to build LLVM can be accessed by passing options to llvm-config. + For complete details on this tool, please see the + manual page.

+

To understand the relationships between libraries, the llvm-config + can be very useful. If all you know is that you want certain libraries to + be available, you can generate the complete set of libraries to link with + using one of four options, as below:

+
    +
  1. --ldflags. This generates the command line options necessary to + be passed to the ld tool in order to link with LLVM. Most notably, + the -L option is provided to specify a library search directory + that contains the LLVM libraries.
  2. +
  3. --libs. This generates command line options suitable for + use with a gcc-style linker. That is, libraries are given with a -l option + and object files are given with a full path.
  4. +
  5. --libnames. This generates a list of just the library file + names. If you know the directory in which these files reside (see --ldflags) + then you can find the libraries there.
  6. +
  7. --libfiles. This generates the full path names of the + LLVM library files.
  8. +
+

If you wish to delve further into how llvm-config generates the + correct order (based on library dependencies), please see the tool named + GenLibDeps.pl in the utils source directory of LLVM.

+ + + + + + + +

Dependency Relationships Of Libraries

+

This graph shows the dependency of archive libraries on other archive + libraries or objects. Where a library has both archive and object forms, only + the archive form is shown.

+ Library Dependencies +

Dependency Relationships Of Object Files

+

This graph shows the dependency of object files on archive libraries or + other objects. Where a library has both object and archive forms, only the + dependency to the archive form is shown.

+ Object File Dependencies +

The following list shows the dependency relationships between libraries in + textual form. The information is the same as shown on the graphs but arranged + alphabetically.

+
+
libLLVMAnalysis.a
    +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
libLLVMArchive.a
    +
  • libLLVMBCReader.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMAsmParser.a
    +
  • libLLVMCore.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMBCReader.a
    +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMBCWriter.a
    +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMCodeGen.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMScalarOpts.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMTransformUtils.a
  • +
+
libLLVMCore.a
    +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMDebugger.a
    +
  • libLLVMBCReader.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMInstrumentation.a
    +
  • libLLVMCore.a
  • +
  • libLLVMScalarOpts.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMTransformUtils.a
  • +
+
libLLVMLinker.a
    +
  • libLLVMArchive.a
  • +
  • libLLVMBCReader.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMScalarOpts.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMTransformUtils.a
  • +
+
libLLVMSelectionDAG.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMTransformUtils.a
  • +
+
libLLVMSupport.a
    +
  • libLLVMSystem.a
  • +
  • libLLVMbzip2.a
  • +
+
libLLVMSystem.a
+
+
libLLVMTarget.a
    +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMTransformUtils.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMipa.a
  • +
+
libLLVMbzip2.a
+
+
libLLVMipa.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
+
libLLVMipo.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMTransformUtils.a
  • +
  • libLLVMipa.a
  • +
+
libLLVMlto.a
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMBCReader.a
  • +
  • libLLVMBCWriter.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMLinker.a
  • +
  • libLLVMScalarOpts.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMipa.a
  • +
  • libLLVMipo.a
  • +
+
LLVMARM.o
    +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSelectionDAG.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMAlpha.o
    +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSelectionDAG.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMCBackend.o
    +
  • libLLVMAnalysis.a
  • +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMScalarOpts.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
  • libLLVMTransformUtils.a
  • +
  • libLLVMipa.a
  • +
+
LLVMExecutionEngine.o
    +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMInterpreter.o
    +
  • LLVMExecutionEngine.o
  • +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMJIT.o
    +
  • LLVMExecutionEngine.o
  • +
  • libLLVMCore.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMPowerPC.o
    +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSelectionDAG.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMSparc.o
    +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSelectionDAG.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
LLVMX86.o
    +
  • libLLVMCodeGen.a
  • +
  • libLLVMCore.a
  • +
  • libLLVMSelectionDAG.a
  • +
  • libLLVMSupport.a
  • +
  • libLLVMSystem.a
  • +
  • libLLVMTarget.a
  • +
+
+
+ - -
+

Linkage Rules Of Thumb

+

This section contains various "rules of thumb" about what files you should link into your programs.

-
- -
-

No matter what you do with LLVM, you'll always need to link with vmcore.o - and support.a.

+

+ Always Link LLVMCore, LLVMSupport, and LLVMSystem +

+
+

No matter what you do with LLVM, the last three entries in the value of + your LLVMLIBS make variable should always be: + LLVMCore LLVMSupport.a LLVMSystem.a. There are no LLVM + programs that don't depend on these three.

- -
-

Need more rules of thumb here.

+

+ Never link both archive and re-linked library +

+
+

There is never any point to linking both the re-linked (.o) and + the archive (.a) versions of a library. Since the re-linked version + includes the entire library, the archive version will not resolve any symbols. + You could even end up with link error if you place the archive version before + the re-linked version on the linker's command line.

+ +
+