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: cross compile support #58042

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pkgs/development/interpreters/erlang/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, unixODBC ? null # odbcSupport
, libGLU_combined ? null, wxGTK ? null, wxmac ? null, xorg ? null # wxSupport
, withSystemd ? stdenv.isLinux, systemd # systemd support in epmd
, buildPackages
}:

{ baseName ? "erlang"
Expand Down Expand Up @@ -41,14 +42,24 @@ let
inherit (stdenv.lib) optional optionals optionalAttrs optionalString;
wxPackages2 = if stdenv.isDarwin then [ wxmac ] else wxPackages;

isCross = stdenv.hostPlatform != stdenv.buildPlatform;

in stdenv.mkDerivation ({
name = "${baseName}-${version}"
+ optionalString javacSupport "-javac"
+ optionalString odbcSupport "-odbc";

inherit src version;

nativeBuildInputs = [ autoreconfHook makeWrapper perl gnum4 libxslt libxml2 ];
nativeBuildInputs = [
buildPackages.autoreconfHook
buildPackages.makeWrapper
buildPackages.perl
buildPackages.gnum4
buildPackages.libxslt
buildPackages.libxml2
Copy link
Member

Choose a reason for hiding this comment

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

Does the buildPackages prefix here actually makes a difference?
I only know that sometimes overrides in all-packages.nix breaks splicing
of the correct architecture. The problem when using this approach is
that it is no longer possible to override packages externally.

Copy link
Member Author

Choose a reason for hiding this comment

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

yea you're right, not sure, let me try it without those

Copy link
Member Author

Choose a reason for hiding this comment

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

@Mic92 just tried it and it doesn't work if I don't explicitly set buildPackages, maybe i'm going about this wrong but it seems to not be able to find perl if I remove buildPackages.

Copy link
Member

Choose a reason for hiding this comment

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

What is the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, I was building it with wxSupport, which doesn't work right now, this patch is to cross-compile erlang without wxSupport (GUI stuff). after fiddling the smallest I can get it is:

{
  nativeBuildInputs = [
    autoreconfHook
    makeWrapper
    perl
    gnum4
    buildPackages.libxslt
    libxml2
  ];
}

if I remove that buildPackages from libxslt I get a format error for xsltproc:

xsltproc --output "../man3/array.3" --stringparam company "Ericsson AB" --stringparam docgen "/build/source/bootstrap/lib/erl_docgen" --stringparam gendate "$date" --stringparam appname "stdlib" --stringparam appver "3.4.5" --stringparam specs_file "$specs_file" --xinclude -path /build/source/bootstrap/lib/erl_docgen/priv/dtd  -path /build/source/bootstrap/lib/erl_docgen/priv/dtd_man_entities /build/source/bootstrap/lib/erl_docgen/priv/xsl/db_man.xsl array.xml
/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin/bash: line 2: /nix/store/rlv5jd00hksp449aqizf33q8nnrx6j80-libxslt-1.1.33-armv7l-unknown-linux-gnueabihf-bin/bin/xsltproc: cannot execute binary file: Exec format error
make[5]: *** [/build/source/make/armv7l-unknown-linux-gnueabihf/otp.mk:293: ../man3/array.3] Error 126
make[5]: Leaving directory '/build/source/lib/stdlib/doc/src'
make[4]: *** [/build/source/make/otp_release_targets.mk:182: release_docs] Error 2
make[4]: Leaving directory '/build/source/lib/stdlib/doc/src'
make[3]: *** [/build/source/make/otp_subdir.mk:29: release_docs] Error 2
make[3]: Leaving directory '/build/source/lib/stdlib'
make[2]: *** [/build/source/make/otp_subdir.mk:29: release_docs] Error 2
make[2]: Leaving directory '/build/source/lib'
make[1]: *** [Makefile:416: release_docs] Error 2
make[1]: Leaving directory '/build/source'
make: *** [Makefile:1029: install-docs] Error 2

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for investigating! We should definitely get to the bottom of why libxslt is different.

Copy link
Member

Choose a reason for hiding this comment

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

Opened #58327 in case that makes a difference.

I only know that sometimes overrides in all-packages.nix breaks splicing
of the correct architecture.

This PR works around that.

Copy link
Member

Choose a reason for hiding this comment

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

That other PR causes more problems. (I almost rather remove the with pkgs!) Can we do everything but xslt leaving a TODO?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do everything but xslt leaving a TODO?

Am I right if I think it then will work already with erlang_nox?

]
++ optional isCross buildPackages.erlang;

buildInputs = [ ncurses openssl ]
++ optionals wxSupport wxPackages2
Expand Down Expand Up @@ -83,7 +94,7 @@ in stdenv.mkDerivation ({
++ optional enableThreads "--enable-threads"
++ optional enableSmpSupport "--enable-smp-support"
++ optional enableKernelPoll "--enable-kernel-poll"
++ optional enableHipe "--enable-hipe"
++ optional (enableHipe && !isCross) "--enable-hipe"
++ optional javacSupport "--with-javac"
++ optional odbcSupport "--with-odbc=${unixODBC}"
++ optional wxSupport "--enable-wx"
Expand Down