OS Manuals

/usr/bin/ld64.lld

LLVM linker

From lld-14 14.0.6-r12 (enterprise-packages), captured 2026-11-08 by running ld64.lld --help (exit 0). permalink

OVERVIEW: LLVM Linker

USAGE: /usr/bin/ld64.lld [options] file...

ADDITIONAL CONTENT:
  -add_empty_section <segment> <section>
                   Create an empty <section> in <segment>
  -filelist <file> Read names of files to link from <file>
  -sectcreate <segment> <section> <file>
                   Create <section> in <segment> from the contents of <file>
  -segcreate <segment> <section> <file>
                   Alias for -sectcreate

BITCODE BUILD FLOW:
  -bitcode_bundle Generate an embedded bitcode bundle in the __LLVM,__bundle section of the output

CREATING A BUNDLE:
  -bundle_loader <executable>
   Resolve undefined symbols from <executable>

DYNAMIC LIBRARIES (DYLIB):
  -compatibility_version <version>
                       Compatibility <version> of this library
  -current_version <version>
                       Current <version> of this library
  -dylib_install_name <name>
                       Alias for -install_name
  -dylinker_install_name <name>
                       Alias for -install_name
  -install_name <name> Set an internal install path in a dylib
  -mark_dead_strippable_dylib
                       Mark output dylib as dead-strippable: When a client links against it but does not use any of its symbols, the dylib will not be added to the client's list of needed dylibs

INTROSPECTING THE LINKER:
  -dependency_info <path> Dump dependency info
  -map <path>             Writes all symbols and their addresses to <path>
  -save-temps             Save intermediate LTO compilation results
  -t                      Log every file the linker loads: object, archive, and dylib
  -why_load               Log why each object file is loaded from a static library
  -whyload                Alias for -why_load

LIBRARIES:
  -all_load              Load all members of all static archive libraries
  -force_load_swift_libs Apply -force_load to libraries listed in LC_LINKER_OPTIONS whose names start with 'swift'
  -force_load <path>     Load all members static archive library at <path>
  -framework <name>      Search for <name>.framework/<name> on the framework search path
  -F <dir>               Add dir to the framework search path
  -L <dir>               Add dir to the library search path
  -l<name>               Search for lib<name>.dylib or lib<name>.a on the library search path
  -needed-l<name>        Like -l<name>, but link library even if its symbols are not used and -dead_strip_dylibs is active
  -needed_framework <name>
                         Like -framework <name>, but link <name> even if none of its symbols are used and -dead_strip_dylibs is active
  -needed_library <path> Like bare <path>, but link library even if its symbols are not used and -dead_strip_dylibs is active
  -noall_load            Don't load all static members from archives, this is the default, this negates -all_load
  -ObjC                  Load all members of static archives that are an Objective-C class or category.
  -reexport-l<name>      Like -l<name>, but export all symbols of <name> from newly created library
  -reexport_framework <name>
                         Like -framework <name>, but export all symbols of <name> from the newly created library
  -reexport_library <path>
                         Like bare <path>, but export all symbols of <path> from newly created library
  -search_dylibs_first   Search for lib<name>.dylib on first pass, then for lib<name>.a on second pass through search path (default for Xcode 3 and earlier)
  -search_paths_first    Search for lib<name>.dylib and lib<name>.a at each step in traversing search path (default for Xcode 4 and later)
  -syslibroot <rootdir>  Prepend <rootdir> to all library and framework search paths
  -weak-l<name>          Like -l<name>, but mark library and its references as weak imports
  -weak_framework <name> Like -framework <name>, but mark framework and its references as weak imports
  -weak_library <path>   Like bare <path>, but mark library and its references as weak imports
  -Z                     Remove standard directories from the library and framework search paths

