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

Erlang: fix cross compilation #100835

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

@DianaOlympos
Copy link
Contributor

@DianaOlympos DianaOlympos commented Oct 17, 2020

Motivation for this change

Erlang does not cross compile right now through Nix. This is trying to address this, in particular with the recent rise of AWS Graviton2 instances. #58042 was doing a lot already, but staled. This is going from there and continuing. I kept the old commit and the new one for now, there is probably still some work to be done

Things done

I tried to shrink the dependency on buildPackages but it seems that it get spliced the Host perl instead of the Build perl into the built of the host package. Same for libxslt. I don't know why, if someone have an idea i would love to hear about it.

The dependency on buildPackages.erlang_nox is also problematic. It is due to the fact that erlang need to bootstrap in cross compilation. But it needs to use the same version, which i found no good way to do here. So i use the default erlang_nox and pray that it works. That is potentially problematic. The other solution would be to bootstrap manually by building a limited bootstrapping OTP. The erlang build system offer that option, but i did not find a way to do that nicely without having to rebuild that bootstrapping lib each time. The other solution would be to build an intermediate derivation exclusively in the case of cross compilation. If this is something NixPkgs would be ok with, i could do that.

I am also not a fan of injecting "erl_xcomp_sysroot=${stdenv.cc.libc}" but it is needed by erlang build system or it decides it cannot find SSL for the host target. If there is a better option i would like that.

  • 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.
@ofborg ofborg bot requested review from gleber, couchemar and mdaiter Oct 17, 2020
@DianaOlympos DianaOlympos changed the title Erlang cross compilation partial Erlang: fix cross compilation Oct 19, 2020
@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented Oct 19, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/state-of-the-beam-ecosystem-in-nix/4202/19

@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented Oct 21, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cross-compiling-compile-bootstrap-on-target-instead-of-build/9576/1

@@ -43,16 +44,28 @@ let
inherit (stdenv.lib) optional optionals optionalAttrs optionalString;
wxPackages2 = if stdenv.isDarwin then [ wxmac ] else wxPackages;

isCross = stdenv.hostPlatform != stdenv.buildPlatform;
hipeSupport = (enableHipe && !isCross);
Copy link
Member

@SuperSandro2000 SuperSandro2000 Jan 18, 2021

Suggested change
hipeSupport = (enableHipe && !isCross);

@@ -85,12 +98,13 @@ in stdenv.mkDerivation ({
++ optional enableThreads "--enable-threads"
++ optional enableSmpSupport "--enable-smp-support"
++ optional enableKernelPoll "--enable-kernel-poll"
++ optional enableHipe "--enable-hipe"
++ optional hipeSupport "--enable-hipe"
Copy link
Member

@SuperSandro2000 SuperSandro2000 Jan 18, 2021

Suggested change
++ optional hipeSupport "--enable-hipe"
++ optional (enableHipe && !isCross) "--enable-hipe"

But honestly I would prefer an asset and throw here because people will be confused why hipe is disabled when cross compiling.

@stale
Copy link

@stale stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@DianaOlympos
Copy link
Contributor Author

@DianaOlympos DianaOlympos commented Jul 21, 2021

for anyone wondering, yes i am still interested in this, just more urgent problems cropped up in the meantime. Will get back to it hopefully soon TM

@stale stale bot removed the 2.status: stale label Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants