6b0257485fe7cfcbde0771bd2157e4a0d61afb23
[oota-llvm.git] / docs / CommandGuide / gccld.pod
1
2 =pod
3
4 =head1 NAME
5
6 gccld - optimizing LLVM linker
7
8 =head1 SYNOPSIS
9
10 gccld [options] file1 [file2 ...]
11
12 =head1 DESCRIPTION
13
14 The B<gccld> utility takes a set of LLVM bytecode files and links them
15 together into a single LLVM bytecode file.  The output bytecode file can be
16 another bytecode library or an executable bytecode program.  Using additional
17 options, B<gccld> is able to produce native code executables.
18
19 The B<gccld> utility is primarily used by the L<llvmgcc> and
20 L<llvmg++|llvmgxx> front-ends, and as such, attempts to mimic the interface
21 provided by the default system linker so that it can act as a ``drop-in''
22 replacement.
23
24 The B<gccld> tool performs a small set of interprocedural, post-link
25 optimizations on the program.
26
27 =head2 Search Order
28
29 When looking for objects specified on the command line, B<gccld> will search for
30 the object first in the current directory and then in the directory specified by
31 the B<LLVM_LIB_SEARCH_PATH> environment variable.  If it cannot find the object,
32 it fails.
33
34 When looking for a library specified with the B<-l> option, B<gccld> first
35 attempts to load a file with that name from the current directory.  If that
36 fails, it looks for libI<library>.bc, libI<library>.a, or libI<library>.I<shared
37 library extension>, in that order, in each directory added to the library search
38 path with the B<-L> option.  These directories are searched in the order they
39 were specified.  If the library cannot be located, then B<gccld> looks in the
40 directory specified by the B<LLVM_LIB_SEARCH_PATH> environment variable.  If it
41 does not find a library there, it fails.
42
43 The shared library extension may be I<.so>, I<.dyld>, I<.dll>, or something
44 different, depending upon the system.
45
46 The B<-L> option is global.  It does not matter where it is specified in the
47 list of command line arguments; the directory is simply added to the search path
48 and is applied to all libraries, preceding or succeeding, in the command line.
49
50 =head2 Link order
51
52 All object files are linked first in the order they were specified on the
53 command line.  All library files are linked next.  Some libraries may not be
54 linked into the object program; see below.
55
56 =head2 Library Linkage
57
58 Object files and static bytecode objects are always linked into the output
59 file.  Library archives (.a files) load only the objects within the archive
60 that define symbols needed by the output file.  Hence, libraries should be
61 listed after the object files and libraries which need them; otherwise, the
62 library may not be linked in, and the dependent library will not have its
63 undefined symbols defined.
64
65 =head2 Native code generation
66
67 The B<gccld> program has limited support for native code generation, when
68 using the B<-native> or B<-native-cbe> options.
69
70 =head1 OPTIONS
71
72 =over
73
74 =item B<-help>
75
76 Print a summary of command line options.
77
78 =item B<-o> I<filename>
79
80 Specify the output filename which will hold the linked bytecode.
81
82 =item B<-stats>
83
84 Print statistics.
85
86 =item B<-time-passes>
87
88 Record the amount of time needed for each pass and print it to standard
89 error.
90
91 =item B<-verify>
92
93 Verify each pass result.
94
95 =item B<-disable-opt>
96
97 Disable all link-time optimization passes.
98
99 =item B<-disable-inlining>
100
101 Do not run the inliner pass.
102
103 =item B<-L>I<directory>
104
105 Add directory to the list of directories to search when looking for
106 libraries.
107
108 =item B<-disable-internalize>
109
110 Do not mark all symbols as internal.
111
112 =item B<-internalize-public-api-file> I<filename>
113
114 Preserve the list of symbol names in the file filename.
115
116 =item B<-internalize-public-api-list &lt;list&gt;>
117
118 Preserve the symbol names in list.
119
120 =item B<-l>I<library>
121
122 Specify libraries to include when linking the output file.  When linking,
123 B<gccld> will first attempt to load a file with the pathname B<library>.  If
124 that fails, it will then attempt to load libI<library>.bc, libI<library>.a, and
125 libI<library>.I<shared library extension>, in that order.
126
127 =item B<-link-as-library>
128
129 Link the .bc files together as a library, not an executable.
130
131 =item B<-native>
132
133 Generate a native machine code executable.
134
135 When generating native executables, B<gccld> first checks for a bytecode
136 version of the library and links it in, if necessary.  If the library is
137 missing, B<gccld> skips it.  Then, B<gccld> links in the same
138 libraries as native code.
139
140 In this way, B<gccld> should be able to link in optimized bytecode
141 subsets of common libraries and then link in any part of the library that
142 hasn't been converted to bytecode.
143
144 =item B<-native-cbe>
145
146 Generate a native machine code executable with the LLVM C backend.
147       
148 This option is identical to the B<-native> option, but uses the
149 C backend to generate code for the program instead of an LLVM native
150 code generator.
151
152 =item B<-s>
153
154 Strip symbol information from the generated executable.
155
156 =item B<-v>
157
158 Print information about actions taken.
159
160 =back
161
162 =head1 EXIT STATUS
163
164 If B<gccld> succeeds, it will exit with an exit status of 0.
165 Otherwise, if an error occurs, it will exit with a non-zero exit
166 status.
167
168 =head1 SEE ALSO
169
170 L<llvm-link>, L<gccas>
171
172 =head1 AUTHORS
173
174 Maintained by the LLVM Team (L<http://llvm.cs.uiuc.edu>).
175
176 =cut
177