Nixpkgs: perlPackages.XMLParser: cross compilation is broken

Created on 8 Nov 2019  路  4Comments  路  Source: NixOS/nixpkgs

Describe the bug
perlPackages.XMLParser fails to cross compile on current nixos-unstable (7827d3f4497ed722fedca57fd4d5ca1a65c38256).

Unfortunately this means that one cannot crosscompile a NixOS system right now, as nixos/modules/system/activation/top-level.nix depends on the package.

To Reproduce
Run nix build nixpkgs.pkgsCross.aarch64-multiplatform.perlPackages.XMLParser.

$ nix log /nix/store/ig0bsk29l8rl5qvqy53n2n8gmnwib2m4-perl5.30.0-XML-Parser-2.46-aarch64-unknown-linux-gnu.drv
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/qmfwv8kx7dxihx6x47lcs5qnfq1x6m9w-XML-Parser-2.46.tar.gz
source root is XML-Parser-2.46
setting SOURCE_DATE_EPOCH to timestamp 1569302874 of file XML-Parser-2.46/MANIFEST
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
patching ./samples/xmlfilter...
patching ./samples/canonical...
patching ./samples/xmlcomments...
patching ./samples/xmlstats...
patching ./t/external_ent.t...
patching ./t/decl.t...
patching ./t/parament.t...

Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' (or
'libexpat1-dev') package with your OS package manager. See 'README'.

Or you can download expat from:

http://sourceforge.net/projects/expat/

If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:

    EXPATLIBPATH=...  To set the directory in which to find libexpat

    EXPATINCPATH=...  To set the directory in which to find expat.h

For example:

    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include

Note that if you build against a shareable library in a non-standard location
you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
variable at run time for perl to find the library.

no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
no Makefile, doing nothing
@nix { "action": "setPhase", "phase": "installPhase" }
installing
install flags: SHELL=/nix/store/zavn4np1jvm79f0rafkv0p1mrag09qkz-bash-4.4-p23/bin/bash pkgconfigdir=/nix/store/q3v25rngsdlaa31vxwxajhgylkqsbm2q-perl5.30.0-XML-Parser-2.46-aarch64-unknown-linux-gnu/lib/pkgconfig m4datadir=/nix/store/q3v25r>
make: *** No rule to make target 'install'.  Stop.

Additional context
I guess 076dc17149af60635d52621e3a2a341af046af2e, caused the issue, at least when I revert it, I can crosscompile the package.

Also this looks related to https://github.com/NixOS/nixpkgs/issues/36675.

For anybody in need of a quick and dirty fix: I use this patch to cross compile my system:

diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index 61822351ee2..846495ffc0f 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -20070,11 +20070,16 @@ let

   XMLParser = buildPerlPackage {
     pname = "XML-Parser";
-    version = "2.46";
-    src = fetchurl {
-      url = mirror://cpan/authors/id/T/TO/TODDR/XML-Parser-2.46.tar.gz;
-      sha256 = "0pai3ik47q7rgnix9644c673fwydz52gqkxr9kxwq765j4j36cfk";
-    };
+    version = if (stdenv.buildPlatform != stdenv.hostPlatform) then "2.44" else "2.46";
+    src = if (stdenv.buildPlatform != stdenv.hostPlatform) then
+      (fetchurl {
+        url = mirror://cpan/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz;
+        sha256 = "05ij0g6bfn27iaggxf8nl5rhlwx6f6p6xmdav6rjcly3x5zd1s8s";
+      }) else
+      (fetchurl {
+        url = mirror://cpan/authors/id/T/TO/TODDR/XML-Parser-2.46.tar.gz;
+        sha256 = "0pai3ik47q7rgnix9644c673fwydz52gqkxr9kxwq765j4j36cfk";
+      });
     patchPhase = stdenv.lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
       substituteInPlace Expat/Makefile.PL --replace 'use English;' '#'
     '' + stdenv.lib.optionalString stdenv.isCygwin ''
bug cross-compilation

All 4 comments

+    version = if (stdenv.buildPlatform != stdenv.hostPlatform) then "2.44" else "2.46";
+    src = if (stdenv.buildPlatform != stdenv.hostPlatform) then

I would put if (stdenv.buildPlatform != stdenv.hostPlatform) then around whole derivation:

XMLParser_2_44 = buildPerlPackage {
...
};
XMLParser_latest = buildPerlPackage {
...
};
XMLParser = if stdenv.buildPlatform != stdenv.hostPlatform then XMLParser_2_44 else XMLParser_latest;

The reason is 2.46 might be updated to 2.47 and further and that update might change buildInputs, patchPhase which would affect 2.44 too if if is only in src= and version=

BTW, HTTP::Daemon is stuck to 6.01 and not updated for the same reason, the newer versions fail to cross-compile.
So, undoing of XMLParser: 2.44 -> 2.46 is good too

XML::Parser is back to 2.44 as part of https://github.com/NixOS/nixpkgs/pull/73954
so, this issue could be closed (for some reason it was not closed automatically, probably because of merging to staging instead of master).

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

retrry picture retrry  路  3Comments

chris-martin picture chris-martin  路  3Comments

lverns picture lverns  路  3Comments

teto picture teto  路  3Comments

spacekitteh picture spacekitteh  路  3Comments