-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
ghcWithPackages: fix dylib path issues of the boot libraries for GHC 9.6. #224542
Conversation
@wavewave Thanks for putting this together. Do you have an example of some command that will fail without this PR? I'm interested in how I can test that this PR is working. |
Yes. On my laptop (Apple M1 macos 13.2.1), with the current master, when entering into a shell with ghcWithPackages env and run ghci:
So you see errors on missing dynamic libraries. With this branch,
no such errors. |
Can you test the following patch for me and report if it solves the problem: diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 34eb2b71d75..eef7a060bae 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -136,7 +136,8 @@ symlinkJoin {
# Clean up the old links that may have been (transitively) included by
# symlinkJoin:
rm -f $dynamicLinksDir/*
- for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u); do
+ # Starting with GHC 9.6 (due to hadrian?) dynamic-library-dirs for boot libraries uses the ''${pkgroot} variable.
+ for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u|sed -e 's|''${pkgroot}|'"${libDir}|"); do
ln -s $d/*.dylib $dynamicLinksDir
done
for f in $packageConfDir/*.conf; do Don't have access to a mac at the moment, hopefully I haven't messed up the |
74cdd5b
to
34957cc
Compare
@sternenseemann : applied your patch and ran the same nix-shell command as above and I got this error:
|
What is the output of the following patch applied? diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 34eb2b71d75..eef7a060bae 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -136,7 +136,8 @@ symlinkJoin {
# Clean up the old links that may have been (transitively) included by
# symlinkJoin:
rm -f $dynamicLinksDir/*
- for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u); do
+ # Starting with GHC 9.6 (due to hadrian?) dynamic-library-dirs for boot libraries uses the ''${pkgroot} variable.
+ for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u| tee /dev/stderr | sed -e 's|''${pkgroot}|'"${libDir}|"); do
ln -s $d/*.dylib $dynamicLinksDir
done
for f in $packageConfDir/*.conf; do |
I got this:
|
I suspect the empty line is the problem, so let's add an diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 34eb2b71d75..eef7a060bae 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -136,7 +136,8 @@ symlinkJoin {
# Clean up the old links that may have been (transitively) included by
# symlinkJoin:
rm -f $dynamicLinksDir/*
- for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u); do
+ # Starting with GHC 9.6 (due to hadrian?) dynamic-library-dirs for boot libraries uses the ''${pkgroot} variable.
+ for d in $(grep -Poz "dynamic-library-dirs:\s*\K .+\n" $packageConfDir/*|awk '{print $2}'|sort -u| grep -v '^$' | sed -e 's|''${pkgroot}|'"${libDir}|"); do
ln -s $d/*.dylib $dynamicLinksDir
done
for f in $packageConfDir/*.conf; do |
I found another bug was lurking in When that
The last commit fixes this problem. |
@wavewave Are you still waiting for a review from @sternenseemann for this? Also, could you refactor the commit messages to adhere to https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#submitting-changes |
Also started getting the missing dynamic libraries warnings on mac after bumping to 9.6. Cabal build also spits out some ld warnings. |
From GHC 9.6 on, the boot libraries (dependencies of the ghc library) are present in a separate directory after the installation, and thus the wrapper environment provided by ghcWithPackages needs to handle the links to the boot dynamic libraries separately than other ordinary ones.
When making ghcWithPackages, haskell package db configuration is modified by sed, but newlines are not handled properly, so resulting in ``` dynamic-library-dirs: ${pkgroot}/../lib/aarch64-osx-ghc-9.6.1 data-dir: ${pkgroot}/../share/aarch64-osx-ghc-9.6.1/filepath-1.4.100.1 ``` is replaced like (data-dir: is swallowed) ``` dynamic-library-dirs: /nix/store/zxmwvns8zg4ff47vw9hqgazjkiqa26kv-ghc-9.6.1-with-packages/lib/links ${pkgroot}/../share/aarch64-osx-ghc-9.6.1/filepath-1.4.100.1 ``` This fixes the bug.
66593d9
to
77504c6
Compare
Can confirm this fixes the issue on aarch64-darwin as well for me. |
The proper way to solve this would have been #224542 (comment), the problem is that this was never tested by anyone, so the PR was on hold from my side. |
Apologies. I was too hasty in merging without thoroughly reviewing all the previous discussion. |
Dynamic libraries for GHC boot libraries (such as ghc-prim) are found missing in ghcWithPackages env since those libraries were not symlinked due to the change in the directory scheme.
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)