llvm-ld - LLVM linker


llvm-ld <options> <files>


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


Input/Output Options

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

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

This option tells llvm-ld to look in Path to find any library subsequently specified with the -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 -l option that occur before any -L options will not search the paths given by the -L options following it.

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

An alias for -link-as-library.

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

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

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

Do not compress bytecode files.

Optimization Options

An alias for the -O1 option.

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.

Perform only the minimal or required set of scalar optimizations.

An alias for the -O2 option.

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

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

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

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

Do not mark all symbols as internal.

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

Strip symbol info from the executable to make it smaller.

An alias for -disable-internalize

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

Miscellaneous Options

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


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


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




Maintained by the LLVM Team (