Skip to content

Commit ba47781

Browse files
committed
More patch fixes
1 parent ed4ae56 commit ba47781

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

overlays/bootstrap.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ in {
185185
++ onAarch64 (until "9.0" ./patches/ghc/ghc-8.10-aarch64-handle-none-rela.patch)
186186
++ onWindows (until "9.0" ./patches/ghc/5b08e0c06e038448a63aa9bd7f163b23d824ba4b.patch)
187187
++ onAarch64 (fromUntil "9.0" "9.11" ./patches/ghc/ghc-9.0-better-symbol-addr-debug.patch)
188-
++ onAarch64 (fromUntil "9.0" "9.11" ./patches/ghc/ghc-9.0-aarch64-handle-none-rela.patch)
188+
++ onAarch64 (fromUntil "9.0" "9.8.3" ./patches/ghc/ghc-9.0-aarch64-handle-none-rela.patch)
189+
++ onAarch64 (fromUntil "9.10" "9.11" ./patches/ghc/ghc-9.0-aarch64-handle-none-rela.patch)
189190

190191
++ onWindows (fromUntil "9.6.3" "9.6.4" ./patches/ghc/ghc-9.6-hadrian-splitsections.patch)
191192
++ onWindows (fromUntil "9.8.1" "9.8.2" ./patches/ghc/ghc-9.6-hadrian-splitsections.patch)
@@ -216,7 +217,8 @@ in {
216217

217218
# Allow loading static external plugins into cross compilers
218219
++ onCross (fromUntil "9.6.1" "9.11" ./patches/ghc/5c80a27488acfe3610ddfcb99a1e961002e386d0.patch)
219-
++ onCross (fromUntil "9.6.1" "9.11" ./patches/ghc/f8beb54a1d5725bd0d8a4b0a909d1b41d742b50b.patch)
220+
++ onCross (fromUntil "9.6.1" "9.8.3" ./patches/ghc/f8beb54a1d5725bd0d8a4b0a909d1b41d742b50b.patch)
221+
++ onCross (fromUntil "9.8.3" "9.11" ./patches/ghc/ghc-9.8.3-f8beb54a1d5725bd0d8a4b0a909d1b41d742b50b.patch)
220222
++ final.lib.optionals (
221223
final.stdenv.targetPlatform.isAndroid
222224
&& final.stdenv.targetPlatform.is32bit
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From f8beb54a1d5725bd0d8a4b0a909d1b41d742b50b Mon Sep 17 00:00:00 2001
2+
From: Luite Stegeman <[email protected]>
3+
Date: Fri, 8 Dec 2023 12:12:20 +0100
4+
Subject: [PATCH] External plugins: try loading archive if loading dynamic
5+
library fails
6+
7+
---
8+
compiler/GHC/Driver/Plugins.hs | 27 ++++++++++-----------------
9+
1 file changed, 10 insertions(+), 17 deletions(-)
10+
11+
diff --git a/compiler/GHC/Driver/Plugins.hs b/compiler/GHC/Driver/Plugins.hs
12+
index 2f3bf44b408..8b06e8b16d5 100644
13+
--- a/compiler/GHC/Driver/Plugins.hs
14+
+++ b/compiler/GHC/Driver/Plugins.hs
15+
@@ -1,12 +1,9 @@
16+
{-# LANGUAGE RankNTypes #-}
17+
{-# LANGUAGE CPP #-}
18+
19+
-#if defined(CAN_LOAD_DLL)
20+
{-# LANGUAGE MagicHash #-}
21+
{-# LANGUAGE LambdaCase #-}
22+
{-# LANGUAGE UnboxedTuples #-}
23+
-#endif
24+
-
25+
26+
-- | Definitions for writing /plugins/ for GHC. Plugins can hook into
27+
-- several areas of the compiler. See the 'Plugin' type. These plugins
28+
@@ -103,11 +100,9 @@ import qualified Data.Semigroup
29+
30+
import Control.Monad
31+
32+
-#if defined(CAN_LOAD_DLL)
33+
import GHCi.ObjLink
34+
import GHC.Exts (addrToAny#, Ptr(..))
35+
import GHC.Utils.Encoding
36+
-#endif
37+
38+
39+
-- | Command line options gathered from the -PModule.Name:stuff syntax
40+
@@ -372,10 +367,6 @@ defaultFrontendPlugin = FrontendPlugin { frontend = \_ _ -> return () }
41+
-- | Load external plugins
42+
loadExternalPlugins :: [ExternalPluginSpec] -> IO [ExternalPlugin]
43+
loadExternalPlugins [] = return []
44+
-#if !defined(CAN_LOAD_DLL)
45+
-loadExternalPlugins _ = do
46+
- panic "loadExternalPlugins: loading shared libraries isn't supported by this compiler"
47+
-#else
48+
loadExternalPlugins ps = do
49+
-- initialize the linker
50+
initObjLinker RetainCAFs
51+
@@ -400,17 +391,19 @@ loadExternalPlugins ps = do
52+
53+
loadExternalPluginLib :: FilePath -> IO ()
54+
loadExternalPluginLib path = do
55+
- -- load library
56+
+ -- XXX we should probably use the filename to determine whether
57+
+ -- the plugin is an archive or dynamic lib
58+
+
59+
+ -- try loading it as a dynamic library
60+
loadDLL path >>= \case
61+
- Left errmsg -> pprPanic "loadExternalPluginLib"
62+
- (vcat [ text "Can't load plugin library"
63+
- , text " Library path: " <> text path
64+
- , text " Error : " <> text errmsg
65+
- ])
66+
- Right _ -> do
67+
+ Left _errmsg ->
68+
+ -- if that fails, try loading it as an archive
69+
+ loadArchive path >> resolve
70+
+ Right _ -> resolve
71+
+ where
72+
+ resolve = do
73+
-- resolve objects
74+
resolveObjs >>= \case
75+
True -> return ()
76+
False -> pprPanic "loadExternalPluginLib" (text "Unable to resolve objects for library: " <> text path)
77+
78+
-#endif
79+
--
80+
GitLab
81+

0 commit comments

Comments
 (0)