Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
reflex-frp
GitHub Repository: reflex-frp/reflex-platform
Path: blob/develop/haskell-overlays/patches/ghc865/fix-big-sur.patch
1 views
1
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
2
index dbe71cd9ab048bd5cc9b2774dd30faeecbdd84fb..da18c019461bdffd62e06bd0441742786109c08c 100644
3
--- a/compiler/ghci/Linker.hs
4
+++ b/compiler/ghci/Linker.hs
5
@@ -1676,6 +1676,38 @@ addEnvPaths name list
6
-- ----------------------------------------------------------------------------
7
-- Loading a dynamic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
8
9
+{-
10
+Note [macOS Big Sur dynamic libraries]
11
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12
+
13
+macOS Big Sur makes the following change to how frameworks are shipped
14
+with the OS:
15
+
16
+> New in macOS Big Sur 11 beta, the system ships with a built-in
17
+> dynamic linker cache of all system-provided libraries. As part of
18
+> this change, copies of dynamic libraries are no longer present on
19
+> the filesystem. Code that attempts to check for dynamic library
20
+> presence by looking for a file at a path or enumerating a directory
21
+> will fail. Instead, check for library presence by attempting to
22
+> dlopen() the path, which will correctly check for the library in the
23
+> cache. (62986286)
24
+
25
+(https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes/)
26
+
27
+Therefore, the previous method of checking whether a library exists
28
+before attempting to load it makes GHC.Runtime.Linker.loadFramework
29
+fail to find frameworks installed at /System/Library/Frameworks.
30
+Instead, any attempt to load a framework at runtime, such as by
31
+passing -framework OpenGL to runghc or running code loading such a
32
+framework with GHCi, fails with a 'not found' message.
33
+
34
+GHC.Runtime.Linker.loadFramework now opportunistically loads the
35
+framework libraries without checking for their existence first,
36
+failing only if all attempts to load a given framework from any of the
37
+various possible locations fail. See also #18446, which this change
38
+addresses.
39
+-}
40
+
41
-- Darwin / MacOS X only: load a framework
42
-- a framework is a dynamic library packaged inside a directory of the same
43
-- name. They are searched for in different paths than normal libraries.
44
@@ -1686,17 +1718,29 @@ loadFramework hsc_env extraPaths rootname
45
Left _ -> []
46
Right dir -> [dir </> "Library/Frameworks"]
47
ps = extraPaths ++ homeFrameworkPath ++ defaultFrameworkPaths
48
- ; mb_fwk <- findFile ps fwk_file
49
- ; case mb_fwk of
50
- Just fwk_path -> loadDLL hsc_env fwk_path
51
- Nothing -> return (Just "not found") }
52
- -- Tried all our known library paths, but dlopen()
53
- -- has no built-in paths for frameworks: give up
54
+ ; errs <- findLoadDLL ps []
55
+ ; return $ fmap (intercalate ", ") errs
56
+ }
57
where
58
fwk_file = rootname <.> "framework" </> rootname
59
- -- sorry for the hardcoded paths, I hope they won't change anytime soon:
60
+
61
+ -- sorry for the hardcoded paths, I hope they won't change anytime soon:
62
defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"]
63
64
+ -- Try to call loadDLL for each candidate path.
65
+ --
66
+ -- See Note [macOS Big Sur dynamic libraries]
67
+ findLoadDLL [] errs =
68
+ -- Tried all our known library paths, but dlopen()
69
+ -- has no built-in paths for frameworks: give up
70
+ return $ Just errs
71
+ findLoadDLL (p:ps) errs =
72
+ do { dll <- loadDLL hsc_env (p </> fwk_file)
73
+ ; case dll of
74
+ Nothing -> return Nothing
75
+ Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs)
76
+ }
77
+
78
{- **********************************************************************
79
80
Helper functions
81
82