-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add patches to fix GHC 8.6.5 on MacOS Big Sur and up #810
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs | ||
index dbe71cd9ab048bd5cc9b2774dd30faeecbdd84fb..da18c019461bdffd62e06bd0441742786109c08c 100644 | ||
--- a/compiler/ghci/Linker.hs | ||
+++ b/compiler/ghci/Linker.hs | ||
@@ -1676,6 +1676,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_0_1-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. | ||
@@ -1686,17 +1718,29 @@ 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 | ||
+ ; errs <- findLoadDLL ps [] | ||
+ ; return $ fmap (intercalate ", ") errs | ||
+ } | ||
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"] | ||
|
||
+ -- 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 | ||
+ return $ Just errs | ||
+ findLoadDLL (p:ps) errs = | ||
+ do { dll <- loadDLL hsc_env (p </> fwk_file) | ||
+ ; case dll of | ||
+ Nothing -> return Nothing | ||
+ Just err -> findLoadDLL ps ((p ++ ": " ++ err):errs) | ||
+ } | ||
+ | ||
{- ********************************************************************** | ||
|
||
Helper functions |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put all the patches in the same place? some are defined here in the overlays and others are up around like 41.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I would like to have all compiler patches that we keep (in-repo) to be in a format like this
$GIT_REPO/haskell-overlays/patches/<ghcver>/<platform>/*.patch
or alternatively replace
$GIT_REPO/haskell-overlays/patches
to just$GIT_REPO/patches
keeps away a ton of ugly directory tree layouts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean the patch files themselves, I meant the list of patches being applied to our compilers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reflex-platform/default.nix
Lines 41 to 45 in 5aa890f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New commit should make this align more with what we're currently doing