summaryrefslogtreecommitdiff
path: root/compiler/GHC/Runtime
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-07-13 08:01:37 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-14 21:34:35 -0400
commit58ae62ebb5750e4dfbdb171efde8e3064b7afea8 (patch)
tree37a0f108df478aef3b98d821d29f5bb7f1e8976b /compiler/GHC/Runtime
parentc9f65c369a60467dcaf2b37d5f41f00565b4fe25 (diff)
downloadhaskell-58ae62ebb5750e4dfbdb171efde8e3064b7afea8.tar.gz
macOS: Load frameworks without stating them first.
macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail.
Diffstat (limited to 'compiler/GHC/Runtime')
-rw-r--r--compiler/GHC/Runtime/Linker.hs21
1 files changed, 14 insertions, 7 deletions
diff --git a/compiler/GHC/Runtime/Linker.hs b/compiler/GHC/Runtime/Linker.hs
index f94d225889..ccbb1791e9 100644
--- a/compiler/GHC/Runtime/Linker.hs
+++ b/compiler/GHC/Runtime/Linker.hs
@@ -1705,17 +1705,24 @@ loadFramework hsc_env extraPaths rootname
Left _ -> []
Right dir -> [dir </> "Library/Frameworks"]
ps = extraPaths ++ homeFrameworkPath ++ defaultFrameworkPaths
- ; mb_fwk <- findFile ps fwk_file
- ; case mb_fwk of
- Just fwk_path -> loadDLL hsc_env fwk_path
- Nothing -> return (Just "not found") }
- -- Tried all our known library paths, but dlopen()
- -- has no built-in paths for frameworks: give up
+ ; findLoadDLL ps }
where
fwk_file = rootname <.> "framework" </> rootname
- -- sorry for the hardcoded paths, I hope they won't change anytime soon:
+
+ -- sorry for the hardcoded paths, I hope they won't change anytime soon:
defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"]
+ findLoadDLL [] =
+ -- Tried all our known library paths, but dlopen()
+ -- has no built-in paths for frameworks: give up
+ return (Just "not found")
+ findLoadDLL (p:ps) =
+ do { dll <- loadDLL hsc_env (p </> fwk_file)
+ ; case dll of
+ Nothing -> return Nothing
+ Just _ -> findLoadDLL ps
+ }
+
{- **********************************************************************
Helper functions