diff mbox

please add NEON pass to libvpx build

Message ID 20120220220216.GA32188@afflict.kos.to
State Accepted
Headers show

Commit Message

Riku Voipio Feb. 20, 2012, 10:02 p.m. UTC
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 mbox

Patch

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