all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 5d4afa28c1417714ea8d233644b2ff14711ed1d4 1491 bytes (raw)
name: gnu/packages/patches/ghc-9.2-glibc-2.33-link-order.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
     )
 

debug log:

solving 5d4afa28c1 ...
found 5d4afa28c1 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.