We need to communicate five things to the linker on Apple/Darwin targets:
Add arbitrary βlate linkβ args defined by the target spec.
FIXME: Determine where exactly these args need to be inserted.
Add sysroot and other globally set directories to the directory search list.
Add a link script embedded in the target, if applicable.
Add a synthetic object file that contains reference to all symbols that we want to expose to
the linker.
When using the linker flavors opting in to lld
, add the necessary paths and arguments to
invoke it:
Add object files for allocator code linked once for the whole crate tree.
Add object files containing metadata for the current crate.
Add object files containing code from the current crate.
Add arbitrary βpost-linkβ args defined by the target spec.
FIXME: Determine where exactly these args need to be inserted.
Add post-link object files defined by the target spec.
Add arbitrary βpre-linkβ args defined by the target spec or from command line.
FIXME: Determine where exactly these args need to be inserted.
Add pre-link object files defined by the target spec.
Add options making relocation sections in the produced ELF files read-only
and suppressing lazy binding.
Add library search paths used at runtime by dynamic linkers.
Add arbitrary βuser definedβ args defined from command line.
FIXME: Determine where exactly these args need to be inserted.
Extract all symbols defined in raw-dylib libraries, collated by library name.
Returns a boolean indicating whether the specified crate should be ignored
during LTO.
Performs the linkage portion of the compilation phase. This will generate all
of the requested outputs for this compilation session.
Use thorin
(rust implementation of a dwarf packaging utility) to link DWARF objects into a
DWARF package.
Create a dynamic library or executable.
Create an βrlibβ.
Create a static archive.
This functions tries to determine the appropriate linker (and corresponding LinkerFlavor) to use
Produce the linker command line containing linker path and arguments.
Returns a pair of boolean indicating whether we should preserve the object and
dwarf object files on the filesystem for their debug information. This is often
useful with split-dwarf like schemes.
Various toolchain components used during linking are used from rustc distribution
instead of being found somewhere on the host system.
We only provide such support for a very limited number of targets.