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

perlPackages.ModuleBuild: fix cross compilation #142349

Conversation

zakame
Copy link
Member

@zakame zakame commented Oct 20, 2021

Motivation for this change

Remove the need to test for an old $Fille::Temp::VERSION so we can cross-compile.

Fixes #66741

Also please label for Hacktoberfest once accepted 🙏

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@zakame zakame requested review from stigtsp, lopsided98 and ju1m October 20, 2021 12:23
@stigtsp
Copy link
Member

stigtsp commented Oct 20, 2021

@GrahamcOfBorg build pkgsCross.aarch64-multiplatform.perlPackages.ModuleBuild

@stigtsp
Copy link
Member

stigtsp commented Oct 20, 2021

Build fails for me

$ nix-build -A pkgsCross.aarch64-multiplatform.perlPackages.ModuleBuild
[..]
patching ./t/runthrough.t...
patching ./t/add_property_hash.t...
# running Build.PL --prefix /nix/store/d1j08ci68k3b7azs1bx2czp23hikci4n-perl5.34.0-Module-Build-aarch64-unknown-linux-gnu-0.4231 --installdirs site --config perl=/nix/store/1jm3ifss904lf1mx9br9jjd9dhz8a3py-perl-5.34.0-aarch64-unknown-linux-gnu-mini/bin/perl --fullperl "/nix/store/ypr273yvmr07n5n1w1gbcqnhpw7lbbvz-perl-5.34.0/bin/perl"

Checking optional features...
inc_bundling_support....disabled
  requires:
    ! inc::latest is not installed

ERRORS/WARNINGS FOUND IN PREREQUISITES.  You may wish to install the versions
of the modules indicated above before proceeding with this installation

Attempt to reload Scalar/Util.pm aborted.
Compilation failed in require at /nix/store/98rdfdqc7kax6ipm1jrmyqiacc7264vp-perl-5.34.0-aarch64-unknown-linux-gnu/lib/perl5/5.34.0/aarch64-linux/Data/Dumper.pm line 314.
Couldn't run Build.PL: No such file or directory at lib/Module/Build/Compat.pm line 341.
builder for '/nix/store/nj3615wg5djicv4icah9kzi7zppr6c28-perl5.34.0-Module-Build-aarch64-unknown-linux-gnu-0.4231.drv' failed with exit code 2
error: build of '/nix/store/nj3615wg5djicv4icah9kzi7zppr6c28-perl5.34.0-Module-Build-aarch64-unknown-linux-gnu-0.4231.drv' failed

@zakame
Copy link
Member Author

zakame commented Oct 20, 2021

Right, I missed something in commit - let me re-check 💪

@zakame
Copy link
Member Author

zakame commented Oct 21, 2021

Ok, so problem moves from not having to check $File::Temp::VERSION to the lack of dynamic loading for our cross-compiled Perl, noting that Attempt to reload Scalar/Util.pm aborted error - given a postPatch like this:

    postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
      sed -i '/File::Temp/d' Build.PL
      perl -MScalar::Util -E 'say qw(ok)'
    '';

We'd see this result:

$ nix-build -A pkgsCross.aarch64-multiplatform.perlPackages.ModuleBuild
this derivation will be built:
  /nix/store/lp1crvhc0phhl350sfnk2nm2gz3zl70v-perl5.34.0-Module-Build-aarch64-unknown-linux-gnu-0.4231.drv
building '/nix/store/lp1crvhc0phhl350sfnk2nm2gz3zl70v-perl5.34.0-Module-Build-aarch64-unknown-linux-gnu-0.4231.drv'...
unpacking sources
unpacking source archive /nix/store/pm54fbqaak7i30i6axai653vs487rfal-Module-Build-0.4231.tar.gz
source root is Module-Build-0.4231
setting SOURCE_DATE_EPOCH to timestamp 1580284283 of file Module-Build-0.4231/t/xs.t
patching sources
Can't load module List::Util, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the List::Util module statically linked into it.)
 at /nix/store/98rdfdqc7kax6ipm1jrmyqiacc7264vp-perl-5.34.0-aarch64-unknown-linux-gnu/lib/perl5/5.34.0/aarch64-linux/Scalar/Util.pm line 23.
