summary refs log tree commit diff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2023-01-29 18:45:45 +0100
committerLars-Dominik Braun <lars@6xq.net>2023-02-26 10:26:15 +0100
commit7df12c8ca631cc46f59da9ceeb883a28044dbb9e (patch)
tree6b374daecf552bb2730387497c592bfbf9086948 /gnu/packages/patches
parent4bb40b098d81e70ebaf86250cb0162bb285ef6ca (diff)
downloadguix-7df12c8ca631cc46f59da9ceeb883a28044dbb9e.tar.gz
gnu: ghc-9.2: Support static linking with glibc < 2.34.
* gnu/packages/patches/ghc-9.2-glibc-2.33-link-order.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/haskell.scm (ghc-9.2)[origin]: Use it.
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/ghc-9.2-glibc-2.33-link-order.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/gnu/packages/patches/ghc-9.2-glibc-2.33-link-order.patch b/gnu/packages/patches/ghc-9.2-glibc-2.33-link-order.patch
new file mode 100644
index 0000000000..5d4afa28c1
--- /dev/null
+++ b/gnu/packages/patches/ghc-9.2-glibc-2.33-link-order.patch
@@ -0,0 +1,35 @@
+Slightly modified version of
+https://gitlab.haskell.org/ghc/ghc/-/issues/19029#note_447989, required
+for older, buggy glibc versions < 2.34.
+
+diff -Naur ghc-9.2.5/compiler/GHC/Linker/Unit.hs ghc-9.2.5.patched/compiler/GHC/Linker/Unit.hs
+--- ghc-9.2.5/compiler/GHC/Linker/Unit.hs	2022-11-06 20:40:29.000000000 +0100
++++ ghc-9.2.5.patched/compiler/GHC/Linker/Unit.hs	2023-01-15 14:52:57.511275338 +0100
+@@ -31,11 +31,26 @@
+     ps <- mayThrowUnitErr $ preloadUnitsInfo' unit_env pkgs
+     return (collectLinkOpts dflags ps)
+ 
++fixOrderLinkOpts :: [String] -> [String]
++fixOrderLinkOpts opts
++  | have_bad_glibc_version -- glibc version strictly less than 2.34
++  , let (before, rest) = break (== libc) opts
++  , not (pthread `elem` before)
++  , pthread `elem` rest -- optional if we know pthread is definitely present
++  = before ++ pthread_and_deps ++ rest
++  | otherwise
++  = opts
++  where
++    pthread = "-lpthread"
++    libc = "-lc"
++    pthread_and_deps = [ "-lrt", pthread ] -- should depend on the environment
++    have_bad_glibc_version = True
++
+ collectLinkOpts :: DynFlags -> [UnitInfo] -> ([String], [String], [String])
+ collectLinkOpts dflags ps =
+     (
+         concatMap (map ("-l" ++) . unitHsLibs (ghcNameVersion dflags) (ways dflags)) ps,
+-        concatMap (map ("-l" ++) . map ST.unpack . unitExtDepLibsSys) ps,
++        fixOrderLinkOpts $ concatMap (map ("-l" ++) . map ST.unpack . unitExtDepLibsSys) ps,
+         concatMap (map ST.unpack . unitLinkerOptions) ps
+     )
+