Skip to main content

argv

Function argv 

Source
pub fn argv(
    target: TargetTuple,
    sysroot: &Sysroot,
    options: &Invocation<'_>,
) -> Result<Vec<String>, Unsupported>
Expand description

The whole linker command line for this target, not counting the linker itself.

Section 11.3’s eight items, in the order a linker wants them:

  1. -m, the output format, because a linker built for more than one machine guesses from its first input otherwise and a link of no objects has nothing to guess from.
  2. --sysroot, and every -L rooted inside it.
  3. -dynamic-linker, the one string on the line that describes the target’s filesystem rather than ours.
  4. The start files, by absolute path, in the order the two nested pairs need.
  5. The default libraries, which are ours rather than the host’s.
  6. librucc_builtins.a for the target, which LinkLine puts after the libc.
  7. No host paths at all.
  8. The format’s own extras, which on ELF is the hardening and reproducibility set below and on PE is the subsystem, the address space layout flags and the header timestamp.

Two formats reach a line here and the difference between them is the flags rather than the shape. Both are written in the GNU style, which is what ld, ld.lld and ld.lld in its MinGW mode all read, so the inputs, the -L directories and the passthrough are assembled once for both rather than twice.

§Errors

Unsupported::Format for a target whose object format is neither ELF nor PE, Unsupported::MsvcAbi for a Windows target in Microsoft’s ABI, Unsupported::Machine for a PE target with no machine type, and Unsupported::StaticStub for a static link against a libc that is a stub.