Compilation failed in require at /nix/store/98rdfdqc7kax6ipm1jrmyqiacc7264vp-perl-5.34.0-aarch64-unknown-linux-gnu/lib/perl5/5.34.0/aarch64-linux/Scalar/Util.pm line 23.
Compilation failed in require.
BEGIN failed--compilation aborted.
error: builder for '/nix/store/lp1crvhc0phhl350sfnk2nm2gz3zl70v-perl5.34.0-Module-Build-aarch64-unknown-linux-gnu-0.4231.drv' failed with exit code 255

(Apparently we can't load other dynamic modules like Fcntl as well.)

Also discovered alongside this is the cause why we're not seeing $File::Temp::VERSION - it is being stubbed in perl-cross which certainly doesn't have that variable defined.

Back to this, I understand we're not doing the equivalent of ./Configure --all-static (or setting -Uusedl) as I also checked the config_args via this cross-compiled perl -V, so I'm not sure if there's a bug here or in perl-cross:

Summary of my perl5 (revision 5 version 34 subversion 0) configuration:
   
  Platform:
    osname=linux
    osvers=current
    archname=aarch64-linux
    uname=''
    config_args='--prefix=/nix/store/98rdfdqc7kax6ipm1jrmyqiacc7264vp-perl-5.34.0-aarch64-unknown-linux-gnu -Dlibpth="" -Dglibpth="" -Ddefault_inc_excludes_dot -Uinstallusrbinperl -Dinstallstyle=lib/perl5 -Dlocincpth=/no-such-path/include -Dloclibpth=/nix/store/nrwmkyqhqczn61zrb3z05k31nnkqjqyb-glibc-aarch64-unknown-linux-gnu-2.33-50/lib -Dusethreads --build=x86_64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu --target=aarch64-unknown-linux-gnu --keeplog --mode=target --target=aarch64-unknown-linux-gnu --targetarch=aarch64-unknown-linux-gnu'
    hint=default

@Mindavi Mindavi added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Oct 22, 2021
@Mindavi
Copy link
Contributor

Mindavi commented Oct 22, 2021

Yes, there's some underlying things that, given solved, will fix a lot of packages.

@Artturin Artturin marked this pull request as draft October 26, 2021 13:49
@ju1m
Copy link
Contributor

ju1m commented Oct 29, 2021

@zakame, thanks for your debugging!
Just to be sure, do you see a way forward for fixing ModuleBuild or are you out of clues for now?
Also I guess that given the number of rebuilds, this PR should target staging instead of master.

@Artturin Artturin mentioned this pull request Nov 4, 2021
12 tasks
@zakame
Copy link
Member Author

zakame commented Nov 29, 2021

@zakame, thanks for your debugging! Just to be sure, do you see a way forward for fixing ModuleBuild or are you out of clues for now? Also I guess that given the number of rebuilds, this PR should target staging instead of master.

Hey, sorry I was busy elsewhere - yeah I'm currently out of clues especially as I'm testing this on both x66_64 and aarch64. I'll review again and recreate for staging target 👍

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 19, 2022
@aspauldingcode
Copy link

I'm still getting this problem..
Checking prerequisites...
test_requires:
! Couldn't find a $VERSION in prerequisite File::Temp
Manifying 1 pod document
checking whether aarch64-unknown-linux-gnu-gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of aarch64-unknown-linux-gnu-gcc... none

Checking optional features...
inc_bundling_support....disabled
requires:
! inc::latest is not installed

ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
of the modules indicated above before proceeding with this installation

I'm on NixOS 23.11 x86_64
Having a hard time cross-compiling for nixos mobile

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 26, 2023
@Artturin
Copy link
Member

Artturin commented Sep 26, 2023

pkgsCross.aarch64-multiplatform.perlPackages.ModuleBuild works here on master(99eb0f3)

Perl module cross was fixed in #225640 but some may still need extra fixes

Perhaps you're at a old revision

@Artturin Artturin closed this Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

perlPackages.ModuleBuild (a dependency of git) fails to cross-compile
6 participants