2 <title>LLVM: gccld tool</title>
6 <center><h1>LLVM: <tt>gccld</tt> tool</h1></center>
13 <tt>gccld [options] < filename> [ filename ...]</tt>
17 The <tt>gccld</tt> utility takes a set of LLVM bytecode files and links them
18 together into a single LLVM bytecode file. The output bytecode file can be
19 another bytecode library or an executable bytecode program. Using additional
20 options, <tt>gccld</tt> is able to produce native code executables.
23 The <tt>gccld</tt> utility is primarily used by the <a href="llvmgcc.html">C</a>
24 and <a href="llvmgxx.html">C++</a> front-ends, and as such, attempts to mimic
25 the interface provided by the default system linker so that it can act as a
26 "drop-in" replacement.
29 The <tt>gccld</tt> tool performs a small set of interprocedural, post-link,
30 optimizations on the program.
36 When looking for objects specified on the command line, <tt>gccld</tt> will
37 search for the object first in the current directory and then in the directory
38 specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable. If it
39 cannot find the object, it fails.
43 When looking for a library specified with the -l option, <tt>gccld</tt> first
44 attempts to load a file with that name from the current directory. If that
45 fails, it looks for lib<library>.bc, lib<library>.a, or
46 lib<library>.<shared library extension>, in that order, in each
47 directory added to the library search path with the -L option. These
48 directories are searched in the order they
49 were specified. If the library cannot be located, then <tt>gccld</tt> looks in
50 the directory specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment
51 variable. If it does not find a library there, it fails.
55 The shared library extension is usually <tt>.so</tt>, but it may differ
56 depending upon the system.
60 The -L option is global. It does not matter where it is specified in the list
61 of command line arguments; the directory is simply added to the search path and
62 is applied to all libraries, preceding or succeeding, in the command line.
67 All object files are linked first in the order they were specified on the
68 command line. All library files are linked next. Some libraries may not be
69 linked into the object program; see below.
71 <h4>Library Linkage</h4>
73 Object files and static bytecode objects are always linked into the output
74 file. Library archives (.a files) load only the objects within the archive
75 that define symbols needed by the output file. Hence, libraries should be
76 listed after the object files and libraries which need them; otherwise, the
77 library may not be linked in, and the dependent library will not have its
78 undefined symbols defined.
80 <h4>Native code generation</h4>
82 The <tt>gccld</tt> program has limited support for native code generation, when
83 using the -native option.
91 Print a summary of command line options.
94 <li> -o <filename>
96 Specify the output filename which will hold the linked bytecode.
106 Record the amount of time needed for each pass and print it to standard
112 Verify each pass result.
117 Disable all link-time optimization passes.
120 <li> -L=<directory>
122 Add directory to the list of directories to search when looking for
126 <li> -disable-internalize
128 Do not mark all symbols as internal.
131 <li> -internalize-public-api-file <filename>
133 Preserve the list of symbol names in the file filename.
136 <li> -internalize-public-api-list <list>
138 Preserve the symbol names in list.
141 <li> -l=<library>
143 Specify libraries to include when linking the output file. When
144 linking, <tt>gccld</tt> will first attempt to load a file with the
145 pathname <tt>library</tt>. If that fails, it will then attempt to load
146 lib<library>.bc, lib<library>.a, and
147 lib<library>.<shared library extension>, in that order.
150 <li> -link-as-library
152 Link the .bc files together as a library, not an executable.
157 Generate a native, machine code executable.
159 When generating native executables, <tt>gccld</tt> first checks for a bytecode
160 version of the library and links it in, if necessary. If the library is
161 missing, <tt>gccld</tt> skips it. Then, <tt>gccld</tt> links in the same
162 libraries as native code.
164 In this way, <tt>gccld</tt> should be able to link in optimized bytecode
165 subsets of common libraries and then link in any part of the library that
166 hasn't been converted to bytecode.
171 Strip symbol information from the generated executable.
176 Print information about actions taken.
181 If <tt>gccld</tt> succeeds, it will exit with 0. Otherwise, if an error occurs,
182 it will exit with a non-zero value.
185 <a href="llvm-link.html"><tt>llvm-link</tt></a>
186 <a href="gccas.html"><tt>gccas</tt></a>
189 The -L option cannot be used for find native code libraries when using the
193 Maintained by the <a href="http://llvm.cs.uiuc.edu">LLVM Team</a>.