LLD-SPECIFIC:
  --call-graph-profile-sort
                         Reorder sections with call graph profile (default)
  --color-diagnostics=[auto,always,never]
                         Use colors in diagnostics (default: auto)
  --color-diagnostics    Alias for --color-diagnostics=always
  --deduplicate-literals Enable literal deduplication. This is implied by --icf={safe,all}
  --error-limit=<value>  Maximum number of errors to print before exiting (default: 20)
  --help-hidden          Display help for hidden options
  --icf=[none,safe,all]  Set level for identical code folding (default: none)
  --lto-legacy-pass-manager
                         Use the legacy pass manager in LLVM
  --lto-O<opt-level>     Set optimization level for LTO (default: 2)
  --no-call-graph-profile-sort
                         Do not reorder sections with call graph profile
  --no-color-diagnostics Alias for --color-diagnostics=never
  --no-lto-legacy-pass-manager
                         Use the new pass manager in LLVM
  --no-warn-dylib-install-name<value>
                         Do not warn on -install-name if -dylib is not passed (default)
  --print-dylib-search   Print which paths lld searched when trying to find dylibs
  --print-symbol-order=<value>
                         Print a symbol order specified by --call-graph-profile-sort into the specified file
  --reproduce=<value>    Write tar file containing inputs and command to reproduce link
  --thinlto-cache-policy=<value>
                         Pruning policy for the ThinLTO cache
  --thinlto-jobs=<value> Number of ThinLTO jobs. Default to --threads=
  --threads=<value>      Number of threads. '1' disables multi-threading. By default all available hardware threads are used
  --time-trace-file=<value>
                         Specify time trace output file
  --time-trace-granularity=<value>
                         Minimum time granularity (in microseconds) traced by time profiler
  --time-trace           Record time trace
  --version              Display the version number and exit
  --warn-dylib-install-name<value>
                         Warn on -install-name if -dylib is not passed

MAIN EXECUTABLE:
  -export_dynamic Preserve all global symbols during LTO and when dead-stripping executables
  -no_pie         Do not build a position independent executable
  -pie            Build a position independent executable (default)

OBSOLETE:
  -lto_library <path> Obsolete. LLD supports LTO directly, without using an external dylib.
  -sectorder <segname> <sectname> <orderfile>
                      Obsolete. Replaced by more general -order_file option

