OVERVIEW: LLVM Linker USAGE: /usr/bin/ld64.lld [options] file... ADDITIONAL CONTENT: -add_empty_section
Create an empty
in -filelist Read names of files to link from -sectcreate
Create
in from the contents of -segcreate
Alias for -sectcreate CREATING A BUNDLE: -bundle_loader Resolve undefined symbols from DYNAMIC LIBRARIES (DYLIB): -compatibility_version Compatibility of this library -current_version Current of this library -dylib_install_name Alias for -install_name -dylinker_install_name Alias for -install_name -install_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 Dump dependency info -map Writes all symbols and their addresses to -save-temps Save intermediate LTO compilation results -t Log every file the linker loads: object, archive, and dylib -why_live Log a chain of references to , for use with -dead_strip -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 Load all members static archive library at -framework Search for .framework/ on the framework search path -F Add dir to the framework search path -hidden-l Like -l, but load all symbols with hidden visibility -load_hidden Load all symbols from static library with hidden visibility -L Add dir to the library search path -l Search for lib.dylib or lib.a on the library search path -needed-l Like -l, but link library even if its symbols are not used and -dead_strip_dylibs is active -needed_framework Like -framework , but link even if none of its symbols are used and -dead_strip_dylibs is active -needed_library Like bare , 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 Like -l, but export all symbols of from newly created library -reexport_framework Like -framework , but export all symbols of from the newly created library -reexport_library Like bare , but export all symbols of from newly created library -search_dylibs_first Search for lib.dylib on first pass, then for lib.a on second pass through search path (default for Xcode 3 and earlier) -search_paths_first Search for lib.dylib and lib.a at each step in traversing search path (default for Xcode 4 and later) -syslibroot Prepend to all library and framework search paths -weak-l Like -l, but mark library and its references as weak imports -weak_framework Like -framework , but mark framework and its references as weak imports -weak_library Like bare , 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) --check-category-conflicts Check for conflicts between category & class methods --color-diagnostics=[auto,always,never] Use colors in diagnostics (default: auto) --color-diagnostics Alias for --color-diagnostics=always --cs-profile-generate Perform context senstive PGO instrumentation --cs-profile-path= Context sensitive profile file path --dead-strip-duplicates Do not error on duplicate symbols that will be dead stripped. --deduplicate-strings Enable string deduplication --error-limit= 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) --ignore-auto-link-option= Ignore a single auto-linked library or framework. Useful to ignore invalid options that ld64 ignores --lto-CGO Set codegen optimization level for LTO (default: 2) --lto-debug-pass-manager Debug new pass manager --lto-O 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-deduplicate-strings Disable string deduplication. This helps uncover cases of comparing string addresses instead of equality and might have a link time performance benefit. --no-warn-dylib-install-name 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= Print a symbol order specified by --call-graph-profile-sort into the specified file --reproduce= Write tar file containing inputs and command to reproduce link --strict-auto-link Always warn for missing frameworks or libraries if they are loaded via LC_LINKER_OPTIONS --thinlto-cache-policy= Pruning policy for the ThinLTO cache --thinlto-jobs= Number of ThinLTO jobs. Default to --threads= --threads= Number of threads. '1' disables multi-threading. By default all available hardware threads are used --time-trace-granularity= Minimum time granularity (in microseconds) traced by time profiler --time-trace= Record time trace to --time-trace Record time trace to file next to output --version Display the version number and exit --warn-dylib-install-name 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 -pagezero_size Size of unreadable segment at address zero is hex (default is 4KB on 32-bit and 4GB on 64-bit) -pie Build a position independent executable (default) OBSOLETE: -lto_library Obsolete. LLD supports LTO directly, without using an external dylib. -sectorder Obsolete. Replaced by more general -order_file option OPTIMIZATIONS: -dead_strip Remove unreachable functions and data -no_deduplicate Disable code deduplication (synonym for `--icf=none') -no_implicit_dylibs Do not optimize public dylib transitive symbol references -order_file Layout functions and data according to specification in 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 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 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 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 Use 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 -dyld_env Specifies a LC_DYLD_ENVIRONMENT variable value pair. -e Make the entry point of an executable (default is "start" from crt1.o) -fatal_warnings Treat warnings as errors -final_output 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 Allocate hex extra space for future expansion of the load commands via install_name_tool (default is 0x20) -ignore_auto_link Ignore LC_LINKER_OPTIONs -max_relative_cache_size_lto Limit the incremental LTO cache growth to of free disk, space -mcpu Processor family target for LTO code generation -mllvm 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 -no_uuid Do not generate the LC_UUID load command -objc_stubs_fast Produce larger stubs for Objective-C method calls with fewer jumps (default). -objc_stubs_small Produce smaller stubs for Objective-C method calls with more jumps. -object_path_lto Retain any temporary mach-o file in that would otherwise be deleted during LTO -prune_after_lto Remove LTO cache entries after -prune_interval_lto Prune the incremental LTO cache after (-1 disables pruning) -rename_section Rename / as / -rename_segment Rename as -reproducible Make the output reproducible by removing timestamps and other non-deterministic data. This is the default behavior. -sectalign
Align
within to hex power-of-2 -segprot Specifies the and virtual memory protection of as r/w/x/-seg_addr_table path -sub_library Re-export the dylib as -sub_umbrella Re-export the framework as -umbrella Re-export this dylib through the umbrella framework -v Print the linker version and search paths in addition to linking -w Suppress all warnings SYMBOL RESOLUTION: -alias Create a symbol alias with default global visibility -exported_symbols_list Symbols specified in remain global, while others become private externs -exported_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 -no_exported_symbols Don't export any symbols from the binary, useful for main executables that don't have plugins -rpath Add to dyld search list for dylibs with load path prefix `@rpath/' -twolevel_namespace Make dyld look up symbols by (dylib,name) pairs (default) -undefined Handle undefined symbols according to : error, warning, suppress, or dynamic_lookup (default is error) -unexported_symbols_list Global symbols specified in become private externs -unexported_symbol Global becomes private extern -U Allow to have no definition -u Require that be defined for the link to succeed SYMBOL TABLE: -add_ast_path AST paths will be emitted as STABS -non_global_symbols_no_strip_list Specify in the non-global symbols that should remain in the output symbol table -non_global_symbols_strip_list Specify in the non-global symbols that should be removed from the output symbol table -oso_prefix Remove the prefix from OSO symbols in the debug map -S Strip debug information (STABS or DWARF) from the output -x Exclude non-global symbols from the output symbol table UNDOCUMENTED: -data_in_code_info Emit data-in-code information (default) -encryptable Generate the LC_ENCRYPTION_INFO load command -fixup_chains Emit chained fixups -function_starts Create table of function start addresses (default) -ignore_optimization_hints Ignore Linker Optimization Hints -init_offsets Store __TEXT segment offsets of static initializers -no_data_in_code_info Do not emit data-in-code information -no_encryption Do not generate the LC_ENCRYPTION_INFO load command -no_fixup_chains Emit fixup information as classic dyld opcodes VERSION TARGETING: -macos_version_min Oldest macOS version for which linked output is usable -platform_version Platform (e.g., macos, ios, tvos, watchos, bridgeos, mac-catalyst, ios-sim, tvos-sim, watchos-sim, driverkit) and version numbers