diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2020-07-13 08:01:37 +0200 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2020-11-19 15:36:22 -0500 |
commit | 3571cc4137bebf067d7c88ec0206104cb5149676 (patch) | |
tree | e86fb004a07c5717dd60144da2363c9ae9a4e22c | |
parent | 65be3832f3aa48bbde896ee846c18fcba1f16b42 (diff) | |
download | haskell-3571cc4137bebf067d7c88ec0206104cb5149676.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.
-rw-r--r-- | compiler/ghci/Linker.hs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index ffc079b5cd..91aa8d4e06 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -1689,17 +1689,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 |