John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 1 | <html> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 2 | <title>LLVM: gccld tool</title> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 3 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 4 | <body bgcolor=white> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 5 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 6 | <center><h1>LLVM: <tt>gccld</tt> tool</h1></center> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 7 | <HR> |
| 8 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 9 | <h3>NAME</h3> |
| 10 | <tt>gccld</tt> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 11 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 12 | <h3>SYNOPSIS</h3> |
| 13 | <tt>gccld [options] < filename> [ filename ...]</tt> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 14 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 15 | <h3>DESCRIPTION</h3> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 16 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 17 | The <tt>gccld</tt> utility takes a set of LLVM bytecode files and links them |
| 18 | together into a single LLVM bytecode file. The output bytecode file can be |
| 19 | another bytecode library or an executable bytecode program. Using additional |
| 20 | options, <tt>gccld</tt> is able to produce native code executables. |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 21 | <p> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 22 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 23 | The <tt>gccld</tt> utility is primarily used by the <a href="llvmgcc.html">C</a> |
| 24 | and <a href="llvmgxx.html">C++</a> front-ends, and as such, attempts to mimic |
| 25 | the interface provided by the default system linker so that it can act as a |
| 26 | "drop-in" replacement. |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 27 | <p> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 28 | |
| 29 | The <tt>gccld</tt> tool performs a small set of interprocedural, post-link, |
| 30 | optimizations on the program. |
| 31 | |
| 32 | |
| 33 | <h4>Search Order</h4> |
| 34 | |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 35 | <p> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 36 | When looking for objects specified on the command line, <tt>gccld</tt> will |
| 37 | search for the object first in the current directory and then in the directory |
| 38 | specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable. If it |
| 39 | cannot find the object, it fails. |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 40 | </p> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 41 | |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 42 | <p> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 43 | When looking for a library specified with the -l option, <tt>gccld</tt> first |
| 44 | attempts to load a file with that name from the current directory. If that |
| 45 | fails, it looks for lib<library>.bc, lib<library>.a, or |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 46 | lib<library>.<shared library extension>, in that order, in each |
| 47 | directory added to the library search path with the -L option. These |
| 48 | directories are searched in the order they |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 49 | were specified. If the library cannot be located, then <tt>gccld</tt> looks in |
| 50 | the directory specified by the <tt>LLVM_LIB_SEARCH_PATH</tt> environment |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 51 | variable. If it does not find a library there, it fails. |
| 52 | </p> |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 53 | |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 54 | <p> |
| 55 | The shared library extension is usually <tt>.so</tt>, but it may differ |
| 56 | depending upon the system. |
| 57 | </p> |
| 58 | |
| 59 | <p> |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 60 | The -L option is global. It does not matter where it is specified in the list |
| 61 | of command line arguments; the directory is simply added to the search path and |
| 62 | is applied to all libraries, preceding or succeeding, in the command line. |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 63 | </p> |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 64 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 65 | <h4>Link order</h4> |
| 66 | |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 67 | All object files are linked first in the order they were specified on the |
| 68 | command line. All library files are linked next. Some libraries may not be |
| 69 | linked into the object program; see below. |
| 70 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 71 | <h4>Library Linkage</h4> |
| 72 | |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 73 | Object files and static bytecode objects are always linked into the output |
| 74 | file. Library archives (.a files) load only the objects within the archive |
| 75 | that define symbols needed by the output file. Hence, libraries should be |
| 76 | listed after the object files and libraries which need them; otherwise, the |
| 77 | library may not be linked in, and the dependent library will not have its |
| 78 | undefined symbols defined. |
| 79 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 80 | <h4>Native code generation</h4> |
| 81 | |
| 82 | The <tt>gccld</tt> program has limited support for native code generation, when |
Chris Lattner | f701069 | 2004-04-06 16:46:12 +0000 | [diff] [blame] | 83 | using the <tt>-native</tt> or <tt>-native-cbe</tt> options. |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 84 | |
| 85 | |
| 86 | <h3>OPTIONS</h3> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 87 | |
| 88 | <ul> |
| 89 | <li> -help |
| 90 | <br> |
| 91 | Print a summary of command line options. |
| 92 | <p> |
| 93 | |
| 94 | <li> -o <filename> |
| 95 | <br> |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 96 | Specify the output filename which will hold the linked bytecode. |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 97 | <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 Gaeke | 99fe6ba | 2003-11-16 23:39:11 +0000 | [diff] [blame] | 115 | <li> -disable-opt |
| 116 | <br> |
John Criswell | 8417142 | 2004-03-12 22:45:35 +0000 | [diff] [blame] | 117 | Disable all link-time optimization passes. |
| 118 | <p> |
| 119 | |
| 120 | <li> -disable-inlining |
| 121 | <br> |
| 122 | Do not run the inliner pass. |
Brian Gaeke | 99fe6ba | 2003-11-16 23:39:11 +0000 | [diff] [blame] | 123 | <p> |
| 124 | |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 125 | <li> -L=<directory> |
| 126 | <br> |
| 127 | Add directory to the list of directories to search when looking for |
| 128 | libraries. |
| 129 | <p> |
| 130 | |
| 131 | <li> -disable-internalize |
| 132 | <br> |
| 133 | Do not mark all symbols as internal. |
| 134 | <p> |
| 135 | |
| 136 | <li> -internalize-public-api-file <filename> |
| 137 | <br> |
| 138 | Preserve the list of symbol names in the file filename. |
| 139 | <p> |
| 140 | |
| 141 | <li> -internalize-public-api-list <list> |
| 142 | <br> |
| 143 | Preserve the symbol names in list. |
| 144 | <p> |
| 145 | |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 146 | <li> -l=<library> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 147 | <br> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 148 | Specify libraries to include when linking the output file. When |
| 149 | linking, <tt>gccld</tt> will first attempt to load a file with the |
John Criswell | f9c7865 | 2004-01-26 21:26:54 +0000 | [diff] [blame] | 150 | pathname <tt>library</tt>. If that fails, it will then attempt to load |
| 151 | lib<library>.bc, lib<library>.a, and |
| 152 | lib<library>.<shared library extension>, in that order. |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 153 | <p> |
| 154 | |
| 155 | <li> -link-as-library |
| 156 | <br> |
| 157 | Link the .bc files together as a library, not an executable. |
| 158 | <p> |
| 159 | |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 160 | <li> -native |
| 161 | <br> |
| 162 | Generate a native, machine code executable. |
John Criswell | b7fcd30 | 2003-09-25 19:14:51 +0000 | [diff] [blame] | 163 | <p> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 164 | When generating native executables, <tt>gccld</tt> first checks for a bytecode |
| 165 | version of the library and links it in, if necessary. If the library is |
| 166 | missing, <tt>gccld</tt> skips it. Then, <tt>gccld</tt> links in the same |
| 167 | libraries as native code. |
John Criswell | b7fcd30 | 2003-09-25 19:14:51 +0000 | [diff] [blame] | 168 | <p> |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 169 | In this way, <tt>gccld</tt> should be able to link in optimized bytecode |
| 170 | subsets of common libraries and then link in any part of the library that |
| 171 | hasn't been converted to bytecode. |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 172 | <p> |
| 173 | |
Chris Lattner | f701069 | 2004-04-06 16:46:12 +0000 | [diff] [blame] | 174 | <li> -native-cbe |
| 175 | <br> |
| 176 | Generate a native, machine code executable with the LLVM C backend. |
| 177 | <p> |
| 178 | This option is identical to the <tt>-native</tt> option, but uses the |
| 179 | C backend to generate code for the program instead of an LLVM native |
| 180 | code generator. |
| 181 | </p> |
| 182 | |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 183 | <li> -s |
| 184 | <br> |
| 185 | Strip symbol information from the generated executable. |
| 186 | <p> |
| 187 | |
| 188 | <li> -v |
| 189 | <br> |
| 190 | Print information about actions taken. |
| 191 | </ul> |
| 192 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 193 | <h3>EXIT STATUS</h3> |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 194 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 195 | If <tt>gccld</tt> succeeds, it will exit with 0. Otherwise, if an error occurs, |
| 196 | it will exit with a non-zero value. |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 197 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 198 | <h3>SEE ALSO</h3> |
| 199 | <a href="llvm-link.html"><tt>llvm-link</tt></a> |
| 200 | <a href="gccas.html"><tt>gccas</tt></a> |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 201 | |
Chris Lattner | 537a02c | 2003-10-07 20:01:09 +0000 | [diff] [blame] | 202 | <h3>BUGS</h3> |
John Criswell | 52f68b8 | 2003-09-25 19:10:25 +0000 | [diff] [blame] | 203 | The -L option cannot be used for find native code libraries when using the |
| 204 | -native option. |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 205 | |
| 206 | <HR> |
Chris Lattner | 08a04fd | 2003-10-07 20:12:05 +0000 | [diff] [blame] | 207 | Maintained by the <a href="http://llvm.cs.uiuc.edu">LLVM Team</a>. |
John Criswell | ecf32e5 | 2003-09-11 19:58:03 +0000 | [diff] [blame] | 208 | </body> |
| 209 | </html> |
| 210 | |