Choosing a non-default linker for dmd (via dub)

WebFreak001 d.forum at webfreak.org
Mon Jul 13 12:52:51 UTC 2020


On Sunday, 12 July 2020 at 16:36:09 UTC, Per Nordlöw wrote:
> The line
>
> dflags "-linker=gold" platform="linux-ldc" # use GNU gold linker
>
> in dub.sdl
>
> enables me to change linker for LDC.
>
> Is it possible to choose a specific linker for DMD aswell in a 
> similar way?
>
> I only find the flag `-L` that sets flags but no linker 
> executable.
>
> One way is to link
>
>     /usr/bin/ld
>
> to either
>
>     /usr/bin/ld.gold
>
> or
>
>     /usr/bin/ld.lld
>
> but it would be nice to be able to do this from the dub.sdl or 
> the command-line call to dub.

dub links using the compiler, so it basically just runs `dmd 
[flags] [files-to-link]`

In the DMD documentation you can see that it just runs gcc: 
https://dlang.org/dmd-linux.html#linking

Personally I always `ln -s /usr/bin/ld.gold /usr/local/bin/ld` to 
make ld.gold the default.


More information about the Digitalmars-d-learn mailing list