From patchwork Mon Feb 20 22:02:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 6844 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CDCDB23ECA for ; Mon, 20 Feb 2012 22:02:20 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6FBB2A184F1 for ; Mon, 20 Feb 2012 22:02:20 +0000 (UTC) Received: by iabz7 with SMTP id z7so11282925iab.11 for ; Mon, 20 Feb 2012 14:02:19 -0800 (PST) Received: from mr.google.com ([10.42.131.129]) by 10.42.131.129 with SMTP id z1mr23663733ics.53.1329775339975 (num_hops = 1); Mon, 20 Feb 2012 14:02:19 -0800 (PST) Received: by 10.42.131.129 with SMTP id z1mr18907747ics.53.1329775339902; Mon, 20 Feb 2012 14:02:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.11.10 with SMTP id r10csp62817ibr; Mon, 20 Feb 2012 14:02:18 -0800 (PST) Received: by 10.229.137.148 with SMTP id w20mr13618548qct.119.1329775338270; Mon, 20 Feb 2012 14:02:18 -0800 (PST) Received: from afflict.kos.to (afflict.kos.to. [92.243.29.197]) by mx.google.com with ESMTPS id w5si8319927qcm.40.2012.02.20.14.02.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Feb 2012 14:02:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of nchip@afflict.kos.to designates 92.243.29.197 as permitted sender) client-ip=92.243.29.197; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of nchip@afflict.kos.to designates 92.243.29.197 as permitted sender) smtp.mail=nchip@afflict.kos.to Received: by afflict.kos.to (Postfix, from userid 1000) id 40E422652D; Mon, 20 Feb 2012 22:02:16 +0000 (UTC) Date: Tue, 21 Feb 2012 00:02:16 +0200 From: Riku Voipio To: submit@bugs.debian.org Cc: patches@linaro.org Subject: please add NEON pass to libvpx build Message-ID: <20120220220216.GA32188@afflict.kos.to> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Gm-Message-State: ALoCoQncX9z4gID4nm5MtVvzwKUcXZEQ5mA0yhVPKPe/THAiIvgatHtHX81Xod2sXICTIxfIyuLv Package: libvpx Version: 1.0.0-1.1 Severity: normal Tags: patch Hi, The following patch adds NEON optimized builds for libvpx on armel and armhf architectures. This patch builds on top of the patch in #643016. List of changes in the patch. debian/patches/fix-armhf-link.patch: patch away setting CROSS to arm-none-linux-gnueabi- if CROSS is not set - fixes native compile of arm assembler code. patch to remove "-mfloat-abi=softfp" hardcoding, toolchain does that automatically. Fixes building armv7 on armhf debian/rules set appropriate flages for arm variants. note the comment on armhf/armv7 hack export BUILD_NEON when building for arm and when use in the build rules to copy the neon libraries to the right place. replace DEB_BUILD_ARCH with DEB_HOST_ARCH. Confusing, but in gnuspeak BUILD is the build machine and HOST is host where the code will run. -part of fixing crosscompiling libvpx remove the broken configure_flags += --host=$(DEB_HOST_GNU_TYPE) and replace it with setting CROSS when crosscompiling. With these changes, libvpx now crosscompiles fine Please ask if any questions left. Riku diff -Nru libvpx-1.0.0/debian/patches/fix-armhf-link.patch libvpx-1.0.0/debian/patches/fix-armhf-link.patch --- libvpx-1.0.0/debian/patches/fix-armhf-link.patch 1970-01-01 02:00:00.000000000 +0200 +++ libvpx-1.0.0/debian/patches/fix-armhf-link.patch 2012-02-20 16:46:19.000000000 +0200 @@ -0,0 +1,23 @@ +Index: libvpx-1.0.0/build/make/configure.sh +=================================================================== +--- libvpx-1.0.0.orig/build/make/configure.sh 2012-02-20 15:33:19.699399094 +0200 ++++ libvpx-1.0.0/build/make/configure.sh 2012-02-20 16:46:12.863199409 +0200 +@@ -680,7 +680,6 @@ + + case ${tgt_cc} in + gcc) +- CROSS=${CROSS:-arm-none-linux-gnueabi-} + link_with_cc=gcc + setup_gnu_toolchain + arch_int=${tgt_isa##armv} +@@ -689,8 +688,8 @@ + tune_cflags="-mtune=" + if enabled armv7 + then +- check_add_cflags -march=armv7-a -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-ftree-vectorize +- check_add_asflags -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-march=armv7-a ++ check_add_cflags -march=armv7-a -mcpu=cortex-a8 -mfpu=neon #-ftree-vectorize ++ check_add_asflags -mcpu=cortex-a8 -mfpu=neon #-march=armv7-a + else + check_add_cflags -march=${tgt_isa} + check_add_asflags -march=${tgt_isa} diff -Nru libvpx-1.0.0/debian/patches/series libvpx-1.0.0/debian/patches/series --- libvpx-1.0.0/debian/patches/series 2012-02-01 10:34:40.000000000 +0200 +++ libvpx-1.0.0/debian/patches/series 2012-02-20 15:33:12.000000000 +0200 @@ -1 +1,2 @@ 01_enable-shared.patch +fix-armhf-link.patch diff -Nru libvpx-1.0.0/debian/rules libvpx-1.0.0/debian/rules --- libvpx-1.0.0/debian/rules 2012-02-20 13:17:07.000000000 +0200 +++ libvpx-1.0.0/debian/rules 2012-02-20 17:16:06.000000000 +0200 @@ -2,7 +2,9 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) -DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) +DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) configure_flags += \ --prefix=/usr \ @@ -11,23 +13,41 @@ --disable-install-bins \ --disable-install-srcs -# TODO: Special cases for ARM? -ifeq ($(DEB_BUILD_ARCH), amd64) +ifeq ($(DEB_HOST_ARCH_CPU),arm) +configure_flags_neon := $(configure_flags) --target=armv7-linux-gcc +BUILD_NEON=Yes +endif + +ifeq ($(DEB_HOST_ARCH), armel) +ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes) +configure_flags += --target=armv6-linux-gcc --enable-small +else +configure_flags += --target=generic-gnu +endif +else +ifeq ($(DEB_HOST_ARCH), armhf) +# now armhf is ARMv7, but ARMv7 in vpx means NEON, which is not mandatory on armhf +# thus we use ARMv6 and -marm (since no thumb2 on ARMv6) to ensure compatability +# with all ARMv7 cores we support. +CFLAGS += -marm +configure_flags += --target=armv6-linux-gcc --enable-small +else +ifeq ($(DEB_HOST_ARCH), amd64) configure_flags += --target=x86_64-linux-gcc else -ifeq ($(DEB_BUILD_ARCH), kfreebsd-amd64) +ifeq ($(DEB_HOST_ARCH), kfreebsd-amd64) configure_flags += --target=x86_64-linux-gcc else -ifeq ($(DEB_BUILD_ARCH), i386) +ifeq ($(DEB_HOST_ARCH), i386) configure_flags += --target=x86-linux-gcc else -ifeq ($(DEB_BUILD_ARCH), kfreebsd-i386) +ifeq ($(DEB_HOST_ARCH), kfreebsd-i386) configure_flags += --target=x86-linux-gcc else -ifeq ($(DEB_BUILD_ARCH), hurd-i386) +ifeq ($(DEB_HOST_ARCH), hurd-i386) configure_flags += --target=x86-linux-gcc else -ifeq ($(DEB_BUILD_ARCH), powerpc) +ifeq ($(DEB_HOST_ARCH), powerpc) configure_flags += --target=ppc32-linux-gcc else configure_flags += --target=generic-gnu @@ -37,9 +57,12 @@ endif endif endif +endif +endif ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) -configure_flags += --host=$(DEB_HOST_GNU_TYPE) +CROSS=$(DEB_HOST_GNU_TYPE)- +export CROSS endif CFLAGS += -Wall -g @@ -60,12 +83,22 @@ CFLAGS="$(CFLAGS)" $(CURDIR)/configure \ $(configure_flags) touch $@ +ifeq ($(BUILD_NEON), Yes) + mkdir -p $(builddir)-neon; \ + cd $(builddir)-neon; \ + CFLAGS="$(CFLAGS)" $(CURDIR)/configure \ + $(configure_flags_neon) + touch $@ +endif build: build-stamp build-stamp: configure-stamp dh_testdir $(MAKE) -C $(builddir) verbose=yes +ifeq ($(BUILD_NEON), Yes) + $(MAKE) -C $(builddir)-neon verbose=yes +endif touch $@ clean: @@ -73,6 +106,7 @@ dh_testroot rm -f *-stamp rm -rf $(builddir) + rm -rf $(builddir)-neon dh_clean install: build-stamp @@ -81,6 +115,9 @@ dh_prep dh_installdirs $(MAKE) -C $(builddir) verbose=yes dist +ifeq ($(BUILD_NEON), Yes) + $(MAKE) -C $(builddir)-neon verbose=yes dist +endif # don't use stripped library... cp -v $(builddir)/libvpx_g.a \ $(builddir)/vpx-vp8-*/lib/libvpx.a @@ -105,6 +142,10 @@ dh_install -s mkdir -p debian/libvpx1/usr/lib/$(DEB_HOST_MULTIARCH) cp -a builddir/vpx-vp8-*/lib/libvpx.so.* debian/libvpx1/usr/lib/$(DEB_HOST_MULTIARCH) +ifeq ($(BUILD_NEON), Yes) + mkdir -p debian/libvpx1/usr/lib/$(DEB_HOST_MULTIARCH)/vfp/neon + cp -a builddir-neon/vpx-vp8-*/lib/libvpx.so.* debian/libvpx1/usr/lib/$(DEB_HOST_MULTIARCH)/vfp/neon +endif mkdir -p debian/libvpx-dev/usr/lib/$(DEB_HOST_MULTIARCH) cp -a builddir/vpx-vp8-*/lib/libvpx.so builddir/vpx-vp8-*/lib/libvpx.a debian/libvpx-dev/usr/lib/$(DEB_HOST_MULTIARCH) dh_installdocs -s -A README AUTHORS