[From nobody Sun Mar 15 10:51:06 2026
Received: (at submit) by bugs.debian.org; 14 Jan 2026 06:32:47 +0000
X-Spam-Checker-Version: SpamAssassin 4.0.1-bugs.debian.org_2005_01_02
 (2024-03-25) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-13.3 required=4.0 tests=BAYES_00,
 BODY_INCLUDES_PACKAGE,FOURLA,HAS_PACKAGE,MONEY,RCVD_IN_PBL,
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,
 RCVD_IN_VALIDITY_SAFE_BLOCKED,RDNS_NONE,SPF_FAIL,STOCKLIKE,
 XMAILER_REPORTBUG autolearn=ham autolearn_force=no
 version=4.0.1-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 84; hammy, 150; neutral, 147; spammy,
 0. spammytokens: hammytokens:0.000-+--XDebbugsCc,
 0.000-+--X-Debbugs-Cc, 0.000-+--armhf, 0.000-+--sk:taint_u,
 0.000-+--sk:TAINT_U
Return-path: &lt;fanpeng@loongson.cn&gt;
Received: from [111.9.175.10] (port=39466 helo=[192.168.100.2])
 by buxtehude.debian.org with esmtp (Exim 4.96)
 (envelope-from &lt;fanpeng@loongson.cn&gt;) id 1vfuQt-00EZ5V-1c
 for submit@bugs.debian.org; Wed, 14 Jan 2026 06:32:46 +0000
Content-Type: multipart/mixed; boundary=&quot;===============3399123188049324836==&quot;
MIME-Version: 1.0
From: fanpeng &lt;fanpeng@loongson.cn&gt;
To: Debian Bug Tracking System &lt;submit@bugs.debian.org&gt;
Subject: ghc: enable ld override for loong64
Message-ID: &lt;176837234945.148.9699852595406602700.reportbug@7a1ee4237e28&gt;
X-Mailer: reportbug 13.2.0
Date: Wed, 14 Jan 2026 06:32:29 +0000
Delivered-To: submit@bugs.debian.org

This is a multi-part MIME message sent by reportbug.


--===============3399123188049324836==
Content-Type: text/plain; charset=&quot;us-ascii&quot;
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: ghc
Version: 9.10.3-1
Severity: normal
X-Debbugs-Cc: fanpeng@loongson.cn

Dear Maintainer,

On Loong64, NCG is currently not supported in 9.10, while Llvm backend
incompatible with tables-next-to-code, which will generate PLT for non-
function symbols.

Only lld can correctly link it.
Specifics can be seen: https://gitlab.haskell.org/ghc/ghc/-/issues/25531


And the 0005-* patch is also required for C files.

-- System Information:
Debian Release: forky/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: loong64 (loongarch64)

Kernel: Linux 6.6.34-9.2.loongarch64 (SMP w/32 CPU threads)
Kernel taint flags: TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages ghc depends on:
ii  dpkg            1.22.21
ii  gcc             4:15.2.0-4
ii  libbsd-dev      0.12.2-2
ii  libc6           2.41-12
ii  libc6-dev       2.41-12
ii  libffi-dev      3.5.2-2
ii  libffi8         3.5.2-2
ii  libgmp-dev      2:6.3.0+dfsg-5
ii  libgmp10        2:6.3.0+dfsg-5
ii  libncurses-dev  6.5+20250216-2
ii  libnuma-dev     2.0.19-1
ii  libnuma1        2.0.19-1
ii  libtinfo6       6.5+20250216-2
ii  llvm-18         1:18.1.8-18+b2

Versions of packages ghc recommends:
ii  libstdc++-14-dev  14.3.0-8

Versions of packages ghc suggests:
pn  ghc-doc   &lt;none&gt;
pn  ghc-prof  &lt;none&gt;
ii  perl      5.40.1-6

-- no debconf information

--===============3399123188049324836==
Content-Type: text/plain; charset=&quot;us-ascii&quot;
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=&quot;ghc-9.10-enable-ld-override-for-loong64.diff&quot;

diff --git a/debian/control b/debian/control
index 77953ea..7156175 100644
--- a/debian/control
+++ b/debian/control
@@ -19,6 +19,8 @@ Build-Depends:
   hadrian:native (&lt;&lt; 9.10.4~) &lt;!pkg.ghc.nohadrian&gt;,
   llvm-21 (&gt;= 1:21.1.6) [armel armhf s390x riscv64 loong64],
   clang-21 [armel armhf s390x riscv64 loong64],
+  lld-21 [loong64],
+  lld [loong64],
   libgmp-dev,
   libffi-dev,
   libncurses-dev,
diff --git a/debian/patches/series b/debian/patches/series
index 6ee5568..6c5d885 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -16,7 +16,7 @@ time_t-time
 llvm-newer-version
 alpha-fix-ieee_set_fp_control-invocation.patch
 # 0004-llvmGen-Pass-mcmodel-medium-option-to-LLVM-backend-on-LoongArch.patch
-# 0005-Pass-the-mcmodel-medium-parameter-to-CC-via-GHC.patch
+0005-Pass-the-mcmodel-medium-parameter-to-CC-via-GHC.patch
 hadrian-bootstrap-plan
 hadrian-unreg-template-haskell
 gnu-hurd
diff --git a/debian/rules b/debian/rules
index 5f69aae..cc83476 100755
--- a/debian/rules
+++ b/debian/rules
@@ -106,9 +106,10 @@ ifneq (,$(filter noopt, $(DEB_BUILD_OPTIONS)))
 endif
 
 ifneq (,$(filter loong64, $(DEB_HOST_ARCH)))
-  EXTRA_HADRIAN_FLAGS += &quot;*.*.ghc.c.opts += -optc-mcmodel=medium&quot;
-  EXTRA_HADRIAN_FLAGS += &quot;*.*.ghc.hs.opts += -optc-mcmodel=medium&quot;
-  EXTRA_HADRIAN_FLAGS += &quot;*.*.cc.c.opts += -optc-mcmodel=medium&quot;
+# See https://gitlab.haskell.org/ghc/ghc/-/issues/25531
+# Llvm backend is not compatible with PLT, ld will generate wrong relocs.
+  EXTRA_CONFIGURE_FLAGS += --enable-ld-override
+  EXTRA_INSTALL_CONFIGURE_FLAGS += --enable-ld-override
 endif
 
 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))

--===============3399123188049324836==--
]