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

perl's TermReadKey fails to cross compile to armv7 #54510

Closed
illegalprime opened this issue Jan 23, 2019 · 4 comments
Closed

perl's TermReadKey fails to cross compile to armv7 #54510

illegalprime opened this issue Jan 23, 2019 · 4 comments

Comments

@illegalprime
Copy link
Member

First let me say that cross-compilation in Nix is awesome! Thank you everyone!

Issue description

Probably related to #34273.

Compiling this module (TermReadKey) for armv7l-hf-multiplatform fails, which leads to nix failing to compile other packages like git and ripgrep. The error is the following:

builder for '/nix/store/4s2r5jma26fkazlp1ingl2g2rvnijw8c-perl5.28.1-TermReadKey-2.37-armv7l-unknown-linux-gnueabihf.drv' failed with exit code 2; last 10 log lines:
   #   define WIDEST_UTYPE U64
   
  rm -f blib/arch/auto/Term/ReadKey/ReadKey.so
  armv7l-unknown-linux-gnueabihf-gcc  -shared  ReadKey.o  -o blib/arch/auto/Term/ReadKey/ReadKey.so  \
        \
    
  chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
  "/nix/store/22w1n5jkpqa5yy7ks45xfqg5ygl18nsl-perl-5.28.1-armv7l-unknown-linux-gnueabihf/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey_pm.PL ReadKey.pm
  /nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash: /nix/store/22w1n5jkpqa5yy7ks45xfqg5ygl18nsl-perl-5.28.1-armv7l-unknown-linux-gnueabihf/bin/perl: cannot execute binary file: Exec format error
  make: *** [Makefile:534: ReadKey.pm] Error 126
[0 built (1 failed), 0.0 MiB DL]
error: build of '/nix/store/4s2r5jma26fkazlp1ingl2g2rvnijw8c-perl5.28.1-TermReadKey-2.37-armv7l-unknown-linux-gnueabihf.drv' failed

After applying this diff:

diff --git a/pkgs/development/perl-modules/generic/default.nix b/pkgs/development/perl-modules/generic/default.nix
index a87e0c616fd..5b4d9ffa15c 100644
--- a/pkgs/development/perl-modules/generic/default.nix
+++ b/pkgs/development/perl-modules/generic/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, perl }:
+{ lib, stdenv, perl, buildPackages }:
 
 { nativeBuildInputs ? [], name, ... } @ attrs:
 
@@ -37,6 +37,6 @@ stdenv.mkDerivation (
     name = "perl${perl.version}-${name}";
     builder = ./builder.sh;
     nativeBuildInputs = nativeBuildInputs ++ [ (perl.dev or perl) ];
-    inherit perl;
+    perl = buildPackages.perl;
   }
 )

The error changes:

builder for '/nix/store/i52d724nqy0zw7kkxwvn4wqa47asw7qs-perl5.28.1-TermReadKey-2.37-armv7l-unknown-linux-gnueabihf.drv' failed with exit code 2; last 10 log lines:
        \
    
  chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
  "/nix/store/9q11wzyadmm9nrx9nrmb7l2iwf52sprm-perl-5.28.1/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey_pm.PL ReadKey.pm
  Can't load 'blib/arch/auto/Term/ReadKey/ReadKey.so' for module Term::ReadKey: blib/arch/auto/Term/ReadKey/ReadKey.so: wrong ELF class: ELFCLASS32 at /nix/store/9q11wzyadmm9nrx9nrmb7l2iwf52sprm-perl-5.28.1/lib/perl5/5.28.1/x86_64-linux-thread-multi/DynaLoader.pm line 193.
   at /nix/store/9q11wzyadmm9nrx9nrmb7l2iwf52sprm-perl-5.28.1/lib/perl5/5.28.1/x86_64-linux-thread-multi/DynaLoader.pm line 95.
        DynaLoader::croak("Can't load 'blib/arch/auto/Term/ReadKey/ReadKey.so' for modul"...) called at /nix/store/9q11wzyadmm9nrx9nrmb7l2iwf52sprm-perl-5.28.1/lib/perl5/5.28.1/x86_64-linux-thread-multi/DynaLoader.pm line 193
        DynaLoader::bootstrap("Term::ReadKey") called at ReadKey_pm.PL line 515
  Creating ReadKey.pm
  Bootstrapping the XS for blockoptions: make: *** [Makefile:534: ReadKey.pm] Error 255
[0 built (1 failed)]
error: build of '/nix/store/i52d724nqy0zw7kkxwvn4wqa47asw7qs-perl5.28.1-TermReadKey-2.37-armv7l-unknown-linux-gnueabihf.drv' failed

I can see that it's trying to load the wrong .so but I'm not sure how to debug beyond this point.

Steps to reproduce

  1. clone nixpkgs and cd into it
  2. nix build -f . pkgsCross.armv7l-hf-multiplatform.perlPackages.TermReadKey

Technical details

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.78, NixOS, 18.09.1185.9ea650bb5de (Jellyfish)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.1.1`
 - channels(michael): `""`
 - channels(root): `"nixos-18.09"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@illegalprime illegalprime changed the title perl's TermReadKey fails to cross compile perl's TermReadKey fails to cross compile to armv7 Jan 23, 2019
@AlexLJordan
Copy link

I have the same problem with aarch64 right now. It's because as you can see here:

chmod 755 blib/arch/auto/Term/ReadKey/ReadKey.so
  "/nix/store/22w1n5jkpqa5yy7ks45xfqg5ygl18nsl-perl-5.28.1-armv7l-unknown-linux-gnueabihf/bin/perl" "-Iblib/arch" "-Iblib/lib" ReadKey_pm.PL ReadKey.pm
  /nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash: /nix/store/22w1n5jkpqa5yy7ks45xfqg5ygl18nsl-perl-5.28.1-armv7l-unknown-linux-gnueabihf/bin/perl: cannot execute binary file: Exec format error

It tries to execute /nix/store/.../bin/perl which of course fails because this binary is compiled for aarch64 (or armv7 in your case) not our current system ("x86_64-linux").

This is stopping me from compiling an aarch64 installation medium and I don't know how to fix this right now.

@illegalprime
Copy link
Member Author

@illegalprime
Copy link
Member Author

i think i have some kind of fix, will post later today

@illegalprime
Copy link
Member Author

this was fixed by #56019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants