blob: be8092a7b03b98803a8259c288fd086d34f065b8 [file] [log] [blame]
John Criswellecf32e52003-09-11 19:58:03 +00001<html>
Chris Lattner537a02c2003-10-07 20:01:09 +00002<title>LLVM: gccld tool</title>
John Criswellecf32e52003-09-11 19:58:03 +00003
Chris Lattner537a02c2003-10-07 20:01:09 +00004<body bgcolor=white>
John Criswellecf32e52003-09-11 19:58:03 +00005
Chris Lattner537a02c2003-10-07 20:01:09 +00006<center><h1>LLVM: <tt>gccld</tt> tool</h1></center>
John Criswellecf32e52003-09-11 19:58:03 +00007<HR>
8
Chris Lattner537a02c2003-10-07 20:01:09 +00009<h3>NAME</h3>
10<tt>gccld</tt>
John Criswellecf32e52003-09-11 19:58:03 +000011
Chris Lattner537a02c2003-10-07 20:01:09 +000012<h3>SYNOPSIS</h3>
13<tt>gccld [options] &lt; filename&gt; [ filename ...]</tt>
John Criswellecf32e52003-09-11 19:58:03 +000014
Chris Lattner537a02c2003-10-07 20:01:09 +000015<h3>DESCRIPTION</h3>
John Criswellecf32e52003-09-11 19:58:03 +000016
Chris Lattner537a02c2003-10-07 20:01:09 +000017The <tt>gccld</tt> utility takes a set of LLVM bytecode files and links them
18together into a single LLVM bytecode file. The output bytecode file can be
19another bytecode library or an executable bytecode program. Using additional
20options, <tt>gccld</tt> is able to produce native code executables.
John Criswellecf32e52003-09-11 19:58:03 +000021<p>
John Criswellecf32e52003-09-11 19:58:03 +000022
Chris Lattner537a02c2003-10-07 20:01:09 +000023The <tt>gccld</tt> utility is primarily used by the <a href="llvmgcc.html">C</a>
24and <a href="llvmgxx.html">C++</a> front-ends, and as such, attempts to mimic
25the interface provided by the default system linker so that it can act as a
26"drop-in" replacement.
John Criswell52f68b82003-09-25 19:10:25 +000027<p>
Chris Lattner537a02c2003-10-07 20:01:09 +000028
29The <tt>gccld</tt> tool performs a small set of interprocedural, post-link,
30optimizations on the program.
31
32
33<h4>Search Order</h4>
34
John Criswellf9c78652004-01-26 21:26:54 +000035<p>
Chris Lattner537a02c2003-10-07 20:01:09 +000036When looking for objects specified on the command line, <tt>gccld</tt> will
37search for the object first in the current directory and then in the directory
38specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable. If it
39cannot find the object, it fails.
John Criswellf9c78652004-01-26 21:26:54 +000040</p>
Chris Lattner537a02c2003-10-07 20:01:09 +000041
John Criswellf9c78652004-01-26 21:26:54 +000042<p>
Chris Lattner537a02c2003-10-07 20:01:09 +000043When looking for a library specified with the -l option, <tt>gccld</tt> first
44attempts to load a file with that name from the current directory. If that
45fails, it looks for lib&lt;library&gt;.bc, lib&lt;library&gt;.a, or
John Criswellf9c78652004-01-26 21:26:54 +000046lib&lt;library&gt;.&lt;shared library extension&gt;, in that order, in each
47directory added to the library search path with the -L option. These
48directories are searched in the order they
Chris Lattner537a02c2003-10-07 20:01:09 +000049were specified. If the library cannot be located, then <tt>gccld</tt> looks in
50the directory specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment
John Criswellf9c78652004-01-26 21:26:54 +000051variable. If it does not find a library there, it fails.
52</p>
John Criswell52f68b82003-09-25 19:10:25 +000053
John Criswellf9c78652004-01-26 21:26:54 +000054<p>
55The shared library extension is usually <tt>.so</tt>, but it may differ
56depending upon the system.
57</p>
58
59<p>
John Criswell52f68b82003-09-25 19:10:25 +000060The -L option is global. It does not matter where it is specified in the list
61of command line arguments; the directory is simply added to the search path and
62is applied to all libraries, preceding or succeeding, in the command line.
John Criswellf9c78652004-01-26 21:26:54 +000063</p>
John Criswell52f68b82003-09-25 19:10:25 +000064
Chris Lattner537a02c2003-10-07 20:01:09 +000065<h4>Link order</h4>
66
John Criswell52f68b82003-09-25 19:10:25 +000067All object files are linked first in the order they were specified on the
68command line. All library files are linked next. Some libraries may not be
69linked into the object program; see below.
70
Chris Lattner537a02c2003-10-07 20:01:09 +000071<h4>Library Linkage</h4>
72
John Criswell52f68b82003-09-25 19:10:25 +000073Object files and static bytecode objects are always linked into the output
74file. Library archives (.a files) load only the objects within the archive
75that define symbols needed by the output file. Hence, libraries should be
76listed after the object files and libraries which need them; otherwise, the
77library may not be linked in, and the dependent library will not have its
78undefined symbols defined.
79
Chris Lattner537a02c2003-10-07 20:01:09 +000080<h4>Native code generation</h4>
81
82The <tt>gccld</tt> program has limited support for native code generation, when
83using the -native option.
84
85
86<h3>OPTIONS</h3>
John Criswellecf32e52003-09-11 19:58:03 +000087
88<ul>
89 <li> -help
90 <br>
91 Print a summary of command line options.
92 <p>
93
94 <li> -o &lt;filename&gt;
95 <br>
John Criswell52f68b82003-09-25 19:10:25 +000096 Specify the output filename which will hold the linked bytecode.
John Criswellecf32e52003-09-11 19:58:03 +000097 <p>
98
99 <li> -stats
100 <br>
101 Print statistics.
102 <p>
103
104 <li> -time-passes
105 <br>
106 Record the amount of time needed for each pass and print it to standard
107 error.
108 <p>
109
110 <li> -verify
111 <br>
112 Verify each pass result.
113 <p>
114
Brian Gaeke99fe6ba2003-11-16 23:39:11 +0000115 <li> -disable-opt
116 <br>
117 Disable all link-time optimization passes.
118 <p>
119
John Criswellecf32e52003-09-11 19:58:03 +0000120 <li> -L=&lt;directory&gt;
121 <br>
122 Add directory to the list of directories to search when looking for
123 libraries.
124 <p>
125
126 <li> -disable-internalize
127 <br>
128 Do not mark all symbols as internal.
129 <p>
130
131 <li> -internalize-public-api-file &lt;filename&gt;
132 <br>
133 Preserve the list of symbol names in the file filename.
134 <p>
135
136 <li> -internalize-public-api-list &lt;list&gt;
137 <br>
138 Preserve the symbol names in list.
139 <p>
140
John Criswell52f68b82003-09-25 19:10:25 +0000141 <li> -l=&lt;library&gt;
John Criswellecf32e52003-09-11 19:58:03 +0000142 <br>
Chris Lattner537a02c2003-10-07 20:01:09 +0000143 Specify libraries to include when linking the output file. When
144 linking, <tt>gccld</tt> will first attempt to load a file with the
John Criswellf9c78652004-01-26 21:26:54 +0000145 pathname <tt>library</tt>. If that fails, it will then attempt to load
146 lib&lt;library&gt;.bc, lib&lt;library&gt;.a, and
147 lib&lt;library&gt;.&lt;shared library extension&gt;, in that order.
John Criswellecf32e52003-09-11 19:58:03 +0000148 <p>
149
150 <li> -link-as-library
151 <br>
152 Link the .bc files together as a library, not an executable.
153 <p>
154
John Criswell52f68b82003-09-25 19:10:25 +0000155 <li> -native
156 <br>
157 Generate a native, machine code executable.
John Criswellb7fcd302003-09-25 19:14:51 +0000158 <p>
Chris Lattner537a02c2003-10-07 20:01:09 +0000159 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.
John Criswellb7fcd302003-09-25 19:14:51 +0000163 <p>
Chris Lattner537a02c2003-10-07 20:01:09 +0000164 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.
John Criswell52f68b82003-09-25 19:10:25 +0000167 <p>
168
John Criswellecf32e52003-09-11 19:58:03 +0000169 <li> -s
170 <br>
171 Strip symbol information from the generated executable.
172 <p>
173
174 <li> -v
175 <br>
176 Print information about actions taken.
177</ul>
178
Chris Lattner537a02c2003-10-07 20:01:09 +0000179<h3>EXIT STATUS</h3>
John Criswellecf32e52003-09-11 19:58:03 +0000180
Chris Lattner537a02c2003-10-07 20:01:09 +0000181If <tt>gccld</tt> succeeds, it will exit with 0. Otherwise, if an error occurs,
182it will exit with a non-zero value.
John Criswellecf32e52003-09-11 19:58:03 +0000183
Chris Lattner537a02c2003-10-07 20:01:09 +0000184<h3>SEE ALSO</h3>
185<a href="llvm-link.html"><tt>llvm-link</tt></a>
186<a href="gccas.html"><tt>gccas</tt></a>
John Criswell52f68b82003-09-25 19:10:25 +0000187
Chris Lattner537a02c2003-10-07 20:01:09 +0000188<h3>BUGS</h3>
John Criswell52f68b82003-09-25 19:10:25 +0000189The -L option cannot be used for find native code libraries when using the
190-native option.
John Criswellecf32e52003-09-11 19:58:03 +0000191
192<HR>
Chris Lattner08a04fd2003-10-07 20:12:05 +0000193Maintained by the <a href="http://llvm.cs.uiuc.edu">LLVM Team</a>.
John Criswellecf32e52003-09-11 19:58:03 +0000194</body>
195</html>
196