Skip to content
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

haskell: Fix with-packages-wrapper MacOS linker hack for GHC 8.8 #89156

Merged

Conversation

soareschen
Copy link
Contributor

@soareschen soareschen commented May 29, 2020

Motivation for this change

with-packages-wrapper.nix has a hack to workaround the linker limit in MacOS Sierra. However that is now broken with GHC 8.8, because of slight change in the format of the package config. In short, the package config produced by GHC 8.8 has a new line between the key and list of values, while earlier versions have them separated by a single space.

For example, in GHC 8.6 the entry is formatted as:

dynamic-library-dirs: /nix/store/8s2jg442gk2p2z2mhlrqh163m7ajqq2m-extra-1.6.21/lib/ghc-8.6.5/x86_64-linux-ghc-8.6.5
                      /nix/store/fn92v9h7gxj9w4z0s2qxsjxb4awczl3h-ncurses-6.2/lib
                      /nix/store/1cygbkyil4flvw8q1fpxn6m783xkxbdq-libffi-3.3/lib
                      /nix/store/3hkj53lkmaz332zv7kcap0rlr5g6vich-gmp-6.2.0/lib

While in GHC 8.8, the entry is formatted as:

dynamic-library-dirs:
    /nix/store/xlvjnm7qkdaib25lxpwdadihjicj72gs-extra-1.6.21/lib/ghc-8.8.3/x86_64-linux-ghc-8.8.3
    /nix/store/fn92v9h7gxj9w4z0s2qxsjxb4awczl3h-ncurses-6.2/lib
    /nix/store/1cygbkyil4flvw8q1fpxn6m783xkxbdq-libffi-3.3/lib
    /nix/store/3hkj53lkmaz332zv7kcap0rlr5g6vich-gmp-6.2.0/lib

This PR fixes the linker hack by modifying the grep and sed commands to pattern match on either space or new line, so that the hack can work on all versions of GHC.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This change is Reviewable

@cdepillabout
Copy link
Member

@soareschen Is this related to #87881 or #78738?

It seems like this is similar to #78738, but I don't understand why this PR is so much simpler than #78738.

If these are related, it is quite unfortunate we missed updating with-packages-wrapper in #78738.

Is there some sort of common functionality between those two nix files you could factor out into a separate file?

@soareschen
Copy link
Contributor Author

soareschen commented May 29, 2020

@cdepillabout yes I think this fixes the same issue as #78738 (didn't know about it) but in Nix shells.

It seems like this is similar to #78738, but I don't understand why this PR is so much simpler than #78738.

This is probably because I gone around Stack Overflow trying to do multi-line pattern matching in grep and awk, which are not that straightforward. Either way I think both approaches are pretty ugly hacks, and we should instead write proper scripts to parse the package conf file. The code should also be deduplicated from with-packages-wrapper.nix and generic-builder.nix so that we do not miss updating one but not the other the next time round.

@peti peti changed the base branch from master to haskell-updates May 29, 2020 19:38
@peti peti merged this pull request into NixOS:haskell-updates May 29, 2020
@peti
Copy link
Member

peti commented May 29, 2020

I merged the PR just now. I just trust that you know what you are doing. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants