From patchwork Fri Nov 9 01:47:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 197907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id B75A52C00F8 for ; Fri, 9 Nov 2012 12:47:31 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BB78930D53; Fri, 9 Nov 2012 01:47:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mHhuizWejeKC; Fri, 9 Nov 2012 01:47:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 3BC6B30E6A; Fri, 9 Nov 2012 01:47:25 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id BBC048F74A for ; Fri, 9 Nov 2012 01:47:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B18ED8D084 for ; Fri, 9 Nov 2012 01:47:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uAWq0sjT1g5R for ; Fri, 9 Nov 2012 01:47:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from viper.mind.be (132.79-246-81.adsl-static.isp.belgacom.be [81.246.79.132]) by whitealder.osuosl.org (Postfix) with ESMTPS id E00D58D087 for ; Fri, 9 Nov 2012 01:47:19 +0000 (UTC) Received: from [172.16.2.6] (helo=vandecaa-laptop) by viper.mind.be with esmtp (Exim 4.69) (envelope-from ) id 1TWdgb-0007EU-9y; Fri, 09 Nov 2012 02:47:16 +0100 Received: from arnout by vandecaa-laptop with local (Exim 4.80) (envelope-from ) id 1TWdgY-0002pQ-V8; Fri, 09 Nov 2012 02:47:07 +0100 From: "Arnout Vandecappelle (Essensium/Mind)" To: buildroot@busybox.net Date: Fri, 9 Nov 2012 02:47:05 +0100 Message-Id: <1352425626-10628-1-git-send-email-arnout@mind.be> X-Mailer: git-send-email 1.7.10.4 Subject: [Buildroot] [PATCH] perl: build with perlcross instead of qemu X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net 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) --- 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))