aboutsummaryrefslogtreecommitdiffstats
path: root/docs/CommandGuide/llvm-ld.pod
blob: be2ff9da5769cc05353e4261ad7501d8ee9f289d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
=pod

=head1 NAME

llvm-ld - LLVM linker

=head1 SYNOPSIS

B<llvm-ld> <options> <files>

=head1 DESCRIPTION

The B<llvm-ld> command is similar to the common Unix utility, C<ld>. It 
links together bytecode modules to produce an executable program.

=head1 OPTIONS

=head2 Input/Output Options

=over

=item B<-o> F<filename>

This overrides the default output file and specifies the name of the file that
should be generated by the linker. By default, B<llvm-ld> generates a file named
F<a.out> for compatibility with B<ld>. The output will be written to
F<filename>.

=item B<-l>F<name>

This option specifies the F<name> of a library to search when resolving symbols
for the program. Only the base name should be specified as F<name>, without a
F<lib> prefix or any suffix. 

=item B<-L>F<Path>

This option tells B<llvm-ld> to look in F<Path> to find any library subsequently
specified with the B<-l> option. The paths will be searched in the order in
which they are specified on the command line. If the library is still not found,
a small set of system specific directories will also be searched. Note that
libraries specified with the B<-l> option that occur I<before> any B<-L> options
will not search the paths given by the B<-L> options following it.

=item B<-link-as-library>

Link the bytecode files together as a library, not an executable. In this mode,
undefined symbols will be permitted.

=item B<-r>

An alias for -link-as-library.

=item B<-march=>C<target>

Specifies the kind of machine for which code or assembly should be generated.

=item B<-native>

Generate a native binary instead of a shell script that runs the JIT from
bytecode.

=item B<-native-cbe>

Generate a native binary with the C back end and compilation with GCC.

=item B<-disable-compression>

Do not compress bytecode files.

=back

=head2 Optimization Options

=over 

=item B<-O0>

An alias for the -O1 option.

=item B<-O1>

Optimize for linking speed, not execution speed. The optimizer will attempt to
reduce the size of the linked program to reduce I/O but will not otherwise
perform any link-time optimizations.

=item B<-O2>

Perform only the minimal or required set of scalar optimizations.

=item B<-03>

An alias for the -O2 option.

=item B<-04>

Perform the standard link time inter-procedural optimizations. This will 
attempt to optimize the program taking the entire program into consideration.

=item B<-O5>

Perform aggressive link time optimizations. This is the same as -O4 but works
more aggressively to optimize the program.

=item B<-disable-inlining>

Do not run the inlining pass. Functions will not be inlined into other
functions.

=item B<-disable-opt>

Completely disable optimization. The various B<-On> options will be ignored and
no link time optimization passes will be run.

=item B<-disable-internalize>

Do not mark all symbols as internal.

=item B<-verify>

Run the verification pass after each of the passes to verify intermediate
results.

=item B<-s>

Strip symbol info from the executable to make it smaller.

=item B<-export-dynamic>

An alias for -disable-internalize

=item B<-load> F<module>

Load an optimization module, F<module>, which is expected to be a dynamic
library that provides the function name C<RunOptimizations>. This function will
be passed the PassManager, and the optimization level (values 0-5 based on the
B<-On> option). This function may add passes to the PassManager that should be
run. This feature allows the optimization passes of B<llvm-ld> to be extended.

=back

=head2 Miscellaneous Options

=over

=item B<-v>

Specifies verbose mode. In this mode the linker will print additional
information about the actions it takes, programs it executes, etc. 

=back

=head1 EXIT STATUS

If B<llvm-ld> succeeds, it will exit with 0 return code.  If an error occurs,
it will exit with a non-zero return code.

=head1 ENVIRONMENT

The C<LLVM_LIB_SEARCH_PATH> environment variable is used to find bytecode
libraries. Any paths specified in this variable will be searched after the C<-L>
options.

=head1 SEE ALSO

L<llvm-ar|llvm-ar>

=head1 AUTHORS

Maintained by the LLVM Team (L<http://llvm.cs.uiuc.edu>).

=cut