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 static building for ocaml-ng #73820
Conversation
…priate The default has been to use buildInputs for build dependencies. This doesn't work when cross-compiling.
This allows this package to build with eudev instead.
Naive question after a quick look at the changes: why is |
@vbgl Because it doesn't appear to be working otherwise :) My guess is that it needs to find both host and target libraries, thus requiring both host and target findlib. |
This commit adds a static adapter for ocaml packages and applies it to pkgsStatic.ocaml-ng. The adapter fixes build of ocaml itself with version <= 4.7 and also attempts to fix builds of some packages.
cd6a682
to
7263951
Compare
@@ -52,7 +52,7 @@ stdenv.mkDerivation rec { | |||
]; | |||
|
|||
nativeBuildInputs = [ ocaml findlib ocamlbuild cc-wrapper ]; | |||
buildInputs = [ ocamlbuild findlib topkg cpuid ocb-stubblr ]; | |||
buildInputs = [ ocamlbuild findlib topkg cpuid ocb-stubblr ppx_deriving ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ppx_deriving
should be propagated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke jackline
, see: https://hydra.nixos.org/build/107730405
Will fix there: #74437
@balsoft commit 7263951 mentions it fixes the static build of OCaml for versions <= 4.07. I got OCaml 4.08 and 4.09 going under musl with the following (I think they switched the build to autoconf since 4.08): (_: super:
{
ocaml = super.ocaml.overrideDerivation (o: {
preConfigure = ''
configureFlagsArray+=("CC=$CC" "AS=$AS" "PARTIALLD=$LD -r")
'';
configureFlags = (lib.remove "--no-shared-libs" o.configureFlags) ++ [
"--disable-shared"
"--host ${o.stdenv.hostPlatform.config}"
"--target ${o.stdenv.targetPlatform.config}"
];
});
}) Ideally this would make it upstream to nixpkgs -- I'm looking for pointers on how to add these flags conditionally based on the OCaml version. |
The
|
I'm happy to submit a PR adding support for OCaml >= 4.08, but I'm still having an issue where I can't use packages that build with
Any pointers on what to look for here would be appreciated. I tried messing with |
Motivation for this change
Currently attempting to build
pkgsStatic.ocaml
and friends fails miserably. This PR:ocaml
and some subset ofocamlPackages
ocamlPackages
I am not sure that the adapter should go in top-level/static.nix, if it belongs in development/compilers/ocaml/generic.nix, then it's pretty easy to move it there.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @vbgl @regnat