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

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

Conversation

DianaOlympos
Copy link
Contributor

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 October 17, 2020 15:25
@DianaOlympos DianaOlympos changed the title Erlang cross compilation partial Erlang: fix cross compilation Oct 19, 2020
@nixos-discourse
Copy link

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

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

@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Nov 19, 2020
@veprbl veprbl requested a review from Ericson2314 November 19, 2020 20:42
@@ -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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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.

@SuperSandro2000 SuperSandro2000 added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 18, 2021
@domenkozar domenkozar mentioned this pull request Jun 14, 2021
10 tasks
@stale
Copy link

stale bot commented Jul 21, 2021

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

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
@DianaOlympos
Copy link
Contributor Author

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 https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
@stale
Copy link

stale bot commented Apr 19, 2022

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

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 19, 2022
@DianaOlympos
Copy link
Contributor Author

still interested, still no time. And tbh, i am not sure there is an easy solution here, because the bootstrapping is getting my head spinning. I do think i would appreciate some help from someone with a bit of experience. I may have to look at how other interpreters and/or runtime do it. If they do.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 20, 2022
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 30, 2022
@IslandUsurper
Copy link
Contributor

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.

I think an intermediate derivation specifically for cross-compilation is the way to go, possibly using just the bootstrapping OTP since there are specific commands for it in its build system. I know @DianaOlympos is strapped for time, but I think I see how it can be done.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 21, 2023
@DianaOlympos
Copy link
Contributor Author

Please go work on it! I want it!

But note that i tried the intermediary derivation and i never got it to work. It always pick the wrong system-arch triplet.

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@wegank wegank marked this pull request as draft March 20, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: erlang 10.rebuild-darwin: 11-100 10.rebuild-linux: 11-100
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants