Use ld.gold on RHEL 8 and 9 (#2134875)

Keep on using ld.gold on RHEL 8 and 9 where using ldc with ld.bfd breaks
gtkd and leads to crashing tilix.

https://bugzilla.redhat.com/show_bug.cgi?id=2134875
epel9
Kalev Lember 2 years ago
parent c4f81ca46c
commit 8fa9d45577

@ -0,0 +1,50 @@
From f3e10a9aee4db798b5ac4a8b5cba9c037dff3faa Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Mon, 19 Dec 2022 13:58:03 +0100
Subject: [PATCH] Revert "Linux: Don't default to ld.gold linker"
Keep on using ld.gold on RHEL 8 and 9 where using ldc with ld.bfd breaks
gtkd and leads to crashing tilix.
https://bugzilla.redhat.com/show_bug.cgi?id=2134875
This reverts commit e125411e988679dfa8cbfc9dcfc05524a37589f7.
---
driver/linker-gcc.cpp | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/driver/linker-gcc.cpp b/driver/linker-gcc.cpp
index a53936a9aa..5ae90ce650 100644
--- a/driver/linker-gcc.cpp
+++ b/driver/linker-gcc.cpp
@@ -599,12 +599,22 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
void ArgsBuilder::addLinker() {
llvm::StringRef linker = opts::linker;
- // Default to ld.bfd for Android (placing .tdata and .tbss sections adjacent
- // to each other as required by druntime's rt.sections_android, contrary to
- // gold and lld as of Android NDK r21d).
- if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android &&
+ // We have a default linker preference for Linux targets. It can be disabled
+ // via `-linker=` (explicitly empty).
+ if (global.params.targetTriple->isOSLinux() &&
opts::linker.getNumOccurrences() == 0) {
- linker = "bfd";
+ // Default to ld.bfd for Android (placing .tdata and .tbss sections adjacent
+ // to each other as required by druntime's rt.sections_android, contrary to
+ // gold and lld as of Android NDK r21d).
+ if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) {
+ linker = "bfd";
+ }
+ // Otherwise default to ld.gold for Linux due to ld.bfd issues with ThinLTO
+ // (see #2278) and older bfd versions stripping llvm.used symbols (e.g.,
+ // ModuleInfo refs) with --gc-sections (see #2870).
+ else {
+ linker = "gold";
+ }
}
if (!linker.empty())
--
2.39.0

@ -14,7 +14,7 @@
Name: ldc
Epoch: 1
Version: 1.30.0%{?pre:~%{pre}}
Release: 2%{?dist}
Release: 4%{?dist}
Summary: LLVM D Compiler
# The DMD frontend in dmd/* GPL version 1 or artistic license
@ -28,6 +28,12 @@ Source3: macros.%{name}
Patch0: ldc-include-path.patch
# Don't add rpath to standard libdir
Patch1: ldc-no-default-rpath.patch
%if 0%{?rhel} && 0%{?rhel} <= 9
# Keep on using ld.gold on RHEL 8 and 9 where using ldc with ld.bfd breaks gtkd
# and leads to crashing tilix.
# https://bugzilla.redhat.com/show_bug.cgi?id=2134875
Patch2: 0001-Revert-Linux-Don-t-default-to-ld.gold-linker.patch
%endif
ExclusiveArch: %{ldc_arches} ppc64le
@ -173,6 +179,9 @@ install -m0644 phobos.d.tags %{buildroot}/%{_datadir}/geany/tags/
%{_datadir}/geany/tags/phobos.d.tags
%changelog
* Mon Dec 19 2022 Kalev Lember <klember@redhat.com> - 1:1.30.0-4
- Use ld.gold on RHEL 8 and 9 (#2134875)
* Mon Sep 12 2022 Kalev Lember <klember@redhat.com> - 1:1.30.0-2
- Bootstrap on ppc64le

Loading…
Cancel
Save