Skip to content

Feature: Integrate LLD, the LLVM cross-linker #2028

@kinke

Description

@kinke

My tests some weeks ago with LLD 3.9 on Win64 have shown that it really works out-of-the-box as drop-in replacement (lld-link.exe for DLLs and executables, llvm-lib.exe for static libraries) for Microsoft's tools, reading the same environment variables etc. All tests passed except for our CDB debugging tests, as debuginfos on Windows (.pdb) aren't implemented yet, that's the only drawback.

While LLD is supposed to be compact & fast and naturally allows for LLVM goodness like LTO, I see the primary advantage in getting rid of LDC's dependency on a target linker and gaining the ability to directly cross-compile and -link. All you need are the target system libs + target druntime/Phobos, and you'll be able to generate shared libs and executables for about any target supported by LLVM. No need for an external cross-linker or linking natively / in an emulator.

By linking the LLD library into LDC directly, we should be able to forward pretty much unchanged command lines to one of the 3 drivers, depending on targeted platform, instead of invoking the external linker (which should still be possible via cmdline option).
Without relying on an external LLD executable, detecting the MSVC++ installation and setting up the environment variables on Windows will have to be moved from the currently used batch files to LDC itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions