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

ocamlPackages tree-wide: Move buildInputs that should be nativeBuildInputs #161344

Merged

Conversation

ulrikstrid
Copy link
Member

@ulrikstrid ulrikstrid commented Feb 22, 2022

Motivation for this change

To make cross compilation better we need to move a bunch of stuff to nativeBuildInputs.
Another good reason is that we should get much smaller closures when building ocaml projects.
This PR supersedes #145448 I think.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ulrikstrid ulrikstrid force-pushed the ulrikstrid/tree-wide-native-inputs branch from f2fc6db to 70dbc54 Compare February 22, 2022 10:06
@ulrikstrid ulrikstrid force-pushed the ulrikstrid/tree-wide-native-inputs branch from 70dbc54 to 2e9d67a Compare February 22, 2022 10:09
@ulrikstrid ulrikstrid force-pushed the ulrikstrid/tree-wide-native-inputs branch from 2e9d67a to a43a8a0 Compare February 22, 2022 10:27
@ulrikstrid ulrikstrid force-pushed the ulrikstrid/tree-wide-native-inputs branch 14 times, most recently from 29fd001 to 14d80f6 Compare February 22, 2022 15:57
Copy link
Member

@symphorien symphorien left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. How did you test it?

It would be nice to add strictDeps = true on every derivation which you fix. This allows to test if the partition between buildInputs and nativeBuildInputs is correct without cross compiling. This is the one true way to know if ppx libs belong to buildInputs or to nativeBuildInputs. In case strictDeps do not work at all in problematic cases (everything involving gtk3 is problematic for example), you can leave it to false, of course. But such a PR would bitrot very fast if we cannot set strictDeps to true on a large proportion of them.

@@ -18,7 +18,8 @@ stdenv.mkDerivation rec {
sha256 = "1c807wrpxra9sbb34lajhimwra28ldxv04m570567lh2b04n38zy";
};

buildInputs = [ ocaml findlib ocamlbuild which camlp4 ];
nativeBuildInputs = [ ocaml findlib ocamlbuild which ];
buildInputs = [ camlp4 ];
Copy link
Member

Choose a reason for hiding this comment

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

I suspect this belongs to nativeBuildInput, as it's a preprocessor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Me and @anmonteiro discussed this and we believe camlp4 will be built and ran while building like ppxes. I would love to be proved wrong and be able to move more things to nativeBuildInputs

Copy link
Member

Choose a reason for hiding this comment

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

Now that strictDeps is set, it only builds with camlp4 in nativeBuildInputs. That answers the question :)

Copy link
Member

Choose a reason for hiding this comment

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

you didn't fix this

@ulrikstrid
Copy link
Member Author

I've been running nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD" and building LIGO statically in a separate project using this patch. It's not fully getting everything but I found a bunch of stuff that I fixed and amended.
I also did a patch to set strictDeps in buildDunePackage just to test it out, but I could add it to all the packages that I've touched in this PR.

@symphorien
Copy link
Member

adding strictDeps = true to buildDunePackage is a good idea if there are not too many exceptions.
Yes it would be better to set it to all packages touched by this PR, otherwise there is no way to check that what you changed is correct, and it would bitrot rapidly.

@ulrikstrid ulrikstrid force-pushed the ulrikstrid/tree-wide-native-inputs branch from 44ed833 to f3db7c9 Compare February 22, 2022 19:59
@ulrikstrid
Copy link
Member Author

@symphorien I have now added strictDeps = true; to all the packages I dared setting it for (skipped the SDL and gnome packages)

Copy link
Member

@symphorien symphorien left a comment

Choose a reason for hiding this comment

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

nix-review is happy
I'll merge over the weekend unless someone complains.

@ulrikstrid
Copy link
Member Author

@symphorien can I ask you to open a issue about the checkInputs failure we're seeing? And also add your guess about how to solve it?

If you do I could spend some time trying to solve it never week. 🙏

@symphorien
Copy link
Member

Issue is #161570 and PR is #161575

@symphorien symphorien merged commit b9ecdae into NixOS:master Feb 27, 2022
@ulrikstrid ulrikstrid deleted the ulrikstrid/tree-wide-native-inputs branch February 27, 2022 19:55
anmonteiro added a commit to nix-ocaml/nix-overlays that referenced this pull request Feb 28, 2022
* wip

* check if still builds

* remove file

* update melange
@vbgl
Copy link
Contributor

vbgl commented Mar 1, 2022

This broke ocaml-ng.ocamlPackages_4_07.lwt.

@symphorien
Copy link
Member

fixed in #162370

@vbgl
Copy link
Contributor

vbgl commented Mar 1, 2022

Thanks for the quick fix.
Bisecting the failure of ocaml-ng.ocamlPackages_4_07.ppx_let led me here again.

@vbgl
Copy link
Contributor

vbgl commented Mar 1, 2022

This also broke ocaml-ng.ocamlPackages_4_07.ppx_deriving.

@symphorien
Copy link
Member

I don't know what makes ppx_let fail, can you have a look @ulrikstrid ?

@ulrikstrid
Copy link
Member Author

Trying to reproduce the error on with ocaml-ng.ocamlPackages_4_07.ppx_let but all I'm seeing is that ppxlib needs dune 2 for version 0.8.1. Is this what you are seeing as well @vbgl @symphorien ?

Also, I asked in the followup PR if any of you know a good command to build all/most packages across ocaml versions so that I can catch these earlier.

@vbgl
Copy link
Contributor

vbgl commented Mar 3, 2022

This broke apron: it builds fine but is not installed properly:

nix-shell -p ocaml-ng.ocamlPackages_4_12.findlib ocaml-ng.ocamlPackages_4_12.apron --run 'ocamlfind query -r apron'

ocamlfind: Package `apron' not found

@ulrikstrid
Copy link
Member Author

I can't reproduce this on master

nix-shell -p ocaml-ng.ocamlPackages_4_12.findlib ocaml-ng.ocamlPackages_4_12.apron --run 'ocamlfind query -r apron'
/nix/store/mps7hcb0qp7cf4l5k582asxwxhdl08kx-ocaml-4.12.0/lib/ocaml
/nix/store/mps7hcb0qp7cf4l5k582asxwxhdl08kx-ocaml-4.12.0/lib/ocaml
/nix/store/hiisfrrljwbj99h4q0spqizzj2xgr7c5-ocaml4.12.0-mlgmpidl-1.2.12/lib/ocaml/4.12.0/site-lib/gmp
/nix/store/lf0cyn31apa7yi2f25w6dih528cjbn3d-ocaml4.12.0-apron-0.9.13-dev/lib/ocaml/4.12.0/site-lib/apron
/nix/store/lf0cyn31apa7yi2f25w6dih528cjbn3d-ocaml4.12.0-apron-0.9.13-dev/lib/ocaml/4.12.0/site-lib/apron

@vbgl
Copy link
Contributor

vbgl commented Mar 3, 2022

You may need to set the NIX_PATH environment variable.

@ulrikstrid
Copy link
Member Author

This would be the same thing right?

➜  nixpkgs git:(master)  nix-shell -I ./default.nix -p ocaml-ng.ocamlPackages_4_12.findlib ocaml-ng.ocamlPackages_4_12.apron
[nix-shell:~/dev/nixpkgs]$ ocamlfind query -r apron
/nix/store/mps7hcb0qp7cf4l5k582asxwxhdl08kx-ocaml-4.12.0/lib/ocaml
/nix/store/mps7hcb0qp7cf4l5k582asxwxhdl08kx-ocaml-4.12.0/lib/ocaml
/nix/store/hiisfrrljwbj99h4q0spqizzj2xgr7c5-ocaml4.12.0-mlgmpidl-1.2.12/lib/ocaml/4.12.0/site-lib/gmp
/nix/store/lf0cyn31apa7yi2f25w6dih528cjbn3d-ocaml4.12.0-apron-0.9.13-dev/lib/ocaml/4.12.0/site-lib/apron
/nix/store/lf0cyn31apa7yi2f25w6dih528cjbn3d-ocaml4.12.0-apron-0.9.13-dev/lib/ocaml/4.12.0/site-lib/apron

@vbgl
Copy link
Contributor

vbgl commented Mar 3, 2022

Did you try: nix-shell -I nixpkgs=./default.nix …?

@vbgl
Copy link
Contributor

vbgl commented Mar 3, 2022

Or -I ..?

@ulrikstrid
Copy link
Member Author

nix-shell -I nixpkgs=./default.nix -p ocaml-ng.ocamlPackages_4_12.findlib ocaml-ng.ocamlPackages_4_12.apron show the error, let me investigate

@ulrikstrid
Copy link
Member Author

Thanks for the quick fix. Bisecting the failure of ocaml-ng.ocamlPackages_4_07.ppx_let led me here again.

It almost looks like dune2 was somehow available for ppxlib even in a case where it shouldn't have been. I have a PR coming up fixing this, I just need to test it with a couple of other OCaml versions before submitting.

@vbgl
Copy link
Contributor

vbgl commented Mar 3, 2022

ocamlPackages.elina seems broken too.

@ulrikstrid
Copy link
Member Author

@vbgl elina and a bunch of other packages are fixed in #162745, would love a review when you have time

@@ -5,6 +5,7 @@ let param =
version = "6.4";
sha256 = "15v7yfv6gyp8lzlgwi9garz10wpg34dk4072jdv19n6v20zfg7n1";
useDune2 = true;
nativeBuildInputs = [cppo];
buildInputs = [cppo];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a left over ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't remember but might be that there's a library component of cppo that was also needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I will do another round. I see other packages with the same issue.

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.

4 participants