Skip to content

Fix problem where ldc2 can't find linker - #4940

Merged
bdbaddog merged 1 commit into
SCons:masterfrom
mwichmann:maint/d-ldc2
Oct 24, 2026
Merged

bdbaddog merged 1 commit into
SCons:masterfrom
mwichmann:maint/d-ldc2

Conversation

@mwichmann

@mwichmann mwichmann commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem: on Ubuntu, you get ldc2 via a snap. The snap appears to be frozen in time (2021) and requires the gold linker. Google has lost interest in maintaining that as they're all in on llvm - and the llvm linker. As a result, binutils kicked ld.gold out of the main package as of 2.44. So now neither the linker ldc2 in the snap is built to require nor the logical alternative lld (the LLVM linker - ldc2 is LLVM based) are available in a default install of either Ubuntu or Fedora.

The workaround here isn't ideal: we add a flag to DLINKFLAGS (for ldc tool only) to request the always-present bfd linker - which the ldc team took explicit pains to avoid. Along the way, found that the way the $DC is handled had a problem - values given to WhereIs for program finding are allowed to include args, and that was the first thing I tried, but that failed in the assumptions in DCommon. So that's fiddled a little bit - would like a review of this part.

Testing would be to install the ldc snap on Unbuntu, so the tests are actually run instead of skipping. On my test VMs with recent Ubuntu releases they were failing and now pass. Note that we don't install this snap, or in fact, any snap, in any of the GitHub runner images.

There aren't really any doc impacts, though we could consider adding a note to the docs somewhere about this new default - not quite sure where. DLINKFLAGS is generic - applies to all three known D compilers. Other compiler-specific settings are not called out in the docs.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

Problem: on Ubuntu, you get ldc2 via a snap.  The snap appears to be
frozen in time (2021) and requires the "gold" linker. Google has lost
interest in maintaining that as they're all in on llvm - and the llvm
linker. As a result, binutils kicked ld.gold out of the main package as of
2.44. So now neither the linker ldc2 in the snap requires nor the logical
alternative lld (the LLVM linker - ldc2 is LLVM based) are available
in a default install of either Ubuntu or Fedora.

The workaround here isn't ideal: we add a default flag to DLINKFLAGS
(for ldc tool only) to request the always-present bfd linker.  Along the
way, found that the way the $DC is handled had a problem - values given
to WhereIs for program finding are allowed to include args, and that was the first thing I
tried, but that failed in the assumptions in DCommon. So that's fiddled
a little bit - would like a review of this part.

Signed-off-by: Mats Wichmann <mats@linux.com>
@mwichmann

mwichmann commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Just to include this note - this isn't an SCons problem, the PR just proposes a workaround. You can reproduce outside SCons with something as simple as this, assuming package binutils.gold is not installed:

$ printf 'void main(){}' > t.d
$ ldc2 t.d
collect2: fatal error: cannot find 'ld'
compilation terminated.
Error: /usr/bin/cc failed with status: 1

@bdbaddog
bdbaddog merged commit ae8a706 into SCons:master Oct 24, 2026
12 checks passed
@mwichmann mwichmann added this to the NextRelease milestone Oct 25, 2026
@mwichmann
mwichmann deleted the maint/d-ldc2 branch October 25, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants