1LLVM-LD(1)                    LLVM Command Guide                    LLVM-LD(1)
2
3
4

NAME

6       llvm-ld - LLVM linker
7

SYNOPSIS

9       llvm-ld <options> <files>
10

DESCRIPTION

12       The llvm-ld tool takes a set of LLVM bitcode files and links them
13       together into a single LLVM bitcode file.  The output bitcode file can
14       be another bitcode file or an executable bitcode program.  Using
15       additional options, llvm-ld is able to produce native code executables.
16
17       The llvm-ld tool is the main linker for LLVM. It is used to link
18       together the output of LLVM front-end compilers and run "link time"
19       optimizations (mostly the inter-procedural kind).
20
21       The llvm-ld tools attempts to mimic the interface provided by the
22       default system linker so that it can act as a drop-in replacement.
23
24   Search Order
25       When looking for objects specified on the command line, llvm-ld will
26       search for the object first in the current directory and then in the
27       directory specified by the LLVM_LIB_SEARCH_PATH environment variable.
28       If it cannot find the object, it fails.
29
30       When looking for a library specified with the -l option, llvm-ld first
31       attempts to load a file with that name from the current directory.  If
32       that fails, it looks for liblibrary.bc, liblibrary.a, or
33       liblibrary.shared library extension, in that order, in each directory
34       added to the library search path with the -L option.  These directories
35       are searched in the order they are specified.  If the library cannot be
36       located, then llvm-ld looks in the directory specified by the
37       LLVM_LIB_SEARCH_PATH environment variable.  If it does not find a
38       library there, it fails.
39
40       The shared library extension may be .so, .dyld, .dll, or something
41       different, depending upon the system.
42
43       The -L option is global.  It does not matter where it is specified in
44       the list of command line arguments; the directory is simply added to
45       the search path and is applied to all libraries, preceding or
46       succeeding, in the command line.
47
48   Link order
49       All object and bitcode files are linked first in the order they were
50       specified on the command line.  All library files are linked next.
51       Some libraries may not be linked into the object program; see below.
52
53   Library Linkage
54       Object files and static bitcode objects are always linked into the
55       output file.  Library archives (.a files) load only the objects within
56       the archive that define symbols needed by the output file.  Hence,
57       libraries should be listed after the object files and libraries which
58       need them; otherwise, the library may not be linked in, and the
59       dependent library will not have its undefined symbols defined.
60
61   Native code generation
62       The llvm-ld program has limited support for native code generation,
63       when using the -native or -native-cbe options. Native code generation
64       is performed by converting the linked bitcode into native assembly (.s)
65       or C code and running the system compiler (typically gcc) on the
66       result.
67

OPTIONS

69   General Options
70       -help
71           Print a summary of command line options.
72
73       -v  Specifies verbose mode. In this mode the linker will print
74           additional information about the actions it takes, programs it
75           executes, etc.
76
77       -stats
78           Print statistics.
79
80       -time-passes
81           Record the amount of time needed for each pass and print it to
82           standard error.
83
84   Input/Output Options
85       -o filename
86           This overrides the default output file and specifies the name of
87           the file that should be generated by the linker. By default, llvm-
88           ld generates a file named a.out for compatibility with ld. The
89           output will be written to filename.
90
91       -b filename
92           This option can be used to override the output bitcode file name.
93           By default, the name of the bitcode output file is one more ".bc"
94           suffix added to the name specified by -o filename option.
95
96       -lname
97           This option specifies the name of a library to search when
98           resolving symbols for the program. Only the base name should be
99           specified as name, without a lib prefix or any suffix.
100
101       -LPath
102           This option tells llvm-ld to look in Path to find any library
103           subsequently specified with the -l option. The paths will be
104           searched in the order in which they are specified on the command
105           line. If the library is still not found, a small set of system
106           specific directories will also be searched. Note that libraries
107           specified with the -l option that occur before any -L options will
108           not search the paths given by the -L options following it.
109
110       -link-as-library
111           Link the bitcode files together as a library, not an executable. In
112           this mode, undefined symbols will be permitted.
113
114       -r  An alias for -link-as-library.
115
116       -native
117           Generate a native machine code executable.
118
119           When generating native executables, llvm-ld first checks for a
120           bitcode version of the library and links it in, if necessary.  If
121           the library is missing, llvm-ld skips it.  Then, llvm-ld links in
122           the same libraries as native code.
123
124           In this way, llvm-ld should be able to link in optimized bitcode
125           subsets of common libraries and then link in any part of the
126           library that hasn't been converted to bitcode.
127
128       -native-cbe
129           Generate a native machine code executable with the LLVM C backend.
130
131           This option is identical to the -native option, but uses the C
132           backend to generate code for the program instead of an LLVM native
133           code generator.
134
135   Optimization Options
136       -disable-inlining
137           Do not run the inlining pass. Functions will not be inlined into
138           other functions.
139
140       -disable-opt
141           Completely disable optimization.
142
143       -disable-internalize
144           Do not mark all symbols as internal.
145
146       -verify-each
147           Run the verification pass after each of the passes to verify
148           intermediate results.
149
150       -strip-all
151           Strip all debug and symbol information from the executable to make
152           it smaller.
153
154       -strip-debug
155           Strip all debug information from the executable to make it smaller.
156
157       -s  An alias for -strip-all.
158
159       -S  An alias for -strip-debug.
160
161       -export-dynamic
162           An alias for -disable-internalize
163
164       -post-link-optPath
165           Run post-link optimization program. After linking is completed a
166           bitcode file will be generated. It will be passed to the program
167           specified by Path as the first argument. The second argument to the
168           program will be the name of a temporary file into which the program
169           should place its optimized output. For example, the "no-op
170           optimization" would be a simple shell script:
171
172               #!/bin/bash
173               cp $1 $2
174

EXIT STATUS

176       If llvm-ld succeeds, it will exit with 0 return code.  If an error
177       occurs, it will exit with a non-zero return code.
178

ENVIRONMENT

180       The "LLVM_LIB_SEARCH_PATH" environment variable is used to find bitcode
181       libraries. Any paths specified in this variable will be searched after
182       the "-L" options.
183

SEE ALSO

185       llvm-link
186

AUTHORS

188       Maintained by the LLVM Team (<http://llvm.org>).
189
190
191
192CVS                               2010-05-07                        LLVM-LD(1)
Impressum