* Use HTML 4.01 Strict DTD
[oota-llvm.git] / docs / CommandGuide / gccld.html
1 <html>
2 <title>LLVM: gccld tool</title>
3
4 <body bgcolor=white>
5
6 <center><h1>LLVM: <tt>gccld</tt> tool</h1></center>
7 <HR>
8
9 <h3>NAME</h3>
10 <tt>gccld</tt>
11
12 <h3>SYNOPSIS</h3>
13 <tt>gccld [options] &lt; filename&gt; [ filename ...]</tt>
14
15 <h3>DESCRIPTION</h3>
16
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.
21 <p>
22
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.
27 <p>
28
29 The <tt>gccld</tt> tool performs a small set of interprocedural, post-link,
30 optimizations on the program.
31
32
33 <h4>Search Order</h4>
34
35 When looking for objects specified on the command line, <tt>gccld</tt> will
36 search for the object first in the current directory and then in the directory
37 specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable.  If it
38 cannot find the object, it fails.
39 <p>
40
41 When looking for a library specified with the -l option, <tt>gccld</tt> first
42 attempts to load a file with that name from the current directory.  If that
43 fails, it looks for lib&lt;library&gt;.bc, lib&lt;library&gt;.a, or
44 lib&lt;library&gt;.so, in that order, in each directory added to the library
45 search path with the -L option.  These directories are searched in order they
46 were specified.  If the library cannot be located, then <tt>gccld</tt> looks in
47 the directory specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment
48 variable.  If it does not find lib&lt;library&gt;.[bc | a | so] there, it fails.
49
50 The -L option is global.  It does not matter where it is specified in the list
51 of command line arguments; the directory is simply added to the search path and
52 is applied to all libraries, preceding or succeeding, in the command line.
53
54 <h4>Link order</h4>
55
56 All object files are linked first in the order they were specified on the
57 command line.  All library files are linked next.  Some libraries may not be
58 linked into the object program; see below.
59
60 <h4>Library Linkage</h4>
61
62 Object files and static bytecode objects are always linked into the output
63 file.  Library archives (.a files) load only the objects within the archive
64 that define symbols needed by the output file.  Hence, libraries should be
65 listed after the object files and libraries which need them; otherwise, the
66 library may not be linked in, and the dependent library will not have its
67 undefined symbols defined.
68
69 <h4>Native code generation</h4>
70
71 The <tt>gccld</tt> program has limited support for native code generation, when
72 using the -native option.
73
74
75 <h3>OPTIONS</h3>
76
77 <ul>
78         <li> -help
79         <br>
80         Print a summary of command line options.
81         <p>
82
83         <li> -o &lt;filename&gt;
84         <br>
85         Specify the output filename which will hold the linked bytecode.
86         <p>
87
88         <li> -stats
89         <br>
90         Print statistics.
91         <p>
92
93         <li> -time-passes
94         <br>
95         Record the amount of time needed for each pass and print it to standard
96         error.
97         <p>
98
99         <li> -verify
100         <br>
101         Verify each pass result.
102         <p>
103
104         <li> -L=&lt;directory&gt;
105         <br>
106         Add directory to the list of directories to search when looking for
107         libraries.
108         <p>
109
110         <li> -disable-internalize
111         <br>
112         Do not mark all symbols as internal.
113         <p>
114
115         <li> -internalize-public-api-file &lt;filename&gt;
116         <br>
117         Preserve the list of symbol names in the file filename.
118         <p>
119
120         <li> -internalize-public-api-list &lt;list&gt;
121         <br>
122         Preserve the symbol names in list.
123         <p>
124
125         <li> -l=&lt;library&gt;
126         <br>
127         Specify libraries to include when linking the output file.  When
128         linking, <tt>gccld</tt> will first attempt to load a file with the
129         pathname library.  If that fails, it will then attempt to load
130         lib&lt;library&gt;.bc, lib&lt;library&gt;.a, and lib&lt;library&gt;.so,
131         in that order.
132         <p>
133
134         <li> -link-as-library
135         <br>
136         Link the .bc files together as a library, not an executable.
137         <p>
138
139         <li> -native
140         <br>
141         Generate a native, machine code executable.
142   <p>
143   When generating native executables, <tt>gccld</tt> first checks for a bytecode
144   version of the library and links it in, if necessary.  If the library is
145   missing, <tt>gccld</tt> skips it.  Then, <tt>gccld</tt> links in the same
146   libraries as native code.
147   <p>
148   In this way, <tt>gccld</tt> should be able to link in optimized bytecode
149   subsets of common libraries and then link in any part of the library that
150   hasn't been converted to bytecode.
151         <p>
152
153         <li> -s
154         <br>
155         Strip symbol information from the generated executable.
156         <p>
157
158         <li> -v
159         <br>
160         Print information about actions taken.
161 </ul>
162
163 <h3>EXIT STATUS</h3>
164
165 If <tt>gccld</tt> succeeds, it will exit with 0.  Otherwise, if an error occurs,
166 it will exit with a non-zero value.
167
168 <h3>SEE ALSO</h3>
169 <a href="llvm-link.html"><tt>llvm-link</tt></a>
170 <a href="gccas.html"><tt>gccas</tt></a>
171
172 <h3>BUGS</h3>
173 The -L option cannot be used for find native code libraries when using the
174 -native option.
175
176 <HR>
177 Maintained by the <a href="http://llvm.cs.uiuc.edu">LLVM Team</a>.
178 </body>
179 </html>
180