From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:47060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQB1H-0001jd-Jf for guix-patches@gnu.org; Sun, 19 Apr 2020 10:34:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQB1G-0002Vb-Qm for guix-patches@gnu.org; Sun, 19 Apr 2020 10:34:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34128) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jQB1G-0002VE-D9 for guix-patches@gnu.org; Sun, 19 Apr 2020 10:34:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jQB1G-0003p9-9q for guix-patches@gnu.org; Sun, 19 Apr 2020 10:34:02 -0400 Subject: [bug#40698] [core-updates]: [PATCH v2] gnu: perl: Actually produce a host perl when cross-compiling. Resent-Message-ID: From: Marius Bakke In-Reply-To: <87lfmrua71.fsf@gnu.org> References: <87r1wku54w.fsf@gnu.org> <87lfmrua71.fsf@gnu.org> Date: Sun, 19 Apr 2020 16:33:06 +0200 Message-ID: <87imhvh7fh.fsf@devup.no> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Jan Nieuwenhuizen , 40698@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jan Nieuwenhuizen writes: > Jan Nieuwenhuizen writes: > >> As discussed on IRC, I tried to apply perl-cross >> (https://github.com/arsv/perl-cross) to make perl actually cross build >> for our Hurd VM. > > Find an improved patch below. It fixes > >> Can't exec "": No such file or directory at /gnu/store/dd5a35aca6411= w5l29ask7pl626v8j4r-perl-5.30.2/lib/perl5/5.30.2/i586-/Cwd.pm line 204. >> Can't exec "": No such file or directory at /gnu/store/mfnmg1m37kyrb= 65alnj6jn2fzw7zkapw-autoconf-cross-2.69/share/autoconf/Autom4te/FileUtils.p= m line 345. > > which was due to having > > #define SH_PATH "" > > in config.h. It also fixes "cwd" in perl, that was caused by this > > (substitute* "dist/PathTools/Cwd.pm" > (("/bin/pwd") > - (which "pwd"))) > + (which "pwd"))) ;TODO: fix cross-compile next rebuild cy= cle > > and now fixed lateron > > + ;;TODO: fix this in setup-configure next rebuild = cycle > + (substitute* "dist/PathTools/Cwd.pm" > + (("/gnu/store/[^/]*-coreutils-[^/]*") coreutils= )) > > Using this, I can cross-build perl and which allows me to ceate patches > to cross build, autoconf and automake that work to configure Guix git on > the Hurd. Wooow, awesome work (as usual)! Some feedback on the patch: > From b10ca56254cd1b1f8ec4b222ad27cb02ce59316c Mon Sep 17 00:00:00 2001 > From: "Jan (janneke) Nieuwenhuizen" > Date: Sat, 18 Apr 2020 17:05:48 +0200 > Subject: [PATCH] gnu: perl: Actually produce a host perl when cross-compi= ling. > > * gnu/packages/perl.scm (perl)[native-inputs]: When cross-compiling, add > `perl-cross' input. > [arguments]: When cross-compiling, use it to produce binary for host. > --- > gnu/packages/perl.scm | 106 +++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 100 insertions(+), 6 deletions(-) [...] > @@ -112,7 +115,7 @@ > ;; Use the right path for `pwd'. > (substitute* "dist/PathTools/Cwd.pm" > (("/bin/pwd") > - (which "pwd"))) > + (which "pwd"))) ;TODO: fix cross-compile next rebuild cy= cle It might be clearer to add "TODO: use coreutils from INPUTS instead of 'which'" here, maybe mentioning the related substitution below. > ;; Build in GNU89 mode to tolerate C++-style comment in lib= c's > ;; . > @@ -120,10 +123,84 @@ > (("-std=3Dc89") > "-std=3Dgnu89")) > #t)) > - (replace 'configure > - (lambda* (#:key configure-flags #:allow-other-keys) > - (format #t "Perl configure flags: ~s~%" configure-flags) > - (apply invoke "./Configure" configure-flags))) > + ,@(if (%current-target-system) > + `((add-after 'unpack 'unpack-cross > + (lambda* (#:key inputs #:allow-other-keys) > + (let ((cross-checkout (assoc-ref %build-inputs "per= l-cross"))) > + (invoke "chmod" "-R" "+w" ".") Please use 'make-file-writable' instead of chmod. > + (copy-recursively cross-checkout ".")) > + (let ((bash (assoc-ref %build-inputs "bash"))) Use the scoped 'inputs' instead of the magical %build-inputs. > + (substitute* '("Makefile.config.SH" > + "cnf/config.guess" > + "cnf/config.sub" > + "cnf/configure" > + "cnf/configure_misc.sh" > + "miniperl_top") > + (("! */bin/sh") (string-append "! " bash "/bin/= bash")) > + ((" /bin/sh") (string-append bash "/bin/bash"))) > + (substitute* '("cnf/configure_tool.sh") > + (( "[\t ]*result \"BSD\".*") > + "\ > + result \"BSD\" > + ;; > + *-gnu) > + result \"GNU\" > +")) > + (substitute* '("ext/Errno/Errno_pm.PL") > + (( "\\$cpp < errno.c") "gcc -E errno.c"))) Should $cpp not be replaced with 'g++'? > + #t)) > + (replace 'configure > + (lambda* (#:key configure-flags outputs inputs #:allo= w-other-keys) > + (let* ((out (assoc-ref outputs "out")) > + (configure-flags > + (cons* > + ;; `perl-cross' confuses target and host > + (string-append "--target=3D" ,(%current-ta= rget-system)) > + (string-append "--prefix=3D" out) > + "-Dbyteorder=3D1234" > + (filter (negate > + (lambda (x) (or (string-prefix? "= -d" x) > + (string-prefix? "= -Dcc=3D" x)))) > + configure-flags))) > + (bash (assoc-ref inputs "bash")) > + (coreutils (assoc-ref inputs "coreutils"))) > + (format (current-error-port) > + "running ./configure ~a\n" (string-join c= onfigure-flags)) > + (apply invoke (cons "./configure" configure-flags= )) > + (substitute* "config.sh" > + (("^libs=3D.*") "libs=3D'-ldl -lpthread -lm'\n") > + (("^perllibs=3D.*") "perllibs=3D'-ldl -lpthread= -lm'\n") > + (("/gnu/store/[^/]*-bash-[^/]*") bash)) This phase should add a let binding for (%store-directory) and refer to that instead of the literal /gnu/store strings (see e.g. 'git'). > + (substitute* '("config.h") > + (("^#define OSNAME .*") > + (string-append "#define OSNAME \"" > + ,(if (hurd-target?) "GNU" "Linu= x") Would it make sense to upstream this? > + "\"\n")) > + (("^# HAS_NANOSLEEP") "/* #undef HAS_NANOSLEEP = */") Is this substitution required on all cross-compilation targets? > + (("^#define SH_PATH .*") > + (string-append "#define SH_PATH \"" bash "/bi= n/bash\"\n"))) > + ;;TODO: fix this in setup-configure next rebuild = cycle > + (substitute* "dist/PathTools/Cwd.pm" > + (("/gnu/store/[^/]*-coreutils-[^/]*") coreutils= )) > + #t))) > + (add-after 'build 'touch-non-built-files-for-install > + (lambda _ > + ;; `make install' wants to install this; it wasn't = built... > + (mkdir-p "cpan/Pod-Usage/blib/script") > + (with-output-to-file "cpan/Pod-Usage/blib/script/po= d2text" > + (lambda _ (display ""))) > + (with-output-to-file "cpan/Pod-Usage/blib/script/po= d2usage" > + (lambda _ (display ""))) > + (with-output-to-file "cpan/Pod-Checker/blib/script/= podchecker" > + (lambda _ (display ""))) > + (mkdir-p "cpan/Pod-Parser/blib/script") > + (with-output-to-file "cpan/Pod-Parser/blib/script/p= odselect" > + (lambda _ (display ""))) Using '(call-with-output-file "foo" (const #t))' is clearer IMO. Also consider using 'for-each' here. Phew! Thanks a lot for this, LGTM! > + #t))) > + `((replace 'configure > + (lambda* (#:key configure-flags #:allow-other-keys) > + (format #t "Perl configure flags: ~s~%" configure-f= lags) > + (apply invoke "./Configure" configure-flags))))) > (add-after 'install 'remove-extra-references > (lambda* (#:key inputs outputs #:allow-other-keys) > (let* ((out (assoc-ref outputs "out")) > @@ -152,6 +229,23 @@ > "/lib',\n")))) > config2) > #t)))))) > + (inputs > + (if (%current-target-system) > + `(("bash" ,bash-minimal) > + ("coreutils" ,coreutils)) > + '())) > + (native-inputs > + (if (%current-target-system) > + `(("perl-cross" > + ,(origin > + (method git-fetch) > + (uri (git-reference > + (url "https://github.com/arsv/perl-cross") > + (commit "1.3.3"))) > + (file-name (git-file-name "perl-cross" "1.3.3")) > + (sha256 > + (base32 "065qbl1x44maykaj8p8za0b6qxj74bz7fi2zsrlydir1mqb= 1js3d"))))) > + '())) > (native-search-paths (list (search-path-specification > (variable "PERL5LIB") > (files '("lib/perl5/site_perl"))))) > --=20 > 2.26.0 > > > --=20 > Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org > Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.c= om --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl6cYSMACgkQoqBt8qM6 VPpMxgf/acx1uFtgCrWX6ioXVZf4tKha1jmmqFjfAqBSwbmGemDowcRS2fjg/a2F ewayhKNTA+aO30braP0JbmNxNf/V/5Oh6vb1he4CT+iz05R8A8TeBOJgJvJ2Fhvo Q1xqm+CNr4YcHYAB8KXg7Vqs8V1G/qrRzNRTnIJAOC0X40vtZTXpDjJ1MZ74ags0 QoxdcZtcv3kO+IBl81ksTQyJLUve2NTzmdceUKVuOTSUZjxMlPU62z8nttMURDn1 geCLbkL9H1ujIgxTvqvA9cnSzih0STRZ3ITzUp0URsBYv0YFZ53q+f6I7CYRAV+n 79GV2tYrsaaKOTRE9ioFD/F2FqdqNw== =g7Nj -----END PGP SIGNATURE----- --=-=-=--