summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-07-17 20:37:41 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-26 13:23:24 -0400
commita7c4439a407ad85b76aab9301fda61e7c10183ff (patch)
tree0ece9ee6109906ff6f5b542f519745cb281bf5c8
parentfc0f6fbcd95f2dc69a8efabbee2d8a485c34cc47 (diff)
downloadhaskell-a7c4439a407ad85b76aab9301fda61e7c10183ff.tar.gz
Document loadFramework changes. (#18446)
Adds commentary on the rationale for the changes made in merge request !3689.
-rw-r--r--compiler/GHC/Runtime/Linker.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/compiler/GHC/Runtime/Linker.hs b/compiler/GHC/Runtime/Linker.hs
index 35a638b12a..face7068d4 100644
--- a/compiler/GHC/Runtime/Linker.hs
+++ b/compiler/GHC/Runtime/Linker.hs
@@ -1695,6 +1695,38 @@ addEnvPaths name list
-- ----------------------------------------------------------------------------
-- Loading a dynamic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
+{-
+Note [macOS Big Sur dynamic libraries]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+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.
+Instead, any attempt to load a framework at runtime, such as by
+passing -framework OpenGL to runghc or running code loading such a
+framework with GHCi, fails with a 'not found' message.
+
+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. See also #18446, which this change
+addresses.
+-}
+
-- Darwin / MacOS X only: load a framework
-- a framework is a dynamic library packaged inside a directory of the same
-- name. They are searched for in different paths than normal libraries.
@@ -1714,6 +1746,9 @@ loadFramework hsc_env extraPaths rootname
-- sorry for the hardcoded paths, I hope they won't change anytime soon:
defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"]
+ -- Try to call loadDLL for each candidate path.
+ --
+ -- See Note [macOS Big Sur dynamic libraries]
findLoadDLL [] errs =
-- Tried all our known library paths, but dlopen()
-- has no built-in paths for frameworks: give up