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
Draft
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
26 changes: 20 additions & 6 deletions pkgs/development/interpreters/erlang/generic-builder.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{ pkgs, stdenv, fetchFromGitHub, makeWrapper, gawk, gnum4, gnused
, libxml2, libxslt, ncurses, openssl, perl, autoconf
, libxml2, libxslt, ncurses, openssl, perl, autoconf, zlib
# TODO: use jdk https://github.com/NixOS/nixpkgs/pull/89731
, openjdk8 ? null # javacSupport
, unixODBC ? null # odbcSupport
, libGL ? null, libGLU ? null, wxGTK ? null, wxmac ? null, xorg ? null # wxSupport
, parallelBuild ? false
, withSystemd ? stdenv.isLinux, systemd # systemd support in epmd
, buildPackages
}:

{ baseName ? "erlang"
Expand Down Expand Up @@ -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);


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

inherit src version;

nativeBuildInputs = [ autoconf makeWrapper perl gnum4 libxslt libxml2 ];

buildInputs = [ ncurses openssl ]
nativeBuildInputs = [
autoconf
makeWrapper
# seems to get a splice error finding perl if that one is not there
buildPackages.perl
buildPackages.libxslt
libxml2
]
++ optional hipeSupport gnum4
++ optional isCross buildPackages.erlang_nox;

buildInputs = [ ncurses openssl zlib ]
++ optionals wxSupport wxPackages2
++ optionals odbcSupport odbcPackages
++ optionals javacSupport javacPackages
Expand All @@ -65,7 +78,7 @@ in stdenv.mkDerivation ({
enableParallelBuilding = parallelBuild;

# Clang 4 (rightfully) thinks signed comparisons of pointers with NULL are nonsense
prePatch = ''
prePatch = optional wxSupport ''
substituteInPlace lib/wx/c_src/wxe_impl.cpp --replace 'temp > NULL' 'temp != NULL'

${prePatch}
Expand All @@ -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.

++ optional javacSupport "--with-javac"
++ optional odbcSupport "--with-odbc=${unixODBC}"
++ optional wxSupport "--enable-wx"
++ optional withSystemd "--enable-systemd"
++ optional stdenv.isDarwin "--enable-darwin-64bit"
++ optional isCross "erl_xcomp_sysroot=${stdenv.cc.libc}"
++ configureFlags;

# install-docs will generate and install manpages and html docs
Expand Down