Patchwork perl: build with perlcross instead of qemu

login
register
mail settings
Submitter Arnout Vandecappelle
Date Nov. 9, 2012, 1:47 a.m.
Message ID <1352425626-10628-1-git-send-email-arnout@mind.be>
Download mbox | patch
Permalink /patch/197907/
State Accepted
Commit 234fe4433489bca81b79311239569525cc008d9d
Headers show

Comments

Arnout Vandecappelle - Nov. 9, 2012, 1:47 a.m.
The perlcross project makes it possible to properly cross-compile
perl.  It creates a host-miniperl that is configured for the target
and uses that to cross-compile the perl modules.

Unfortunately there are still a few hacks needed to make it work.
Proper fixes can be developed and upstreamed later.

Since there is no longer a dependency on qemu, it works on all
architectures again.

Also removed some config options:
- BR2_PACKAGE_PERL_CUSTOM_INSTALL just allows a selection of modules;
this can also be encoded by an empty BR2_PACKAGE_PERL_MODULES.
- BR2_PACKAGE_PERL_DB_FILE and BR2_PACKAGE_PERL_GDBM_FILE can be
derived automatically from the package configs.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
This is still a bit RFC.  I've tested in on a glibc x86_64, on a
minimal internal powerpc and a glibc ARM.  I haven't tested with any
of the autobuilder configurations, but I expect it will at least be
better than what we get now...

Francois, can you check if it also runs?  I've only done build tests.

Peter, if Francois confirms that the perl binary actually runs and if
he has no other concerns, then I'd commit this patch quickly and wait
for the autobuilder fallout.
 package/perl/Config.in |   40 +++----------
 package/perl/perl.mk   |  153 ++++++++++++++++++++----------------------------
 2 files changed, 71 insertions(+), 122 deletions(-)
Dan Pattison - Nov. 9, 2012, 3:01 a.m.
On 11/8/2012 5:47 PM, Arnout Vandecappelle (Essensium/Mind) wrote:
> The perlcross project makes it possible to properly cross-compile
> perl.  It creates a host-miniperl that is configured for the target
> and uses that to cross-compile the perl modules.
>
> Unfortunately there are still a few hacks needed to make it work.
> Proper fixes can be developed and upstreamed later.
>
> Since there is no longer a dependency on qemu, it works on all
> architectures again.
>
> Also removed some config options:
> - BR2_PACKAGE_PERL_CUSTOM_INSTALL just allows a selection of modules;
> this can also be encoded by an empty BR2_PACKAGE_PERL_MODULES.
> - BR2_PACKAGE_PERL_DB_FILE and BR2_PACKAGE_PERL_GDBM_FILE can be
> derived automatically from the package configs.
>
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> ---
> This is still a bit RFC.  I've tested in on a glibc x86_64, on a
> minimal internal powerpc and a glibc ARM.  I haven't tested with any
> of the autobuilder configurations, but I expect it will at least be
> better than what we get now...
>
> Francois, can you check if it also runs?  I've only done build tests.
>
> Peter, if Francois confirms that the perl binary actually runs and if
> he has no other concerns, then I'd commit this patch quickly and wait
> for the autobuilder fallout.
>   package/perl/Config.in |   40 +++----------
>   package/perl/perl.mk   |  153 ++++++++++++++++++++----------------------------
>   2 files changed, 71 insertions(+), 122 deletions(-)
>
> diff --git a/package/perl/Config.in b/package/perl/Config.in
> index 0642deb..b2991b0 100644
> --- a/package/perl/Config.in
> +++ b/package/perl/Config.in
> @@ -1,12 +1,5 @@
>   config BR2_PACKAGE_PERL
>   	bool "perl"
> -	depends on !BR2_avr32
> -	depends on !BR2_bfin
> -	depends on !BR2_sh2
> -	depends on !BR2_sh2a
> -	depends on !BR2_sh3
> -	depends on !BR2_sh3eb
> -	depends on !BR2_sh64
>   	help
>   	  Larry Wall's Practical Extraction and Report Language
>   	  An interpreted scripting language, known among some as "Unix's Swiss
> @@ -16,35 +9,18 @@ config BR2_PACKAGE_PERL
>   
>   if BR2_PACKAGE_PERL
>   
> -config BR2_PACKAGE_PERL_CUSTOM_INSTALL
> -	bool "custom install"
> -	help
> -	  Don't use the full install target
> -	  Install only a selection of modules (like microperl).
> -
>   config BR2_PACKAGE_PERL_MODULES
> -	string "additional modules"
> -	depends on BR2_PACKAGE_PERL_CUSTOM_INSTALL
> +	string "custom module selection"
>   	help
> -	  List of space-separated perl modules to copy to the rootfs.
> -
> -	  Examples: constant.pm Getopt/Std.pm Time/Local.pm
> +	  List of space-separated perl modules (without .pm) to copy to the
> +	  rootfs.
>   
> -	  Module dependencies are not automatic so check your needs.
> +	  Examples: constant Getopt/Std Time/Local
>   
> -config BR2_PACKAGE_PERL_DB_FILE
> -	bool "DB_File"
> -	select BR2_PACKAGE_BERKELEYDB
> -	help
> -	  Build the DB_File module.
> +	  Module dependencies on external libraries are not automatic so
> +	  check your needs.
>   
> -config BR2_PACKAGE_PERL_GDBM_FILE
> -	bool "GDBM_File"
> -	select BR2_PACKAGE_GDBM
> -	help
> -	  Build the GDBM_File module.
> +	  Leave empty for all modules (as far as the external libraries
> +	  are available).
>   
>   endif
> -
> -comment "perl requires an architecture supported by qemu"
> -	depends on BR2_avr32 || BR2_bfin || BR2_sh2 || BR2_sh2a || BR2_sh3 || BR2_sh3eb || BR2_sh64
> diff --git a/package/perl/perl.mk b/package/perl/perl.mk
> index 81dff04..f3c73dd 100644
> --- a/package/perl/perl.mk
> +++ b/package/perl/perl.mk
> @@ -12,7 +12,26 @@ PERL_LICENSE = Artistic
>   PERL_LICENSE_FILES = Artistic
>   PERL_INSTALL_STAGING = YES
>   
> -PERL_DEPENDENCIES = host-qemu
> +PERL_CROSS_VERSION = 0.7
> +PERL_CROSS_SITE    = http://download.berlios.de/perlcross
> +PERL_CROSS_SOURCE  = perl-5.$(PERL_VERSION_MAJOR).0-cross-$(PERL_CROSS_VERSION).tar.gz
> +
> +# We use the perlcross hack to cross-compile perl. It should
> +# be extracted over the perl sources, so we don't define that
> +# as a separate package. Instead, it is downloaded and extracted
> +# together with perl
> +
> +define PERL_CROSS_DOWNLOAD
> +	$(call DOWNLOAD,$(PERL_CROSS_SITE)/$(PERL_CROSS_SOURCE))
> +endef
> +PERL_POST_DOWNLOAD_HOOKS += PERL_CROSS_DOWNLOAD
> +
> +define PERL_CROSS_EXTRACT
> +	$(INFLATE$(suffix $(PERL_CROSS_SOURCE))) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \
> +	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(TAR_OPTIONS) -
> +endef
> +PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
> +
>   ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
>       PERL_DEPENDENCIES += berkeleydb
>   endif
> @@ -20,23 +39,31 @@ ifeq ($(BR2_PACKAGE_GDBM),y)
>       PERL_DEPENDENCIES += gdbm
>   endif
>   
> -PERL_CONF_OPT = -des \
> -		-Dusecrosscompile \
> -		-Dtargetrun=$(QEMU_USER) \
> -		-Dqemulib=$(STAGING_DIR) \
> -		-Dar="$(TARGET_AR)" \
> -		-Dcc="$(TARGET_CC)" \
> -		-Dcpp="$(TARGET_CC)" \
> -		-Dld="$(TARGET_LD)" \
> -		-Dnm="$(TARGET_NM)" \
> -		-Dranlib="$(TARGET_RANLIB)" \
> -		-Dccflags="$(TARGET_CFLAGS)" \
> -		-Dldflags="$(TARGET_LDFLAGS) -lgcc_s -lm" \
> -		-Dlddlflags="-shared" \
> -		-Dlibc=$(STAGING_DIR)/lib/libc.so \
> -		-Duseshrplib \
> -		-Dprefix=/usr \
> -		-Uoptimize
> +# Normally, --mode=cross should automatically do the two steps
> +# below, but it doesn't work for some reason.
> +PERL_HOST_CONF_OPT = \
> +	--mode=buildmini \
> +	--target=$(GNU_TARGET_NAME) \
> +	--target-arch=$(GNU_TARGET_NAME) \
> +	--set-target-name=$(GNU_TARGET_NAME)
> +
> +# We have to override LD, because an external multilib toolchain ld is not
> +# wrapped to provide the required sysroot options.  We also can't use ccache
> +# because the configure script doesn't support it.
> +PERL_CONF_OPT = \
> +	--mode=target \
> +	--target=$(GNU_TARGET_NAME) \
> +	--target-tools-prefix=$(TARGET_CROSS) \
> +	--prefix=/usr \
> +	-Dld="$(TARGET_CC_NOCCACHE)" \
> +	-A ccflags="$(TARGET_CFLAGS)" \
> +	-A ldflags="$(TARGET_LDFLAGS) -lm" \
> +	-A mydomain="" \
> +	-A myhostname="$(BR2_TARGET_GENERIC_HOSTNAME)" \
> +	-A myuname="Buildroot $(BR2_VERSION_FULL)" \
> +	-A osname=linux \
> +	-A osvers=$(LINUX_VERSION) \
> +	-A perlamdin=root
>   
>   ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
>       PERL_CONF_OPT += -Dusedevel
> @@ -46,93 +73,39 @@ ifneq ($(BR2_LARGEFILE),y)
>       PERL_CONF_OPT += -Uuselargefiles
>   endif
>   
> +PERL_MODULES = $(call qstrip,$(BR2_PACKAGE_PERL_MODULES))
> +ifneq ($(PERL_MODULES),)
> +PERL_CONF_OPT += --only-mod=$(subst $(space),$(comma),$(PERL_MODULES))
> +endif
> +
>   define PERL_CONFIGURE_CMDS
> -	rm -f $(@D)/config.sh
> -	(cd $(@D); ./Configure $(PERL_CONF_OPT))
> -	echo "# patched values"                                 >>$(@D)/config.sh
> -	$(SED) '/^myarchname=/d' \
> -		-e '/^mydomain=/d' \
> -		-e '/^myhostname=/d' \
> -		-e '/^myuname=/d' \
> -		-e '/^osname=/d' \
> -		-e '/^osvers=/d' \
> -		-e '/^perladmin=/d' \
> -		$(@D)/config.sh
> -	echo "myarchname='$(GNU_TARGET_NAME)'"                  >>$(@D)/config.sh
> -	echo "mydomain=''"                                      >>$(@D)/config.sh
> -	echo "myhostname='$(BR2_TARGET_GENERIC_HOSTNAME)'"      >>$(@D)/config.sh
> -	echo "myuname='Buildroot $(BR2_VERSION_FULL)'"          >>$(@D)/config.sh
> -	echo "osname='linux'"                                   >>$(@D)/config.sh
> -	echo "osvers='$(BR2_LINUX_KERNEL_VERSION)'"             >>$(@D)/config.sh
> -	echo "perladmin='root'"                                 >>$(@D)/config.sh
> -	(cd $(@D); ./Configure -S)
> -	cp $(@D)/config.h $(@D)/xconfig.h
> +	(cd $(@D); HOSTCC='$(HOSTCC_NOCACHE)' ./configure $(PERL_HOST_CONF_OPT))
> +	(cd $(@D); ./configure $(PERL_CONF_OPT))
>   	$(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
>   endef
>   
> +# perlcross's miniperl_top forgets base, which is required by mktables.
> +# Instead of patching, it's easier to just set PERL5LIB
>   define PERL_BUILD_CMDS
> -	echo "#!/bin/sh"                                > $(@D)/Cross/miniperl
> -	echo "$(QEMU_USER) $(@D)/miniperl \"\$$@\""     >>$(@D)/Cross/miniperl
> -	chmod +x $(@D)/Cross/miniperl
> -	PERL_MM_OPT="PERL=$(@D)/Cross/miniperl" \
> -		$(MAKE) -C $(@D) all
> +	PERL5LIB=$(@D)/dist/base/lib $(MAKE1) -C $(@D) perl modules
>   endef
>   
>   define PERL_INSTALL_STAGING_CMDS
> -	$(MAKE) INSTALL_DEPENDENCE= \
> -		INSTALLFLAGS= \
> -		DESTDIR="$(STAGING_DIR)" \
> -		-C $(@D) install.perl
> +	PERL5LIB=$(@D)/dist/base/lib $(MAKE1) -C $(@D) DESTDIR="$(STAGING_DIR)" install.perl
>   endef
>   
> -PERL_RUN_PERL = $(QEMU_USER) $(@D)/perl -Ilib
> -PERL_ARCHNAME = $(shell $(PERL_RUN_PERL) -MConfig -e "print Config->{archname}")
> -PERL_LIB = $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)
> -PERL_ARCHLIB = $(PERL_LIB)/$(PERL_ARCHNAME)
> -PERL_MODS = $(call qstrip,$(BR2_PACKAGE_PERL_MODULES))
> -# Minimal set of modules required for 'perl -V' to work
> -PERL_ARCH_MODS = Config.pm Config_git.pl Config_heavy.pl
> -PERL_BASE_MODS = strict.pm vars.pm warnings.pm warnings/register.pm
> -
> -define PERL_INSTALL_MODULES
> -	for i in $(PERL_ARCH_MODS); do \
> -		$(INSTALL) -m 0644 -D $(@D)/lib/$$i $(PERL_ARCHLIB)/$$i; \
> -	done
> -	for i in $(PERL_BASE_MODS); do \
> -		$(INSTALL) -m 0644 -D $(@D)/lib/$$i $(PERL_LIB)/$$i; \
> -	done
> -	for i in $(PERL_MODS); do \
> -		j=`echo $$i|cut -d : -f 1` ; \
> -		if [ -d $(@D)/lib/$$j ] ; then \
> -			cp -af $(@D)/lib/$$j $(PERL_LIB) ; \
> -		fi ; \
> -		if [ -f $(@D)/lib/$$i ] ; then \
> -			$(INSTALL) -m 0644 -D $(@D)/lib/$$i $(PERL_LIB)/$$i; \
> -		fi ; \
> -	done
> -	# Remove test files
> -	find $(PERL_LIB) -type f -name *.t -exec rm -f {} \;
> -endef
> +PERL_INSTALL_TARGET_GOALS = install.perl
> +ifeq ($(BR2_HAVE_DOCUMENTATION),y)
> +PERL_INSTALL_TARGET_GOALS += install.man
> +endif
> +
>   
> -ifeq ($(BR2_PACKAGE_PERL_CUSTOM_INSTALL),y)
> -define PERL_INSTALL_TARGET_CMDS
> -	$(INSTALL) -m 0755 -D $(@D)/perl $(TARGET_DIR)/usr/bin/perl
> -	$(INSTALL) -m 0755 -D $(@D)/libperl.so $(PERL_ARCHLIB)/CORE/libperl.so
> -	$(PERL_INSTALL_MODULES)
> -endef
> -else
>   define PERL_INSTALL_TARGET_CMDS
> -	$(MAKE) INSTALL_DEPENDENCE= \
> -		INSTALLFLAGS=-p \
> -		DESTDIR="$(TARGET_DIR)" \
> -		-C $(@D) install.perl
> -	rm -f $(PERL_ARCHLIB)/CORE/*.h
> -	find $(PERL_ARCHLIB) -type f -name *.bs -exec rm -f {} \;
> +	PERL5LIB=$(@D)/dist/base/lib $(MAKE1) -C $(@D) DESTDIR="$(TARGET_DIR)" $(PERL_INSTALL_TARGET_GOALS)
>   endef
> -endif
>   
>   define PERL_CLEAN_CMDS
> -	-$(MAKE) -C $(@D) clean
> +	-$(MAKE1) -C $(@D) clean
>   endef
>   
>   $(eval $(generic-package))
Hello,

In the perlcross Makefile, if you change perl5160delta.pod   to 
perl5162delta.pod in three places then you can compile the newest 
perl-5.16.2. Tested for arm, confirmed working.

Regards,

Dan Pattison
Ethertek Circuits
Peter Korsgaard - Nov. 9, 2012, 7:19 a.m.
>>>>> "Arnout" == Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> writes:

Hi,

 Arnout> Peter, if Francois confirms that the perl binary actually runs
 Arnout> and if he has no other concerns, then I'd commit this patch
 Arnout> quickly and wait for the autobuilder fallout.

I completely agree, thanks for doing this!
Alexander Khryukin - Nov. 9, 2012, 8:58 a.m.
2012/11/9 Peter Korsgaard <jacmet@uclibc.org>

> >>>>> "Arnout" == Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> writes:
>
> Hi,
>
>  Arnout> Peter, if Francois confirms that the perl binary actually runs
>  Arnout> and if he has no other concerns, then I'd commit this patch
>  Arnout> quickly and wait for the autobuilder fallout.
>
> I completely agree, thanks for doing this!
>
> --
> Bye, Peter Korsgaard
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>


How about to include perl-cross into buildroot packages?
Arnout Vandecappelle - Nov. 9, 2012, 9:15 a.m.
On 11/09/12 09:58, Alexander Khryukin wrote:
>
>
> 2012/11/9 Peter Korsgaard <jacmet@uclibc.org <mailto:jacmet@uclibc.org>>
>
>     > >>>> "Arnout" == Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be <mailto:arnout@mind.be>> writes:
>
>     Hi,
>
>       Arnout> Peter, if Francois confirms that the perl binary actually runs
>       Arnout> and if he has no other concerns, then I'd commit this patch
>       Arnout> quickly and wait for the autobuilder fallout.
>
>     I completely agree, thanks for doing this!
>
> How about to include perl-cross into buildroot packages?

  Doesn't make sense.  perlcross has to be extracted over the perl source: it
replaces a few configuration scripts and creates a few more.  There is nothing
in there to install on the host or on the target.

  Regards,
  Arnout
Peter Korsgaard - Nov. 9, 2012, 9:15 a.m.
>>>>> "Alexander" == Alexander Khryukin <alexander@mezon.ru> writes:

Hi,

 Alexander> How about to include perl-cross into buildroot packages?

I'm doing a test build right now, and will commit if that works. Perhaps
it isn't perfect yet, but certainly better than all the qemu issues
we're seing right now.
Thomas Petazzoni - Nov. 9, 2012, 9:18 a.m.
On Fri, 09 Nov 2012 10:15:06 +0100, Arnout Vandecappelle wrote:

>   Doesn't make sense.  perlcross has to be extracted over the perl source: it
> replaces a few configuration scripts and creates a few more.  There is nothing
> in there to install on the host or on the target.

First of all, thanks a lot for doing this work.

Do you have details on how perl-cross is maintained with regard to
perl? I.e, is it kept reasonably updated with new perl versions, or is
it a hack that works on a single perl version that will force us to
stay with only this version of perl?

Thanks!

Thomas
Arnout Vandecappelle - Nov. 9, 2012, 9:20 a.m.
On 11/09/12 10:15, Peter Korsgaard wrote:
>>>>>> "Alexander" == Alexander Khryukin<alexander@mezon.ru>  writes:
>
> Hi,
>
>   Alexander>  How about to include perl-cross into buildroot packages?
>
> I'm doing a test build right now, and will commit if that works. Perhaps
> it isn't perfect yet, but certainly better than all the qemu issues
> we're seing right now.

  BTW, please everybody do review this patch even after it's committed - there
could very well be some things that I missed and that can be caught with visual
review.  (Just look at the time that I sent the patch to know why :-)

  Regards,
  Arnout
Arnout Vandecappelle - Nov. 9, 2012, 9:22 a.m.
On 11/09/12 10:18, Thomas Petazzoni wrote:
>
> On Fri, 09 Nov 2012 10:15:06 +0100, Arnout Vandecappelle wrote:
>
>>    Doesn't make sense.  perlcross has to be extracted over the perl source: it
>> replaces a few configuration scripts and creates a few more.  There is nothing
>> in there to install on the host or on the target.
>
> First of all, thanks a lot for doing this work.
>
> Do you have details on how perl-cross is maintained with regard to
> perl? I.e, is it kept reasonably updated with new perl versions, or is
> it a hack that works on a single perl version that will force us to
> stay with only this version of perl?

  There are about 12 versions on the download site, one per major perl.  I guess
it doesn't make much difference which perl patchlevel it is applied to (this one
is actually for perl-5.16.0 but it work fine on our perl-5.16.1).

  Regards,
  Arnout
Peter Korsgaard - Nov. 9, 2012, 9:23 a.m.
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:

Hi,

 Arnout>  BTW, please everybody do review this patch even after it's
 Arnout> committed - there could very well be some things that I missed
 Arnout> and that can be caught with visual review.  (Just look at the
 Arnout> time that I sent the patch to know why :-)

Yeah, I noticed ;) Thanks for doing it.
Peter Korsgaard - Nov. 9, 2012, 9:25 a.m.
>>>>> "Arnout" == Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> writes:

 Arnout> The perlcross project makes it possible to properly cross-compile
 Arnout> perl.  It creates a host-miniperl that is configured for the target
 Arnout> and uses that to cross-compile the perl modules.

Committed, thanks.
Arnout Vandecappelle - Nov. 9, 2012, 9:27 a.m.
On 11/09/12 04:01, Dan Pattison wrote:
> In the perlcross Makefile, if you change perl5160delta.pod   to perl5162delta.pod in three places then you can compile
> the newest perl-5.16.2. Tested for arm, confirmed working.

  Thanks, I'll try that later.

  Regards,
  Arnout

  PS Dan, if you reply to such a long mail, it helps if you strip away some of
the quoted text.  Saves people with simple mail readers a lot of scrolling.
Thomas Petazzoni - Nov. 9, 2012, 10:31 a.m.
Arnout,

On Fri,  9 Nov 2012 02:47:05 +0100, Arnout Vandecappelle
(Essensium/Mind) wrote:

> This is still a bit RFC.  I've tested in on a glibc x86_64, on a
> minimal internal powerpc and a glibc ARM.  I haven't tested with any
> of the autobuilder configurations, but I expect it will at least be
> better than what we get now...
> 
> Francois, can you check if it also runs?  I've only done build tests.
> 
> Peter, if Francois confirms that the perl binary actually runs and if
> he has no other concerns, then I'd commit this patch quickly and wait
> for the autobuilder fallout.

This patch unfortunately breaks the build of cpanminus, which
apparently still requires qemu:

>>> cpanminus 1.5018 Configuring
>>> cpanminus 1.5018 Building
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
>>> cpanminus 1.5018 Installing to target
echo "#!/bin/sh"                                                        > /home/thomas/projets/buildroot/output/build/cpanminus-1.5018/run_perl
echo "PERL5LIB=/home/thomas/projets/buildroot/output/target/usr/lib/perl5/site_perl/5.16.1/:/home/thomas/projets/buildroot/output/target/usr/lib/perl5/site_perl/5.16.1:/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/perl5/5.16.1/:/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/perl5/5.16.1 /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm /home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/bin/perl \"\$@\""    >>/home/thomas/projets/buildroot/output/build/cpanminus-1.5018/run_perl
chmod +x /home/thomas/projets/buildroot/output/build/cpanminus-1.5018/run_perl
PERL5LIB=/home/thomas/projets/buildroot/output/target/usr/lib/perl5/site_perl/5.16.1/:/home/thomas/projets/buildroot/output/target/usr/lib/perl5/site_perl/5.16.1:/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/perl5/5.16.1/:/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/perl5/5.16.1 PERL_MM_OPT="DESTDIR=/home/thomas/projets/buildroot/output/target PERL=/home/thomas/projets/buildroot/output/build/cpanminus-1.5018/run_perl PERL_LIB=/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/perl5/5.16.1 PERL_ARCHLIB=/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/perl5/5.16.1/" PERL_MB_OPT="--destdir /home/thomas/projets/buildroot/output/target" RUN_PERL="/home/thomas/projets/buildroot/output/build/cpanminus-1.5018/run_perl" /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm /home/thomas/projets/buildroot/outpu
 t/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/bin/perl /home/thomas/projets/buildroot/output/build/cpanminus-1.5018/cpanm --perl=/home/thomas/projets/buildroot/output/build/cpanminus-1.5018/run_perl --notest --no-man-pages  Curses::UI
/bin/bash: /home/thomas/projets/buildroot/output/host/usr/bin/qemu-arm: Aucun fichier ou dossier de ce type
make: *** [/home/thomas/projets/buildroot/output/build/cpanminus-1.5018/.stamp_target_installed] Erreur 127

Thomas
Arnout Vandecappelle - Nov. 9, 2012, 10:36 a.m.
On 11/09/12 11:31, Thomas Petazzoni wrote:
> This patch unfortunately breaks the build of cpanminus, which
> apparently still requires qemu:

  Of course, I didn't think of that...  The solution is to install miniperl and
its wrapper in the host directory.

  I'll try to take a look at it later.

  Regards,
  Arnout
Arnout Vandecappelle - Nov. 9, 2012, 6:07 p.m.
On 11/09/12 11:31, Thomas Petazzoni wrote:
> This patch unfortunately breaks the build of cpanminus, which
> apparently still requires qemu:

  Yep, it does require qemu.  To make it work with perlcross, you'd need to
build a host-perl with a few extra modules (to support network downloads) - but
building those modules can't be done with cross-miniperl because it has the
target's settings for which headers etc. exist.  The perlcross docs state:
"And thinking of possible need to install additional modules for hostperl makes
my head spin."

  So instead, I'll make cpanminus depend on host-qemu and try to exclude the
failing architectures.

  The long term solution is probably to replace cpanminus with something
buildroot-friendly.  The cross-build of the downloaded modules is probably
doable with cross-miniperl.

  Regards,
  Arnout
Francois Perrad - Nov. 9, 2012, 9:13 p.m.
2012/11/9 Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>:
> The perlcross project makes it possible to properly cross-compile
> perl.  It creates a host-miniperl that is configured for the target
> and uses that to cross-compile the perl modules.
>
> Unfortunately there are still a few hacks needed to make it work.
> Proper fixes can be developed and upstreamed later.
>
> Since there is no longer a dependency on qemu, it works on all
> architectures again.
>
> Also removed some config options:
> - BR2_PACKAGE_PERL_CUSTOM_INSTALL just allows a selection of modules;
> this can also be encoded by an empty BR2_PACKAGE_PERL_MODULES.
> - BR2_PACKAGE_PERL_DB_FILE and BR2_PACKAGE_PERL_GDBM_FILE can be
> derived automatically from the package configs.
>
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

The 3 following patches are now useless :
   package/perl/perl-configure-qemu.patch
   package/perl/perl-make-ext.patcg
   package/perl/perl-mkppport.patch

Fran├žois

Patch

diff --git a/package/perl/Config.in b/package/perl/Config.in
index 0642deb..b2991b0 100644
--- a/package/perl/Config.in
+++ b/package/perl/Config.in
@@ -1,12 +1,5 @@ 
 config BR2_PACKAGE_PERL
 	bool "perl"
-	depends on !BR2_avr32
-	depends on !BR2_bfin
-	depends on !BR2_sh2
-	depends on !BR2_sh2a
-	depends on !BR2_sh3
-	depends on !BR2_sh3eb
-	depends on !BR2_sh64
 	help
 	  Larry Wall's Practical Extraction and Report Language
 	  An interpreted scripting language, known among some as "Unix's Swiss
@@ -16,35 +9,18 @@  config BR2_PACKAGE_PERL
 
 if BR2_PACKAGE_PERL
 
-config BR2_PACKAGE_PERL_CUSTOM_INSTALL
-	bool "custom install"
-	help
-	  Don't use the full install target
-	  Install only a selection of modules (like microperl).
-
 config BR2_PACKAGE_PERL_MODULES
-	string "additional modules"
-	depends on BR2_PACKAGE_PERL_CUSTOM_INSTALL
+	string "custom module selection"
 	help
-	  List of space-separated perl modules to copy to the rootfs.
-
-	  Examples: constant.pm Getopt/Std.pm Time/Local.pm
+	  List of space-separated perl modules (without .pm) to copy to the
+	  rootfs.
 
-	  Module dependencies are not automatic so check your needs.
+	  Examples: constant Getopt/Std Time/Local
 
-config BR2_PACKAGE_PERL_DB_FILE
-	bool "DB_File"
-	select BR2_PACKAGE_BERKELEYDB
-	help
-	  Build the DB_File module.
+	  Module dependencies on external libraries are not automatic so
+	  check your needs.
 
-config BR2_PACKAGE_PERL_GDBM_FILE
-	bool "GDBM_File"
-	select BR2_PACKAGE_GDBM
-	help
-	  Build the GDBM_File module.
+	  Leave empty for all modules (as far as the external libraries
+	  are available).
 
 endif
-
-comment "perl requires an architecture supported by qemu"
-	depends on BR2_avr32 || BR2_bfin || BR2_sh2 || BR2_sh2a || BR2_sh3 || BR2_sh3eb || BR2_sh64
diff --git a/package/perl/perl.mk b/package/perl/perl.mk
index 81dff04..f3c73dd 100644
--- a/package/perl/perl.mk
+++ b/package/perl/perl.mk
@@ -12,7 +12,26 @@  PERL_LICENSE = Artistic
 PERL_LICENSE_FILES = Artistic
 PERL_INSTALL_STAGING = YES
 
-PERL_DEPENDENCIES = host-qemu
+PERL_CROSS_VERSION = 0.7
+PERL_CROSS_SITE    = http://download.berlios.de/perlcross
+PERL_CROSS_SOURCE  = perl-5.$(PERL_VERSION_MAJOR).0-cross-$(PERL_CROSS_VERSION).tar.gz
+
+# We use the perlcross hack to cross-compile perl. It should
+# be extracted over the perl sources, so we don't define that
+# as a separate package. Instead, it is downloaded and extracted
+# together with perl
+
+define PERL_CROSS_DOWNLOAD
+	$(call DOWNLOAD,$(PERL_CROSS_SITE)/$(PERL_CROSS_SOURCE))
+endef
+PERL_POST_DOWNLOAD_HOOKS += PERL_CROSS_DOWNLOAD
+
+define PERL_CROSS_EXTRACT
+	$(INFLATE$(suffix $(PERL_CROSS_SOURCE))) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \
+	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(TAR_OPTIONS) -
+endef
+PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
+
 ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
     PERL_DEPENDENCIES += berkeleydb
 endif
@@ -20,23 +39,31 @@  ifeq ($(BR2_PACKAGE_GDBM),y)
     PERL_DEPENDENCIES += gdbm
 endif
 
-PERL_CONF_OPT = -des \
-		-Dusecrosscompile \
-		-Dtargetrun=$(QEMU_USER) \
-		-Dqemulib=$(STAGING_DIR) \
-		-Dar="$(TARGET_AR)" \
-		-Dcc="$(TARGET_CC)" \
-		-Dcpp="$(TARGET_CC)" \
-		-Dld="$(TARGET_LD)" \
-		-Dnm="$(TARGET_NM)" \
-		-Dranlib="$(TARGET_RANLIB)" \
-		-Dccflags="$(TARGET_CFLAGS)" \
-		-Dldflags="$(TARGET_LDFLAGS) -lgcc_s -lm" \
-		-Dlddlflags="-shared" \
-		-Dlibc=$(STAGING_DIR)/lib/libc.so \
-		-Duseshrplib \
-		-Dprefix=/usr \
-		-Uoptimize
+# Normally, --mode=cross should automatically do the two steps
+# below, but it doesn't work for some reason.
+PERL_HOST_CONF_OPT = \
+	--mode=buildmini \
+	--target=$(GNU_TARGET_NAME) \
+	--target-arch=$(GNU_TARGET_NAME) \
+	--set-target-name=$(GNU_TARGET_NAME)
+
+# We have to override LD, because an external multilib toolchain ld is not
+# wrapped to provide the required sysroot options.  We also can't use ccache
+# because the configure script doesn't support it.
+PERL_CONF_OPT = \
+	--mode=target \
+	--target=$(GNU_TARGET_NAME) \
+	--target-tools-prefix=$(TARGET_CROSS) \
+	--prefix=/usr \
+	-Dld="$(TARGET_CC_NOCCACHE)" \
+	-A ccflags="$(TARGET_CFLAGS)" \
+	-A ldflags="$(TARGET_LDFLAGS) -lm" \
+	-A mydomain="" \
+	-A myhostname="$(BR2_TARGET_GENERIC_HOSTNAME)" \
+	-A myuname="Buildroot $(BR2_VERSION_FULL)" \
+	-A osname=linux \
+	-A osvers=$(LINUX_VERSION) \
+	-A perlamdin=root
 
 ifeq ($(shell expr $(PERL_VERSION_MAJOR) % 2), 1)
     PERL_CONF_OPT += -Dusedevel
@@ -46,93 +73,39 @@  ifneq ($(BR2_LARGEFILE),y)
     PERL_CONF_OPT += -Uuselargefiles
 endif
 
+PERL_MODULES = $(call qstrip,$(BR2_PACKAGE_PERL_MODULES))
+ifneq ($(PERL_MODULES),)
+PERL_CONF_OPT += --only-mod=$(subst $(space),$(comma),$(PERL_MODULES))
+endif
+
 define PERL_CONFIGURE_CMDS
-	rm -f $(@D)/config.sh
-	(cd $(@D); ./Configure $(PERL_CONF_OPT))
-	echo "# patched values"                                 >>$(@D)/config.sh
-	$(SED) '/^myarchname=/d' \
-		-e '/^mydomain=/d' \
-		-e '/^myhostname=/d' \
-		-e '/^myuname=/d' \
-		-e '/^osname=/d' \
-		-e '/^osvers=/d' \
-		-e '/^perladmin=/d' \
-		$(@D)/config.sh
-	echo "myarchname='$(GNU_TARGET_NAME)'"                  >>$(@D)/config.sh
-	echo "mydomain=''"                                      >>$(@D)/config.sh
-	echo "myhostname='$(BR2_TARGET_GENERIC_HOSTNAME)'"      >>$(@D)/config.sh
-	echo "myuname='Buildroot $(BR2_VERSION_FULL)'"          >>$(@D)/config.sh
-	echo "osname='linux'"                                   >>$(@D)/config.sh
-	echo "osvers='$(BR2_LINUX_KERNEL_VERSION)'"             >>$(@D)/config.sh
-	echo "perladmin='root'"                                 >>$(@D)/config.sh
-	(cd $(@D); ./Configure -S)
-	cp $(@D)/config.h $(@D)/xconfig.h
+	(cd $(@D); HOSTCC='$(HOSTCC_NOCACHE)' ./configure $(PERL_HOST_CONF_OPT))
+	(cd $(@D); ./configure $(PERL_CONF_OPT))
 	$(SED) 's/UNKNOWN-/Buildroot $(BR2_VERSION_FULL) /' $(@D)/patchlevel.h
 endef
 
+# perlcross's miniperl_top forgets base, which is required by mktables.
+# Instead of patching, it's easier to just set PERL5LIB
 define PERL_BUILD_CMDS
-	echo "#!/bin/sh"                                > $(@D)/Cross/miniperl
-	echo "$(QEMU_USER) $(@D)/miniperl \"\$$@\""     >>$(@D)/Cross/miniperl
-	chmod +x $(@D)/Cross/miniperl
-	PERL_MM_OPT="PERL=$(@D)/Cross/miniperl" \
-		$(MAKE) -C $(@D) all
+	PERL5LIB=$(@D)/dist/base/lib $(MAKE1) -C $(@D) perl modules
 endef
 
 define PERL_INSTALL_STAGING_CMDS
-	$(MAKE) INSTALL_DEPENDENCE= \
-		INSTALLFLAGS= \
-		DESTDIR="$(STAGING_DIR)" \
-		-C $(@D) install.perl
+	PERL5LIB=$(@D)/dist/base/lib $(MAKE1) -C $(@D) DESTDIR="$(STAGING_DIR)" install.perl
 endef
 
-PERL_RUN_PERL = $(QEMU_USER) $(@D)/perl -Ilib
-PERL_ARCHNAME = $(shell $(PERL_RUN_PERL) -MConfig -e "print Config->{archname}")
-PERL_LIB = $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)
-PERL_ARCHLIB = $(PERL_LIB)/$(PERL_ARCHNAME)
-PERL_MODS = $(call qstrip,$(BR2_PACKAGE_PERL_MODULES))
-# Minimal set of modules required for 'perl -V' to work
-PERL_ARCH_MODS = Config.pm Config_git.pl Config_heavy.pl
-PERL_BASE_MODS = strict.pm vars.pm warnings.pm warnings/register.pm
-
-define PERL_INSTALL_MODULES
-	for i in $(PERL_ARCH_MODS); do \
-		$(INSTALL) -m 0644 -D $(@D)/lib/$$i $(PERL_ARCHLIB)/$$i; \
-	done
-	for i in $(PERL_BASE_MODS); do \
-		$(INSTALL) -m 0644 -D $(@D)/lib/$$i $(PERL_LIB)/$$i; \
-	done
-	for i in $(PERL_MODS); do \
-		j=`echo $$i|cut -d : -f 1` ; \
-		if [ -d $(@D)/lib/$$j ] ; then \
-			cp -af $(@D)/lib/$$j $(PERL_LIB) ; \
-		fi ; \
-		if [ -f $(@D)/lib/$$i ] ; then \
-			$(INSTALL) -m 0644 -D $(@D)/lib/$$i $(PERL_LIB)/$$i; \
-		fi ; \
-	done
-	# Remove test files
-	find $(PERL_LIB) -type f -name *.t -exec rm -f {} \;
-endef
+PERL_INSTALL_TARGET_GOALS = install.perl
+ifeq ($(BR2_HAVE_DOCUMENTATION),y)
+PERL_INSTALL_TARGET_GOALS += install.man
+endif
+
 
-ifeq ($(BR2_PACKAGE_PERL_CUSTOM_INSTALL),y)
-define PERL_INSTALL_TARGET_CMDS
-	$(INSTALL) -m 0755 -D $(@D)/perl $(TARGET_DIR)/usr/bin/perl
-	$(INSTALL) -m 0755 -D $(@D)/libperl.so $(PERL_ARCHLIB)/CORE/libperl.so
-	$(PERL_INSTALL_MODULES)
-endef
-else
 define PERL_INSTALL_TARGET_CMDS
-	$(MAKE) INSTALL_DEPENDENCE= \
-		INSTALLFLAGS=-p \
-		DESTDIR="$(TARGET_DIR)" \
-		-C $(@D) install.perl
-	rm -f $(PERL_ARCHLIB)/CORE/*.h
-	find $(PERL_ARCHLIB) -type f -name *.bs -exec rm -f {} \;
+	PERL5LIB=$(@D)/dist/base/lib $(MAKE1) -C $(@D) DESTDIR="$(TARGET_DIR)" $(PERL_INSTALL_TARGET_GOALS)
 endef
-endif
 
 define PERL_CLEAN_CMDS
-	-$(MAKE) -C $(@D) clean
+	-$(MAKE1) -C $(@D) clean
 endef
 
 $(eval $(generic-package))