Thread overview
Cannot make sense of LLD linker error with ldc 1.11.0
Aug 30, 2018
Per Nordlöw
Aug 30, 2018
Radu
Aug 30, 2018
kinke
Aug 30, 2018
kinke
Aug 30, 2018
Nordlöw
Aug 30, 2018
kinke
Sep 01, 2018
Nordlöw
Sep 01, 2018
kinke
Aug 30, 2018
Per Nordlöw
August 30, 2018
Recently the benchmark

https://github.com/nordlow/phobos-next/tree/master/benchmarks/containers/dub.sdl

run as

    dub run --compiler=ldc2 --build=release

has started to fail as

Performing "release" build using ldc2 for x86_64.
phobos-next ~master: target for configuration "library" is up to date.
benchmark-containers ~master: building configuration "application"...
lld: error: unknown argument: --no-warn-search-mismatch
lld: error: unable to find library -lzstd
lld: error: unable to find library -lz
lld: error: unable to find library -lbz2
lld: error: unable to find library -lrt
lld: error: unable to find library -ldl
lld: error: unable to find library -lpthread
lld: error: unable to find library -lm
Error: linking with LLD failed
ldc2 failed with exit code 1.
[

on latest stable ldc 1.11.0 on Ubuntu 18.04 x64.

Anybody got a clue what's wrong?

Is there a way to make use of the gold linker instead?
August 30, 2018
On Thursday, 30 August 2018 at 13:36:58 UTC, Per Nordlöw wrote:
> Recently the benchmark
>
> https://github.com/nordlow/phobos-next/tree/master/benchmarks/containers/dub.sdl
>
> [...]

There is a way to specify the linker to be used
```
-linker=<lld-link|lld|gold|bfd|...>           - Linker to use
```
August 30, 2018
On Thursday, 30 August 2018 at 13:36:58 UTC, Per Nordlöw wrote:
> [...]

LDC uses the C compiler as linker driver by default, exactly because the linker needs some setup (default lib dirs etc.). So this is almost certainly a dub issue.
August 30, 2018
Nope, I now think this is more likely an issue with the default config (etc/ldc2.conf). It contains a new section for WebAssembly, which specificies `-link-internally`, which seems to be wrongly used for non-WebAssembly too in your case.
I take it you're not using an official package, but a distro one?
August 30, 2018
On Thursday, 30 August 2018 at 16:12:24 UTC, kinke wrote:
> Nope, I now think this is more likely an issue with the default config (etc/ldc2.conf). It contains a new section for WebAssembly, which specificies `-link-internally`, which seems to be wrongly used for non-WebAssembly too in your case.
> I take it you're not using an official package, but a distro one?

I'm using the tar.xz for x64 Linux. Ok?
August 30, 2018
On Thursday, 30 August 2018 at 16:12:24 UTC, kinke wrote:
> Nope, I now think this is more likely an issue with the default config (etc/ldc2.conf). It contains a new section for WebAssembly, which specificies `-link-internally`, which seems to be wrongly used for non-WebAssembly too in your case.
> I take it you're not using an official package, but a distro one?

My mistake, I was using dmd's dub (at /usr/bin/dub) instead of ldc's.

As I prefer to have both installed at the same time, does anybody have any good trick to prevent this from happening in the future...some clever bash alias for instance?
August 30, 2018
On Thursday, 30 August 2018 at 19:41:38 UTC, Nordlöw wrote:
> I'm using the tar.xz for x64 Linux. Ok?

You're explicitly adding `-link-internally` in your top-level dub.sdl:

dflags "-link-internally" platform="linux-ldc" # use GNU gold linker

If you want to go with gold, as your comment suggests, you'd use `-linker=gold` instead. For more context wrt. `-link-internally` clumsiness on non-Windows, see https://github.com/ldc-developers/ldc/issues/2717.
September 01, 2018
On Thursday, 30 August 2018 at 20:36:02 UTC, kinke wrote:
> On Thursday, 30 August 2018 at 19:41:38 UTC, Nordlöw wrote:
>> I'm using the tar.xz for x64 Linux. Ok?
>
> You're explicitly adding `-link-internally` in your top-level dub.sdl:
>
> dflags "-link-internally" platform="linux-ldc" # use GNU gold linker
>
> If you want to go with gold, as your comment suggests, you'd use `-linker=gold` instead. For more context wrt. `-link-internally` clumsiness on non-Windows, see https://github.com/ldc-developers/ldc/issues/2717.

Thanks! Is there usually only apps and not libs that are supposed to have linker flags like these?
September 01, 2018
On Saturday, 1 September 2018 at 18:46:32 UTC, Nordlöw wrote:
> Thanks! Is there usually only apps and not libs that are supposed to have linker flags like these?

In this specific case, I'm not sure it's a good idea to set the linker in the dub config. Does it absolutely require gold, i.e., not work properly with bfd? There used to be issues with `-flto=thin` and bfd on Linux, but LDC now defaults to `-linker=gold` in that case.