NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.69k stars 13.83k forks source link

`perlPackages.Testutf8` fails when cross-compiling #198548

Open Majiir opened 1 year ago

Majiir commented 1 year ago

Steps To Reproduce

Build perlPackages.Testutf8 cross-compiled for armv7l-hf-multiplatform on a x86_64-linux host:

nix build 'nixpkgs#pkgsCross.armv7l-hf-multiplatform.perlPackages.Testutf8'

Build log

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/b31nlj5bnzjgfwcxjyjyrc4987v9fziw-Test-utf8-1.02.tar.gz
source root is Test-utf8-1.02
setting SOURCE_DATE_EPOCH to timestamp 1583064372 of file Test-utf8-1.02/xt/anyperlperlcriticrc
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
patching ./xt/003perlcritic.t...
patching ./xt/001pod.t...
patching ./xt/002podcoverage.t...
patching ./t/02invalid.t...
patching ./t/04ascii.t...
patching ./t/07valid_docu.t...
patching ./t/06flag.t...
patching ./t/01basic.t...
patching ./t/05latin1.t...
patching ./t/03deu.t...
Can't load module Fcntl, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the Fcntl module statically linked into it.)
 at inc/Module/Install/Makefile.pm line 6.
Compilation failed in require at inc/Module/Install/Makefile.pm line 6.
BEGIN failed--compilation aborted at inc/Module/Install/Makefile.pm line 6.
Compilation failed in require at inc/Module/Install.pm line 307.
The 'makemaker_args' method does not exist in the 'inc' path!
Please remove the 'inc' directory and run Makefile.PL again to load it.

Additional context

Above build log is from nixpkgs at 9ecc270f02b09b2f6a76b98488554dd842797357. It also fails on latest master (535abb755ed4f0b912bb70d2834371a358185ce8).

Notify maintainers

I'm not sure who to notify here. The last maintainer appears to be a deleted user.

Metadata

nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.19.14, NixOS, 22.05 (Quokka), 22.05.20221012.e06bd4b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `""`
 - channels(majiir): `""`
 - nixpkgs: `/etc/nix/inputs/nixpkgs`
GangaRamX commented 1 year ago

Hi, Did you find any workaround for this issue? I am also facing same issue when I cross compile for riscv arch.

Majiir commented 1 year ago

I never solved the cross-compilation problem. I did switch away from GRUB, because it's what was ultimately pulling in this dependency.

GangaRamX commented 1 year ago

Issue persists in command $> nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.perlPackages.Testutf8

Did similar changes for Testutf8 too but another Perl package failed:

error: builder for '/nix/store/mp6ap29xawb3mwjsb66dmy5z9a358g9a-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu.drv' failed with exit code 2;
       last 10 log lines:
       > Installing /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/share/man/man3/XML::SAX::ParserFactory.3
       > Installing /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/share/man/man3/XML::SAX::PurePerl::Reader.3
       > Installing /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/share/man/man3/XML::SAX.3
       > Installing /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/share/man/man3/XML::SAX::DocumentLocator.3
       > Installing /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/share/man/man3/XML::SAX::PurePerl.3
       > Installing /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/share/man/man3/XML::SAX::Intro.3
       > Appending installation info to /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/lib/perl5/5.36.0/riscv64-linux/perllocal.pod
       > Can't locate XML/SAX.pm in @INC (you may need to install the XML::SAX module) (@INC contains: /nix/store/44xnllrmif2398vhfwk7nskafhv88sss-perl-riscv64-unknown-linux-gnu-5.36.0-mini/lib/perl5/cross_perl/5.36.0 /nix/store/0dka6kdnwpsk7rjywkfyvw3dgihw9ip5-perl-riscv64-unknown-linux-gnu-5.36.0/lib/perl5/5.36.0 /nix/store/0dka6kdnwpsk7rjywkfyvw3dgihw9ip5-perl-riscv64-unknown-linux-gnu-5.36.0/lib/perl5/5.36.0/riscv64-linux /nix/store/0dka6kdnwpsk7rjywkfyvw3dgihw9ip5-perl-riscv64-unknown-linux-gnu-5.36.0/lib/perl5/site_perl/5.36.0 /nix/store/0dka6kdnwpsk7rjywkfyvw3dgihw9ip5-perl-riscv64-unknown-linux-gnu-5.36.0/lib/perl5/site_perl/5.36.0/riscv64-linux /nix/store/am6q1w1cgk0nax02i4p62ddwgh396l6p-perl5.36.0-XML-NamespaceSupport-1.12-riscv64-unknown-linux-gnu/lib/perl5/site_perl/5.36.0 /nix/store/am6q1w1cgk0nax02i4p62ddwgh396l6p-perl5.36.0-XML-NamespaceSupport-1.12-riscv64-unknown-linux-gnu/lib/perl5/site_perl/5.36.0/riscv64-linux /nix/store/5v2lvxgp5cjhibdczhgvf8lwvcc4nxrm-perl5.36.0-XML-SAX-Base-1.09-riscv64-unknown-linux-gnu/lib/perl5/site_perl/5.36.0 /nix/store/5v2lvxgp5cjhibdczhgvf8lwvcc4nxrm-perl5.36.0-XML-SAX-Base-1.09-riscv64-unknown-linux-gnu/lib/perl5/site_perl/5.36.0/riscv64-linux /nix/store/7fhvq7m7r20lxi6i9smvj8z3v88vrpi3-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu/lib/perl5/site_perl .).
       > BEGIN failed--compilation aborted.
       > make: *** [Makefile:743: install_sax_pureperl] Error 2
       For full logs, run 'nix log /nix/store/mp6ap29xawb3mwjsb66dmy5z9a358g9a-perl5.36.0-XML-SAX-1.02-riscv64-unknown-linux-gnu.drv'.
error: 1 dependencies of derivation '/nix/store/fkp36ghyc5bc30ssyibj5ad8cxgzzy4r-perl-riscv64-unknown-linux-gnu-5.36.0-env.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9d1slcn6318p8jkk3hckias0mqfjvhzd-install-grub.sh.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mgl01qiwv01rxxwc0fx215a2kzixrg5s-nixos-system-ghaf-host-22.11.20230323.467f913.drv' failed to build
error: 1 dependencies of derivation '/nix/store/4mxfbydrjp4rffhn24xi6ddrrnsw259i-nixos-disk-image.drv' failed to build
[ghaf]$>
G3zz commented 1 year ago

I just hit this issue as well and am coming to this trying to cross compile nixos to armv7l (so not a Perl expert at all), but I think I can see why it's happening:

Looking at this issue, the problem seems to be that the default install target is install_sax_pureperl, which is defined in the package's Makefile.PL to be:

\t\@\$(PERL) -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()"

This won't work during cross-compilation because the PERL variable points to a perl.mini (not a full perl), which is only supposed to be used for configuration - according to the few references I've seen.

The nix derivation also has a postInstall attribute that also uses the PERL variable - which will also be inappropriate during cross-compilation.

Not knowing the Perl ecosystem very well, I wonder if we could change the installTarget to pure_install, which would stop this stateful mutation. If it's actually needed (I don't know), then perhaps there is another way to configure the interpreter using a config file or something similar?

nixos-discourse commented 1 year ago

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

https://discourse.nixos.org/t/cross-compiling-and-maybe-even-remote-deploying-a-nixos-system/31755/6

lopsided98 commented 1 year ago

This is now preventing NixOS cross-compilation due to #246772.