Bug#1128371: ghc: Hurd fixes

Samuel Thibault sthibault at debian.org
Wed Feb 18 21:11:41 GMT 2026


Package: ghc
Version: 9.6.6-4
Severity: important
Tags: patch upstream
Forwarded: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15319

Hello,

A few patches are needed to fix building ghc on hurd-any. The attached
three patches have already been applied upstream, could you apply them
to the Debian package?

Thanks,
Samuel

-- System Information:
Debian Release: forky/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'proposed-updates'), (500, 'oldstable-debug'), (500, 'oldoldstable'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, arm64

Kernel: Linux 6.19.0 (SMP w/22 CPU threads; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ghc depends on:
ii  dpkg            1.23.5
ii  gcc             4:15.2.0-5
ii  libbsd-dev      0.12.2-2+b1
ii  libc6           2.42-11+b1
ii  libc6-dev       2.42-11+b1
ii  libffi-dev      3.5.2-3+b1
ii  libffi8         3.5.2-3+b1
ii  libgmp-dev      2:6.3.0+dfsg-5+b1
ii  libgmp10        2:6.3.0+dfsg-5+b1
ii  libncurses-dev  6.6+20251231-1
ii  libnuma-dev     2.0.19-1+b1
ii  libnuma1        2.0.19-1+b1
ii  libtinfo6       6.6+20251231-1

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

Versions of packages ghc suggests:
pn  ghc-doc   <none>
pn  ghc-prof  <none>
ii  llvm-18   1:18.1.8-20+b2
ii  perl      5.40.1-7

-- no debconf information
-------------- next part --------------
commit bf4694e9d10b7d9898ed1e3cd7ae115fd33ac725
Author: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date:   Sat Jan 10 15:53:10 2026 +0100

    Fix linking against libm by moving the -lm option
    
    For those systems that need -lm for getting math functions, this is
    currently added on the link line very early, before the object files being
    linked together. Newer toolchains enable --as-needed by default, which means
    -lm is ignored at that point because no object requires a math function
    yet. With such toolchains, we thus have to add -lm after the objects, so the
    linker actually includes libm in the link.

---
 compiler/GHC/Linker/Dynamic.hs |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15319

--- a/compiler/GHC/Linker/Dynamic.hs
+++ b/compiler/GHC/Linker/Dynamic.hs
@@ -223,7 +223,6 @@ linkDynLib logger tmpfs dflags0 unit_env
 
             runLink logger tmpfs linker_config (
                     map Option verbFlags
-                 ++ libmLinkOpts platform
                  ++ [ Option "-o"
                     , FileOption "" output_fn
                     ]
@@ -234,6 +233,7 @@ linkDynLib logger tmpfs dflags0 unit_env
                     -- Solaris 10 doesn't support the latter:
                  ++ [ Option ("-Wl,-h," ++ takeFileName output_fn) ]
                  ++ extra_ld_inputs
+                 ++ libmLinkOpts platform
                  ++ map Option lib_path_opts
                  ++ map Option pkg_lib_path_opts
                  ++ map Option pkg_link_opts
-------------- next part --------------
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15318

+

>From 3939a8bf93e27d8151aa1d92bf3ce10bbbc96a72 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date: Sun, 15 Sep 2024 15:57:52 +0200
Subject: [PATCH] GNU/Hurd: Add getExecutablePath support

GNU/Hurd exposes it as /proc/self/exe just like on Linux.
---
 .../src/GHC/Internal/System/Environment/ExecutablePath.hsc  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: ghc-9.10.3/libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
===================================================================
--- ghc-9.10.3.orig/libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
+++ ghc-9.10.3/libraries/ghc-internal/src/GHC/Internal/System/Environment/ExecutablePath.hsc
@@ -51,7 +51,7 @@ import GHC.Internal.Foreign.Ptr
 import GHC.Internal.Foreign.Storable
 import GHC.Internal.System.IO.Error (isDoesNotExistError)
 import GHC.Internal.System.Posix.Internals
-#elif defined(linux_HOST_OS)
+#elif defined(linux_HOST_OS) || defined(gnu_HOST_OS)
 import GHC.Internal.Data.Functor
 import GHC.Internal.Data.List (isSuffixOf)
 import GHC.Internal.Foreign.C.Types
@@ -200,9 +200,9 @@ executablePath = Just (fmap Just getExec
       | otherwise             = throw e
 
 --------------------------------------------------------------------------------
--- Linux / Solaris
+-- Linux / Solaris / Hurd
 
-#elif defined(linux_HOST_OS) || defined(solaris2_HOST_OS)
+#elif defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(gnu_HOST_OS)
 
 foreign import ccall unsafe "readlink"
     c_readlink :: CString -> CString -> CSize -> IO CInt
@@ -219,7 +219,7 @@ readSymbolicLink file =
                    c_readlink s buf 4096
             peekFilePathLen (buf,fromIntegral len)
 
-#  if defined(linux_HOST_OS)
+#  if defined(linux_HOST_OS) || defined(gnu_HOST_OS)
 getExecutablePath = readSymbolicLink $ "/proc/self/exe"
 
 executablePath = Just (check <$> getExecutablePath) where
-------------- next part --------------
commit 95773d289c62373772f676df91c1278b7d382e30
Author: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date:   Sat Jan 10 15:59:18 2026 +0100

    Fix the OS string encoding for GNU/Hurd
    
    Following https://github.com/haskell/cabal/pull/9434/files , and as seen
    in the various gnu_HOST_OS usages in the source code, it is expected that
    GNU/Hurd is advertised as "gnu", like the autotools do.

https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15320
https://github.com/haskell/cabal/pull/11401

--- a/libraries/Cabal/Cabal/src/Distribution/Simple/PreProcess.hs
+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/PreProcess.hs
@@ -780,7 +780,7 @@ platformDefines lbi =
       Android -> ["android"]
       Ghcjs -> ["ghcjs"]
       Wasi -> ["wasi"]
-      Hurd -> ["hurd"]
+      Hurd -> ["gnu"]
       Haiku -> ["haiku"]
       OtherOS _ -> []
     archStr = case hostArch of
--- a/libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
+++ b/libraries/ghc-platform/src/GHC/Platform/ArchOS.hs
@@ -157,7 +157,7 @@ stringEncodeOS = \case
   OSHaiku     -> "haiku"
   OSQNXNTO    -> "nto-qnx"
   OSAIX       -> "aix"
-  OSHurd      -> "hurd"
+  OSHurd      -> "gnu"
   OSWasi      -> "wasi"
   OSGhcjs     -> "ghcjs"
 


More information about the Pkg-haskell-maintainers mailing list