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

Make cross-compilation work again. #4881

Closed
wants to merge 1 commit into from
Closed

Conversation

jbgi
Copy link
Contributor

@jbgi jbgi commented Oct 4, 2022

To correctly eval the haskell.nix project we need the pkgs for the current
system, not the cross system one.

cf. input-output-hk/haskell.nix#1666

Issue was introduced with haskell.nix bump in in #4871 (comment)

Related issue is that haskell.nix should not silently ignore dependencies errors:
input-output-hk/haskell.nix#1392

 To correctly eval the haskell.nix project we need the pkgs for the current
 system, not the cross system one.

 cf. input-output-hk/haskell.nix#1666
@jbgi jbgi requested review from zeme-iohk and michaelpj October 4, 2022 10:28
Copy link
Contributor

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

I have some questions D:

@@ -20,6 +20,7 @@ let
r-packages = with rPackages; [ R tidyverse dplyr stringr MASS plotly shiny shinyjs purrr ];
project = haskell-nix.cabalProject' ({ pkgs, ... }: {
inherit compiler-nix-name;
evalPackages = pkgs.buildPackages.buildPackages;
Copy link
Contributor

Choose a reason for hiding this comment

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

comment, please! Also I don't think we want this: this makes it not possible to evaluate things on a different system from the build one, which we used to be able to do. So should we not actually use evalPackages here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, isn't that the default? or is the issue that the default is broken?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

evalPackages default is pkgs.buildPackages. But apparently this not enough, probably because:

nix eval -f ./default.nix --arg crossSystem '{ config = "x86_64-w64-mingw32"; libc = "msvcrt"; }' plutus.haskell.project.pkgs.buildPackages.targetPlatform.system
"x86_64-windows"

while with pkgs.buildPackages.buildPackages

nix eval -f ./default.nix --arg crossSystem '{ config = "x86_64-w64-mingw32"; libc = "msvcrt"; }' plutus.haskell.project.pkgs.buildPackages.buildPackages.targetPlatform.system
"x86_64-linux"

But not sure why exactly. Maybe @hamishmack ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh that is a good point. Just using .buildPackages has caused problems in the past with caching. IIRC anything that used python (including some surprising things like git) would include a dependency on gdb (I think it was gdb), but buildPackages.gdb would be the cross compiler gdb (not the native one). The result was that git would recompile.

Copy link
Contributor

Choose a reason for hiding this comment

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

@michaelpj
Copy link
Contributor

Thanks for the fix!

@@ -22,6 +22,8 @@ let

compiler-nix-name = library.ghc-compiler-nix-name;

evalPackages = library.pkgs;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this not also use library.pkgs.buildPackages.buildPackages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, in this case library.pkgs is the original pkgs (not from any cross* invocation), so the one we want.

Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't make sense to me, aren't these two files literally the same thing just with one of them setup for the new infra? how are we doing cross builds in the std world then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with plutus-project.projectCross.mingwW64.

Copy link
Contributor

Choose a reason for hiding this comment

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

More attributes over functions :( What was wrong with the old way? I won't fight about it though.

Copy link
Contributor Author

@jbgi jbgi Oct 6, 2022

Choose a reason for hiding this comment

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

though, using pkgs.pkgsBuildBuild should also work and must be the same. so we can use it instead of library.pkgs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm very pro consistency if it doesn't cost us anything!!

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. I'll close this PR then.

@michaelpj
Copy link
Contributor

Also, I remembered that there's a simpler and clearer way to get this: pkgs.pkgsBuildBuild https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/stage.nix#L116

@jbgi
Copy link
Contributor Author

jbgi commented Oct 6, 2022

upstreamed in input-output-hk/haskell.nix#1739

@jbgi jbgi closed this Oct 6, 2022
@kwxm kwxm deleted the cross-compilation-fix branch November 14, 2022 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants