Subject: bug#27149: perl for arm-linux-gnueabihf

From: Ludovic Courtès <[email-masked]>
Date: Sun, 20 Jan 2019 23:39:23 +0100

Hello,

Ricardo Wurmus <[email-masked]> skribis:

>> *guix build --target=arm-linux-gnueabihf* *perl* fails with the following
>> output: https://pastebin.com/QF0xKAmR
>
> Here’s the output copied from pastebin:
>
> starting phase `remove-extra-references'

[...]

>            1 (string-append "incpth='" #f "/include'\n")
> In ice-9/boot-9.scm:
>    752:25  0 (dispatch-exception _ _ _)
>
> ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
> In procedure string-append: Wrong type (expecting string): #f
> builder for `/gnu/store/zj5xld149ibdyc4nlm2dj41jnjm9bqyn-perl-5.28.0.drv' failed with exit code 1
> build of /gnu/store/zj5xld149ibdyc4nlm2dj41jnjm9bqyn-perl-5.28.0.drv failed
>
> I have never tried to cross-compiled packages for “arm-linux-gnueabihf”.
> I don’t know if this is expected to work.

The “arm-linux-gnueabihf” is a cross-compilation triplet that we
generally support.  However, note, Gérard, that not all packages in Guix
can be successfully cross-compiled, and Perl is one that fails to cross
build.  We are not committed to supporting cross-compilation of every
package, but we’re of course happy to make the feature more useful.

The patch below is the beginning of a fix, but as it is, it builds a
native Perl.  To address that, we need to fiddle with Perl’s peculiar
build system.  If you know how to instruct it to cross-build, let’s
address this!  :-)

Thanks,
Ludo’.

PS: This issue was previously reported at
    <https://issues.guix.info/issue/27149> so I suggest we keep
    discussing it there.

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index c4d9d64de3..109a4c1154 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2013 Andreas Enge <[email-masked]>
 ;;; Copyright © 2015, 2016, 2017, 2019 Ricardo Wurmus <[email-masked]>
 ;;; Copyright © 2015, 2016, 2017 Eric Bavier <[email-masked]>
@@ -78,7 +78,7 @@
                        "perl-reproducible-build-date.patch"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:tests? #f
+     `(#:tests? #f
        #:configure-flags
        (let ((out  (assoc-ref %outputs "out"))
              (libc (assoc-ref %build-inputs "libc")))
@@ -127,7 +127,10 @@
          (add-after 'install 'remove-extra-references
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((out     (assoc-ref outputs "out"))
-                    (libc    (assoc-ref inputs "libc"))
+                    (libc    (assoc-ref inputs
+                                        ,(if (%current-target-system)
+                                             "cross-libc"
+                                             "libc")))
                     (config1 (car (find-files (string-append out "/lib/perl5")
                                               "^Config_heavy\\.pl$")))
                     (config2 (find-files (string-append out "/lib/perl5")