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

Fix ar command path in GHC #110695

Closed
wants to merge 5 commits into from
Closed

Fix ar command path in GHC #110695

wants to merge 5 commits into from

Conversation

TerrorJack
Copy link
Contributor

@TerrorJack TerrorJack commented Jan 24, 2021

Previously, the "ar command" in the global config of GHC in nixpkgs is
simply "ar" instead of a proper absolute path in the nix store. This
will result in an "ar: command not found" error when using GHC and cabal
in a pure nix shell. This commit adds the patch and applies to all
pre-9.0 versions.

See output of ghc --info for "ar command" value.

The original patch comes from haskell.nix, see here. Hopefully this will be fixed in upstream 9.x releases.

Motivation for this change
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 update was generated by hackage2nix v2.16.0-9-ga573266 from Hackage revision
commercialhaskell/all-cabal-hashes@de484d6.
This update was generated by hackage2nix v2.16.0-9-ga573266 from Hackage revision
commercialhaskell/all-cabal-hashes@f9bd351.
This update was generated by hackage2nix v2.16.0-9-ga573266 from Hackage revision
commercialhaskell/all-cabal-hashes@c1d88e6.
@cdepillabout
Copy link
Member

cdepillabout commented Jan 25, 2021

A couple questions:

  • How can I test that this works?
  • What does "not working" look like?
  • Why does this need to be patched?

(Although I guess are all basically the same underlying question.)

Can you rebase this on the haskell-updates branch as well?

@xaverdh
Copy link
Contributor

xaverdh commented Jan 25, 2021

Nice, this should resolve #55995 if I am not mistaken?

Previously, the "ar command" in the global config of GHC in nixpkgs is
simply "ar" instead of a proper absolute path in the nix store. This
will result in an "ar: command not found" error when using GHC and cabal
in a pure nix shell. This commit adds the patch and applies to all
pre-9.0 versions.

See output of ghc --info for "ar command" value.
@TerrorJack
Copy link
Contributor Author

@cdepillabout

How can I test that this works? What does "not working" look like? Why does this need to be patched?

See #55995. tl;dr: nix run -f /path/to/nixpkgs haskell.compiler.ghc8103 cabal-install, then cabal get unordered-containers-0.2.13.0 && cd unordered-containers-0.2.13.0 && cabal v2-build. Before applying the fix, there'll be an error message like: cabal: The program 'ar' is required but it could not be found..

Can you rebase this on the haskell-updates branch as well?

Done. Should I change the PR to target haskell-updates instead of master as well?

@xaverdh

Nice, this should resolve #55995 if I am not mistaken?

Yes.

@cdepillabout cdepillabout changed the base branch from master to haskell-updates January 26, 2021 00:32
@cdepillabout
Copy link
Member

cdepillabout commented Jan 26, 2021

I was able to reproduce this using the steps explained by @TerrorJack in #110695 (comment). One thing that I had to be careful with is that I have ar available in /run/current-system/sw/bin/ar, so I had to make sure to run nix run --ignore-environment -f ../. cabal-install ghc -c cabal build (specifying the --ignore-environment flag).

On #85136 (comment), @peti specifically talks about the case where you can get cabal-install from nixpkgs, but get binutils and ghc from your distro. However, I don't really understand whether the fix in this PR is fixing a bug of GHC (in that the path to ar is not properly recorded) or a "feature" of GHC (in that you can use a different version of binutils between compiling GHC and actually using it). If it is fixing a bug, then I imagine it should probably be fixed upstream? Is there a bug report upstream somewhere? If not, could you create one @TerrorJack?

@TerrorJack
Copy link
Contributor Author

@cdepillabout https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885

@cdepillabout
Copy link
Member

@TerrorJack Can you edit this PR to add a comment to link to the upstream PR, and add an explanation of why we can't just pull this from upstream?

I'd like to make sure we can track when this patch is no longer needed (so we know when it can be removed from nixpkgs).

@cdepillabout
Copy link
Member

cdepillabout commented Jan 26, 2021

@GrahamcOfBorg build haskell.compiler.ghc865
@GrahamcOfBorg build haskell.compiler.ghc882
@GrahamcOfBorg build haskell.compiler.ghc883
@GrahamcOfBorg build haskell.compiler.ghc884
@GrahamcOfBorg build haskell.compiler.ghc8101
@GrahamcOfBorg build haskell.compiler.ghc8102
@GrahamcOfBorg build haskell.compiler.ghc8103

Copy link
Member

@cdepillabout cdepillabout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, especially since it seems like they are accepting it as a bug upstream.

I'll wait a week for anyone (like @peti) to comment, but if no one has said anything by then, please feel free to ping me again @TerrorJack and I'll merge this in.

Copy link
Member

@peti peti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks pretty good. Thanks a lot to both of you for your efforts! 👍

Let's wait for the build bot to confirm that everything compiles, and then we should merge so that these patches make into this weeks merge of haskell-updates into master.

@peti
Copy link
Member

peti commented Jan 29, 2021

Well, the test builds don't look so good. That patch is probably not going to make it into haskell-updates tonight. :-(

@peti
Copy link
Member

peti commented Jan 29, 2021

I've pushed 8fae904 to haskell-updates. Let's hope that the test builds succeed on Hydra at https://hydra.nixos.org/jobset/nixpkgs/haskell-updates.

@peti peti force-pushed the haskell-updates branch 3 times, most recently from 36d8f4b to 0b62665 Compare February 5, 2021 22:21
@cdepillabout
Copy link
Member

This was merged into haskell-updates in 643169b (and is now in master as well).

Thanks @TerrorJack!

@TerrorJack TerrorJack deleted the ghc-respect-ar-path branch February 6, 2021 08:05
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