blob: 1b90d8459525ac68a90de1a2075c281800958b40 [file] [log] [blame]
John Criswell408128d2003-09-11 19:58:03 +00001<html>
Chris Lattnerfc294d12003-10-07 20:01:09 +00002<title>LLVM: gccld tool</title>
John Criswell408128d2003-09-11 19:58:03 +00003
Chris Lattnerfc294d12003-10-07 20:01:09 +00004<body bgcolor=white>
John Criswell408128d2003-09-11 19:58:03 +00005
Chris Lattnerfc294d12003-10-07 20:01:09 +00006<center><h1>LLVM: <tt>gccld</tt> tool</h1></center>
John Criswell408128d2003-09-11 19:58:03 +00007<HR>
8
Chris Lattnerfc294d12003-10-07 20:01:09 +00009<h3>NAME</h3>
10<tt>gccld</tt>
John Criswell408128d2003-09-11 19:58:03 +000011
Chris Lattnerfc294d12003-10-07 20:01:09 +000012<h3>SYNOPSIS</h3>
13<tt>gccld [options] &lt; filename&gt; [ filename ...]</tt>
John Criswell408128d2003-09-11 19:58:03 +000014
Chris Lattnerfc294d12003-10-07 20:01:09 +000015<h3>DESCRIPTION</h3>
John Criswell408128d2003-09-11 19:58:03 +000016
Chris Lattnerfc294d12003-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 Criswell408128d2003-09-11 19:58:03 +000021<p>
John Criswell408128d2003-09-11 19:58:03 +000022
Chris Lattnerfc294d12003-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 Criswellcef81352003-09-25 19:10:25 +000027<p>
Chris Lattnerfc294d12003-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
35When looking for objects specified on the command line, <tt>gccld</tt> will
36search for the object first in the current directory and then in the directory
37specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable. If it
38cannot find the object, it fails.
39<p>
40
41When looking for a library specified with the -l option, <tt>gccld</tt> first
42attempts to load a file with that name from the current directory. If that
43fails, it looks for lib&lt;library&gt;.bc, lib&lt;library&gt;.a, or
John Criswellcef81352003-09-25 19:10:25 +000044lib&lt;library&gt;.so, in that order, in each directory added to the library
45search path with the -L option. These directories are searched in order they
Chris Lattnerfc294d12003-10-07 20:01:09 +000046were specified. If the library cannot be located, then <tt>gccld</tt> looks in
47the directory specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment
48variable. If it does not find lib&lt;library&gt;.[bc | a | so] there, it fails.
John Criswellcef81352003-09-25 19:10:25 +000049
50The -L option is global. It does not matter where it is specified in the list
51of command line arguments; the directory is simply added to the search path and
52is applied to all libraries, preceding or succeeding, in the command line.
53
Chris Lattnerfc294d12003-10-07 20:01:09 +000054<h4>Link order</h4>
55
John Criswellcef81352003-09-25 19:10:25 +000056All object files are linked first in the order they were specified on the
57command line. All library files are linked next. Some libraries may not be
58linked into the object program; see below.
59
Chris Lattnerfc294d12003-10-07 20:01:09 +000060<h4>Library Linkage</h4>
61
John Criswellcef81352003-09-25 19:10:25 +000062Object files and static bytecode objects are always linked into the output
63file. Library archives (.a files) load only the objects within the archive
64that define symbols needed by the output file. Hence, libraries should be
65listed after the object files and libraries which need them; otherwise, the
66library may not be linked in, and the dependent library will not have its
67undefined symbols defined.
68
Chris Lattnerfc294d12003-10-07 20:01:09 +000069<h4>Native code generation</h4>
70
71The <tt>gccld</tt> program has limited support for native code generation, when
72using the -native option.
73
74
75<h3>OPTIONS</h3>
John Criswell408128d2003-09-11 19:58:03 +000076
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>
John Criswellcef81352003-09-25 19:10:25 +000085 Specify the output filename which will hold the linked bytecode.
John Criswell408128d2003-09-11 19:58:03 +000086 <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
Brian Gaeke9c917ab2003-11-16 23:39:11 +0000104 <li> -disable-opt
105 <br>
106 Disable all link-time optimization passes.
107 <p>
108
John Criswell408128d2003-09-11 19:58:03 +0000109 <li> -L=&lt;directory&gt;
110 <br>
111 Add directory to the list of directories to search when looking for
112 libraries.
113 <p>
114
115 <li> -disable-internalize
116 <br>
117 Do not mark all symbols as internal.
118 <p>
119
120 <li> -internalize-public-api-file &lt;filename&gt;
121 <br>
122 Preserve the list of symbol names in the file filename.
123 <p>
124
125 <li> -internalize-public-api-list &lt;list&gt;
126 <br>
127 Preserve the symbol names in list.
128 <p>
129
John Criswellcef81352003-09-25 19:10:25 +0000130 <li> -l=&lt;library&gt;
John Criswell408128d2003-09-11 19:58:03 +0000131 <br>
Chris Lattnerfc294d12003-10-07 20:01:09 +0000132 Specify libraries to include when linking the output file. When
133 linking, <tt>gccld</tt> will first attempt to load a file with the
134 pathname library. If that fails, it will then attempt to load
135 lib&lt;library&gt;.bc, lib&lt;library&gt;.a, and lib&lt;library&gt;.so,
136 in that order.
John Criswell408128d2003-09-11 19:58:03 +0000137 <p>
138
139 <li> -link-as-library
140 <br>
141 Link the .bc files together as a library, not an executable.
142 <p>
143
John Criswellcef81352003-09-25 19:10:25 +0000144 <li> -native
145 <br>
146 Generate a native, machine code executable.
John Criswell67d48112003-09-25 19:14:51 +0000147 <p>
Chris Lattnerfc294d12003-10-07 20:01:09 +0000148 When generating native executables, <tt>gccld</tt> first checks for a bytecode
149 version of the library and links it in, if necessary. If the library is
150 missing, <tt>gccld</tt> skips it. Then, <tt>gccld</tt> links in the same
151 libraries as native code.
John Criswell67d48112003-09-25 19:14:51 +0000152 <p>
Chris Lattnerfc294d12003-10-07 20:01:09 +0000153 In this way, <tt>gccld</tt> should be able to link in optimized bytecode
154 subsets of common libraries and then link in any part of the library that
155 hasn't been converted to bytecode.
John Criswellcef81352003-09-25 19:10:25 +0000156 <p>
157
John Criswell408128d2003-09-11 19:58:03 +0000158 <li> -s
159 <br>
160 Strip symbol information from the generated executable.
161 <p>
162
163 <li> -v
164 <br>
165 Print information about actions taken.
166</ul>
167
Chris Lattnerfc294d12003-10-07 20:01:09 +0000168<h3>EXIT STATUS</h3>
John Criswell408128d2003-09-11 19:58:03 +0000169
Chris Lattnerfc294d12003-10-07 20:01:09 +0000170If <tt>gccld</tt> succeeds, it will exit with 0. Otherwise, if an error occurs,
171it will exit with a non-zero value.
John Criswell408128d2003-09-11 19:58:03 +0000172
Chris Lattnerfc294d12003-10-07 20:01:09 +0000173<h3>SEE ALSO</h3>
174<a href="llvm-link.html"><tt>llvm-link</tt></a>
175<a href="gccas.html"><tt>gccas</tt></a>
John Criswellcef81352003-09-25 19:10:25 +0000176
Chris Lattnerfc294d12003-10-07 20:01:09 +0000177<h3>BUGS</h3>
John Criswellcef81352003-09-25 19:10:25 +0000178The -L option cannot be used for find native code libraries when using the
179-native option.
John Criswell408128d2003-09-11 19:58:03 +0000180
181<HR>
Chris Lattner7c2b1262003-10-07 20:12:05 +0000182Maintained by the <a href="http://llvm.cs.uiuc.edu">LLVM Team</a>.
John Criswell408128d2003-09-11 19:58:03 +0000183</body>
184</html>
185