OPTIMIZATIONS:
  -dead_strip         Remove unreachable functions and data
  -no_deduplicate     Disable code deduplicaiton (synonym for `--icf=none')
  -no_implicit_dylibs Do not optimize public dylib transitive symbol references
  -order_file <file>  Layout functions and data according to specification in <file>

OPTIONS:
  -demangle   Demangle symbol names in diagnostics
  --end-lib   End a grouping of objects that should be treated as if they were together in an archive
  -O <value>  Optimize output file size
  --start-lib Start a grouping of objects that should be treated as if they were together in an archive

OUTPUT KIND:
  -arch <arch_name> The architecture (e.g. ppc, ppc64, i386, x86_64)
  -bundle           Produce a bundle
  -dylib            Produce a shared library
  -dynamic          Link dynamically (default)
  -execute          Produce a main executable (default)
  -o <path>         The name of the output file (default: `a.out')

RARELY USED:
  -adhoc_codesign         Write an ad-hoc code signature to the output file (default for arm64 binaries)
  -application_extension  Mark output as safe for use in an application extension, and validate that linked dylibs are safe
  -arch_errors_fatal      Escalate to errors any warnings about inputs whose architecture does not match the -arch option
  -arch_multiple          Augment error and warning messages with the architecture name
  -cache_path_lto <path>  Use <path> as a directory for the incremental LTO cache
  -data_const             Force migration of readonly data into __DATA_CONST segment
  -dead_strip_dylibs      Remove dylibs that are unreachable by the entry point or exported symbols
  -e <symbol>             Make <symbol> the entry point of an executable (default is "start" from crt1.o)
  -fatal_warnings         Treat warnings as errors
  -final_output <name>    Specify dylib install name if -install_name is not used; used by compiler driver for multiple -arch arguments
  -headerpad_max_install_names
                          Allocate extra space so all load-command paths can expand to MAXPATHLEN via install_name_tool
  -headerpad <size>       Allocate hex <size> extra space for future expansion of the load commands via install_name_tool (default is 0x20)
  -max_relative_cache_size_lto <percent>
                          Limit the incremental LTO cache growth to <percent> of free disk, space
  -mcpu <value>           Processor family target for LTO code generation
  -mllvm <value>          Options to pass to LLVM
  -no_adhoc_codesign      Do not write an ad-hoc code signature to the output file (default for x86_64 binaries)
  -no_application_extension
                          Disable application extension functionality (default)
  -no_data_const          Block migration of readonly data away from __DATA segment
  -no_dtrace_dof          Disable dtrace-dof processing (default).
  -no_function_starts     Do not create table of function start addresses
  -object_path_lto <path> Retain any temporary mach-o file in <path> that would otherwise be deleted during LTO
  -prune_after_lto <seconds>
                          Remove LTO cache entries after <seconds>
  -prune_interval_lto <seconds>
                          Prune the incremental LTO cache after <seconds> (-1 disables pruning)
  -rename_section <from_segment> <from_section> <to_segment> <to_section>
                          Rename <from_segment>/<from_section> as <to_segment>/<to_section>
  -rename_segment <from_segment> <to_segment>
                          Rename <from_segment> as <to_segment>
  -sectalign <segment> <section> <boundary>
                          Align <section> within <segment> to hex power-of-2 <boundary>
  -segprot <segment> <max> <init>
                          Specifies the <max> and <init> virtual memory protection of <segment> as r/w/x/-seg_addr_table path
  -sub_library <name>     Re-export the dylib as <name>
  -sub_umbrella <name>    Re-export the framework as <name>
  -umbrella <name>        Re-export this dylib through the umbrella framework <name>
  -v                      Print the linker version and search paths in addition to linking

SYMBOL RESOLUTION:
  -exported_symbols_list <file>
                         Symbols specified in <file> remain global, while others become private externs
  -exported_symbol <symbol>
                         <symbol> remains global, while others become private externs
  -flat_namespace        Resolve symbols from all dylibs, both direct and transitive. Do not record source libraries: dyld must re-search at runtime and use the first definition found
  -rpath <path>          Add <path> to dyld search list for dylibs with load path prefix `@rpath/'
  -twolevel_namespace    Make dyld look up symbols by (dylib,name) pairs (default)
  -undefined <treatment> Handle undefined symbols according to <treatment>: error, warning, suppress, or dynamic_lookup (default is error)
  -unexported_symbols_list <file>
                         Global symbols specified in <file> become private externs
  -unexported_symbol <symbol>
                         Global <symbol> becomes private extern
  -U <symbol>            Allow <symbol> to have no definition
  -u <symbol>            Require that <symbol> be defined for the link to succeed

SYMBOL TABLE:
  -add_ast_path <path> AST paths will be emitted as STABS
  -oso_prefix <path>   Remove the prefix <path> from OSO symbols in the debug map
  -S                   Strip debug information (STABS or DWARF) from the output

UNDOCUMENTED:
  -data_in_code_info    Emit data-in-code information (default)
  -encryptable          Generate the LC_ENCRYPTION_INFO load command
  -function_starts      Create table of function start addresses (default)
  -no_data_in_code_info Do not emit data-in-code information
  -no_encryption        Do not generate the LC_ENCRYPTION_INFO load command

VERSION TARGETING:
  -macos_version_min <version>
   Oldest macOS version for which linked output is usable
  -platform_version <platform> <min_version> <sdk_version>
   Platform (e.g., macos, ios, tvos, watchos, bridgeos, mac-catalyst, ios-sim, tvos-sim, watchos-sim, driverkit) and version numbers
Options (105)
OptionDescriptionSource
-bundle_loader executableResolve undefined symbols from <executable>help
-compatibility_version versionCompatibility <version> of this libraryhelp
-current_version versionCurrent <version> of this libraryhelp
-dylib_install_name nameAlias for -install_namehelp
-dylinker_install_name nameAlias for -install_namehelp
-mark_dead_strippable_dylibMark output dylib as dead-strippable: When a client links against it but does not use any of its symbols, the dylib will not be added to the client's list of needed dylibshelp
-map pathWrites all symbols and their addresses to <path>help
-save-tempsSave intermediate LTO compilation resultshelp
-tLog every file the linker loads: object, archive, and dylibhelp
-why_loadLog why each object file is loaded from a static libraryhelp
-whyloadAlias for -why_loadhelp
-all_loadLoad all members of all static archive librarieshelp
-force_load pathLoad all members static archive library at <path>help
-framework nameSearch for <name>.framework/<name> on the framework search pathhelp
-F dirAdd dir to the framework search pathhelp
-L dirAdd dir to the library search pathhelp
-l nameSearch for lib<name>.dylib or lib<name>.a on the library search pathhelp
-needed-l nameLike -l<name>, but link library even if its symbols are not used and -dead_strip_dylibs is activehelp
-needed_framework nameLike -framework <name>, but link <name> even if none of its symbols are used and -dead_strip_dylibs is activehelp
-noall_loadDon't load all static members from archives, this is the default, this negates -all_loadhelp
-ObjCLoad all members of static archives that are an Objective-C class or category.help
-reexport-l nameLike -l<name>, but export all symbols of <name> from newly created libraryhelp
-reexport_framework nameLike -framework <name>, but export all symbols of <name> from the newly created libraryhelp
-reexport_library pathLike bare <path>, but export all symbols of <path> from newly created libraryhelp
-search_dylibs_firstSearch for lib<name>.dylib on first pass, then for lib<name>.a on second pass through search path (default for Xcode 3 and earlier)help
-search_paths_firstSearch for lib<name>.dylib and lib<name>.a at each step in traversing search path (default for Xcode 4 and later)help
-syslibroot rootdirPrepend <rootdir> to all library and framework search pathshelp
-weak-l nameLike -l<name>, but mark library and its references as weak importshelp
-weak_library pathLike bare <path>, but mark library and its references as weak importshelp
-ZRemove standard directories from the library and framework search pathshelp
--call-graph-profile-sortReorder sections with call graph profile (default)help
--color-diagnostics autoUse colors in diagnostics (default: auto)help
--error-limit valueMaximum number of errors to print before exiting (default: 20)help
--help-hiddenDisplay help for hidden optionshelp
--icf noneSet level for identical code folding (default: none)help
--lto-legacy-pass-managerUse the legacy pass manager in LLVMhelp
--lto-O opt-levelSet optimization level for LTO (default: 2)help
--no-call-graph-profile-sortDo not reorder sections with call graph profilehelp
--no-lto-legacy-pass-managerUse the new pass manager in LLVMhelp
--no-warn-dylib-install-name valueDo not warn on -install-name if -dylib is not passed (default)help
--print-dylib-searchPrint which paths lld searched when trying to find dylibshelp
--print-symbol-order valuePrint a symbol order specified by --call-graph-profile-sort into the specified filehelp
--reproduce valueWrite tar file containing inputs and command to reproduce linkhelp
--thinlto-cache-policy valuePruning policy for the ThinLTO cachehelp
--threads valueNumber of threads.help
--time-trace-file valueSpecify time trace output filehelp
--time-trace-granularity valueMinimum time granularity (in microseconds) traced by time profilerhelp
--time-traceRecord time tracehelp
--versionDisplay the version number and exithelp
--warn-dylib-install-name valueWarn on -install-name if -dylib is not passedhelp
-no_pieDo not build a position independent executablehelp
-pieBuild a position independent executable (default)help
-dead_stripRemove unreachable functions and datahelp
-no_deduplicateDisable code deduplicaiton (synonym for `--icf=none')help
-order_file fileLayout functions and data according to specification in <file>help
-demangleDemangle symbol names in diagnosticshelp
--end-libEnd a grouping of objects that should be treated as if they were together in an archivehelp
-O valueOptimize output file sizehelp
-bundleProduce a bundlehelp
-dylibProduce a shared libraryhelp
-dynamicLink dynamically (default)help
-executeProduce a main executable (default)help
-o pathThe name of the output file (default: `a.out')help
-adhoc_codesignWrite an ad-hoc code signature to the output file (default for arm64 binaries)help
-application_extensionMark output as safe for use in an application extension, and validate that linked dylibs are safehelp
-arch_errors_fatalEscalate to errors any warnings about inputs whose architecture does not match the -arch optionhelp
-arch_multipleAugment error and warning messages with the architecture namehelp
-cache_path_lto pathUse <path> as a directory for the incremental LTO cachehelp
-data_constForce migration of readonly data into __DATA_CONST segmenthelp
-dead_strip_dylibsRemove dylibs that are unreachable by the entry point or exported symbolshelp
-e symbolMake <symbol> the entry point of an executable (default is "start" from crt1.o)help
-fatal_warningsTreat warnings as errorshelp
-final_output nameSpecify dylib install name if -install_name is not used;help
-headerpad_max_install_namesAllocate extra space so all load-command paths can expand to MAXPATHLEN via install_name_toolhelp
-headerpad sizeAllocate hex <size> extra space for future expansion of the load commands via install_name_tool (default is 0x20)help
-max_relative_cache_size_lto percentLimit the incremental LTO cache growth to <percent> of free disk, spacehelp
-mcpu valueProcessor family target for LTO code generationhelp
-mllvm valueOptions to pass to LLVMhelp
-no_adhoc_codesignDo not write an ad-hoc code signature to the output file (default for x86_64 binaries)help
-no_application_extensionDisable application extension functionality (default)help
-no_data_constBlock migration of readonly data away from __DATA segmenthelp
-no_dtrace_dofDisable dtrace-dof processing (default).help
-no_function_startsDo not create table of function start addresseshelp
-prune_after_lto secondsRemove LTO cache entries after <seconds>help
-prune_interval_lto secondsPrune the incremental LTO cache after <seconds> (-1 disables pruning)help
-sub_library nameRe-export the dylib as <name>help
-sub_umbrella nameRe-export the framework as <name>help
-umbrella nameRe-export this dylib through the umbrella framework <name>help
-vPrint the linker version and search paths in addition to linkinghelp
-exported_symbols_list fileSymbols specified in <file> remain global, while others become private externshelp
-exported_symbol symbol<symbol> remains global, while others become private externshelp
-flat_namespaceResolve symbols from all dylibs, both direct and transitive.help
-rpath pathAdd <path> to dyld search list for dylibs with load path prefix `@rpath/'help
-twolevel_namespaceMake dyld look up symbols by (dylib,name) pairs (default)help
-unexported_symbols_list fileGlobal symbols specified in <file> become private externshelp
-unexported_symbol symbolGlobal <symbol> becomes private externhelp
-U symbolAllow <symbol> to have no definitionhelp
-u symbolRequire that <symbol> be defined for the link to succeedhelp
-oso_prefix pathRemove the prefix <path> from OSO symbols in the debug maphelp
-SStrip debug information (STABS or DWARF) from the outputhelp
-data_in_code_infoEmit data-in-code information (default)help
-encryptableGenerate the LC_ENCRYPTION_INFO load commandhelp
-function_startsCreate table of function start addresses (default)help
-no_encryptionDo not generate the LC_ENCRYPTION_INFO load commandhelp
-macos_version_min versionOldest macOS version for which linked output is usablehelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.