[vlc-commits] contrib: vpx: Backport patches for windows on arm with mingw

Martin Storsjö git at videolan.org
Fri Nov 23 16:10:59 CET 2018


vlc/vlc-3.0 | branch: master | Martin Storsjö <martin at martin.st> | Fri Apr 20 10:59:35 2018 +0300| [75e620af18361d1f4b00820504e0403ab4a5d48a] | committer: Hugo Beauzée-Luyssen

contrib: vpx: Backport patches for windows on arm with mingw

These patches are from the latest git master of libvpx (past the 1.7.0
release).

This also tries to configure with arm64 optimizations on other platforms
as well, which hadn't been hooked up before.

(cherry picked from commit e14d19fe8620e6399066b613cfd7ec1d389a2f7d)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=75e620af18361d1f4b00820504e0403ab4a5d48a
---

 .../src/vpx/0001-ads2gas-Add-a-noelf-option.patch  | 80 ++++++++++++++++++++++
 ...2-configure-Add-an-armv7-win32-gcc-target.patch | 66 ++++++++++++++++++
 ...3-configure-Add-an-arm64-win64-gcc-target.patch | 29 ++++++++
 contrib/src/vpx/rules.mak                          | 16 ++++-
 4 files changed, 189 insertions(+), 2 deletions(-)

diff --git a/contrib/src/vpx/0001-ads2gas-Add-a-noelf-option.patch b/contrib/src/vpx/0001-ads2gas-Add-a-noelf-option.patch
new file mode 100644
index 0000000000..a7275238b9
--- /dev/null
+++ b/contrib/src/vpx/0001-ads2gas-Add-a-noelf-option.patch
@@ -0,0 +1,80 @@
+From dcddec1e8b994e7bca90779a10e6654491e98fb8 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin at martin.st>
+Date: Wed, 21 Mar 2018 14:09:04 +0200
+Subject: [PATCH 1/3] ads2gas: Add a -noelf option
+
+This allows skipping elf specific features from the output.
+
+Change-Id: I739299ba41286ca10415e056b4ffd561be5e0350
+---
+ build/make/ads2gas.pl | 25 ++++++++++++++++++-------
+ 1 file changed, 18 insertions(+), 7 deletions(-)
+
+diff --git a/build/make/ads2gas.pl b/build/make/ads2gas.pl
+index 029cc4a..91609da 100755
+--- a/build/make/ads2gas.pl
++++ b/build/make/ads2gas.pl
+@@ -23,9 +23,11 @@ use lib $FindBin::Bin;
+ use thumb;
+ 
+ my $thumb = 0;
++my $elf = 1;
+ 
+ foreach my $arg (@ARGV) {
+     $thumb = 1 if ($arg eq "-thumb");
++    $elf = 0 if ($arg eq "-noelf");
+ }
+ 
+ print "@ This file was created from a .asm file\n";
+@@ -140,7 +142,11 @@ while (<STDIN>)
+ 
+     # Make function visible to linker, and make additional symbol with
+     # prepended underscore
+-    s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/;
++    if ($elf) {
++        s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/;
++    } else {
++        s/EXPORT\s+\|([\$\w]*)\|/.global $1/;
++    }
+     s/IMPORT\s+\|([\$\w]*)\|/.global $1/;
+ 
+     s/EXPORT\s+([\$\w]*)/.global $1/;
+@@ -181,11 +187,16 @@ while (<STDIN>)
+     # eabi_attributes numerical equivalents can be found in the
+     # "ARM IHI 0045C" document.
+ 
+-    # REQUIRE8 Stack is required to be 8-byte aligned
+-    s/\sREQUIRE8/.eabi_attribute 24, 1 \@Tag_ABI_align_needed/g;
++    if ($elf) {
++        # REQUIRE8 Stack is required to be 8-byte aligned
++        s/\sREQUIRE8/.eabi_attribute 24, 1 \@Tag_ABI_align_needed/g;
+ 
+-    # PRESERVE8 Stack 8-byte align is preserved
+-    s/\sPRESERVE8/.eabi_attribute 25, 1 \@Tag_ABI_align_preserved/g;
++        # PRESERVE8 Stack 8-byte align is preserved
++        s/\sPRESERVE8/.eabi_attribute 25, 1 \@Tag_ABI_align_preserved/g;
++    } else {
++        s/\sREQUIRE8//;
++        s/\sPRESERVE8//;
++    }
+ 
+     # Use PROC and ENDP to give the symbols a .size directive.
+     # This makes them show up properly in debugging tools like gdb and valgrind.
+@@ -202,7 +213,7 @@ while (<STDIN>)
+         my $proc;
+         s/\bENDP\b/@ $&/;
+         $proc = pop(@proc_stack);
+-        $_ = "\t.size $proc, .-$proc".$_ if ($proc);
++        $_ = "\t.size $proc, .-$proc".$_ if ($proc and $elf);
+     }
+ 
+     # EQU directive
+@@ -225,4 +236,4 @@ while (<STDIN>)
+ }
+ 
+ # Mark that this object doesn't need an executable stack.
+-printf ("\t.section\t.note.GNU-stack,\"\",\%\%progbits\n");
++printf ("\t.section\t.note.GNU-stack,\"\",\%\%progbits\n") if $elf;
+-- 
+2.7.4
+
diff --git a/contrib/src/vpx/0002-configure-Add-an-armv7-win32-gcc-target.patch b/contrib/src/vpx/0002-configure-Add-an-armv7-win32-gcc-target.patch
new file mode 100644
index 0000000000..43c763f7ce
--- /dev/null
+++ b/contrib/src/vpx/0002-configure-Add-an-armv7-win32-gcc-target.patch
@@ -0,0 +1,66 @@
+From 6c6085eb50c2a1c44151a9a1f96c925cfe5e7e34 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin at martin.st>
+Date: Wed, 21 Mar 2018 14:12:04 +0200
+Subject: [PATCH 2/3] configure: Add an armv7-win32-gcc target
+
+This builds for windows on arm, with llvm-mingw. The target triplet
+is named -gcc since that's how similar existing targets are named,
+even though it technically runs clang (via frontends named
+"$CROSS-gcc").
+
+Assemble using $CC -c since there's no standalone assembler
+available (except perhaps llvm-mc).
+
+Change-Id: I2c9a319730afef73f811bad79f488dcdc244ab0d
+---
+ build/make/configure.sh | 14 +++++++++++++-
+ configure               |  1 +
+ 2 files changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/build/make/configure.sh b/build/make/configure.sh
+index 007e020..9aa4f1c 100644
+--- a/build/make/configure.sh
++++ b/build/make/configure.sh
+@@ -891,7 +891,6 @@ process_common_toolchain() {
+           setup_gnu_toolchain
+           arch_int=${tgt_isa##armv}
+           arch_int=${arch_int%%te}
+-          check_add_asflags --defsym ARCHITECTURE=${arch_int}
+           tune_cflags="-mtune="
+           if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
+             if [ -z "${float_abi}" ]; then
+@@ -918,6 +917,19 @@ EOF
+ 
+           enabled debug && add_asflags -g
+           asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
++
++          case ${tgt_os} in
++            win*)
++              asm_conversion_cmd="$asm_conversion_cmd -noelf"
++              AS="$CC -c"
++              EXE_SFX=.exe
++              enable_feature thumb
++              ;;
++            *)
++              check_add_asflags --defsym ARCHITECTURE=${arch_int}
++              ;;
++          esac
++
+           if enabled thumb; then
+             asm_conversion_cmd="$asm_conversion_cmd -thumb"
+             check_add_cflags -mthumb
+diff --git a/configure b/configure
+index fb732ac..16f301e 100755
+--- a/configure
++++ b/configure
+@@ -106,6 +106,7 @@ all_platforms="${all_platforms} armv7-darwin-gcc"    #neon Cortex-A8
+ all_platforms="${all_platforms} armv7-linux-rvct"    #neon Cortex-A8
+ all_platforms="${all_platforms} armv7-linux-gcc"     #neon Cortex-A8
+ all_platforms="${all_platforms} armv7-none-rvct"     #neon Cortex-A8
++all_platforms="${all_platforms} armv7-win32-gcc"
+ all_platforms="${all_platforms} armv7-win32-vs11"
+ all_platforms="${all_platforms} armv7-win32-vs12"
+ all_platforms="${all_platforms} armv7-win32-vs14"
+-- 
+2.7.4
+
diff --git a/contrib/src/vpx/0003-configure-Add-an-arm64-win64-gcc-target.patch b/contrib/src/vpx/0003-configure-Add-an-arm64-win64-gcc-target.patch
new file mode 100644
index 0000000000..07051c8b2e
--- /dev/null
+++ b/contrib/src/vpx/0003-configure-Add-an-arm64-win64-gcc-target.patch
@@ -0,0 +1,29 @@
+From 3392bb335ee58bc930da624834c74c1625afbb82 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin at martin.st>
+Date: Wed, 21 Mar 2018 14:15:13 +0200
+Subject: [PATCH 3/3] configure: Add an arm64-win64-gcc target
+
+This configuration doesn't require any extra custom settings, since
+it only uses neon intrinsics that are handled automatically by the
+compiler (no external assembly).
+
+Change-Id: I35415c68f483a430c0672e060a7bbd09a3469512
+---
+ configure | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure b/configure
+index 16f301e..1ba4c48 100755
+--- a/configure
++++ b/configure
+@@ -101,6 +101,7 @@ EOF
+ all_platforms="${all_platforms} arm64-android-gcc"
+ all_platforms="${all_platforms} arm64-darwin-gcc"
+ all_platforms="${all_platforms} arm64-linux-gcc"
++all_platforms="${all_platforms} arm64-win64-gcc"
+ all_platforms="${all_platforms} armv7-android-gcc"   #neon Cortex-A8
+ all_platforms="${all_platforms} armv7-darwin-gcc"    #neon Cortex-A8
+ all_platforms="${all_platforms} armv7-linux-rvct"    #neon Cortex-A8
+-- 
+2.7.4
+
diff --git a/contrib/src/vpx/rules.mak b/contrib/src/vpx/rules.mak
index 05e759c3c4..106288cd90 100644
--- a/contrib/src/vpx/rules.mak
+++ b/contrib/src/vpx/rules.mak
@@ -20,6 +20,9 @@ libvpx: libvpx-$(VPX_VERSION).tar.bz2 .sum-vpx
 ifdef HAVE_ANDROID
 	$(APPLY) $(SRC)/vpx/libvpx-android.patch
 endif
+	$(APPLY) $(SRC)/vpx/0001-ads2gas-Add-a-noelf-option.patch
+	$(APPLY) $(SRC)/vpx/0002-configure-Add-an-armv7-win32-gcc-target.patch
+	$(APPLY) $(SRC)/vpx/0003-configure-Add-an-arm64-win64-gcc-target.patch
 	$(MOVE)
 
 DEPS_vpx =
@@ -39,8 +42,7 @@ VPX_ARCH := armv7s
 else
 VPX_ARCH := armv7
 endif
-else ifndef HAVE_WIN32
-# libvpx doesn't support win32/arm with clang yet
+else
 VPX_ARCH := armv7
 endif
 else ifeq ($(ARCH),i386)
@@ -55,6 +57,8 @@ else ifeq ($(ARCH),sparc)
 VPX_ARCH := sparc
 else ifeq ($(ARCH),x86_64)
 VPX_ARCH := x86_64
+else ifeq ($(ARCH),aarch64)
+VPX_ARCH := arm64
 endif
 
 ifdef HAVE_ANDROID
@@ -100,9 +104,17 @@ VPX_CONF := \
 	--disable-dependency-tracking \
 	--enable-vp9-highbitdepth
 
+ifndef HAVE_WIN32
 ifndef HAVE_IOS
 VPX_CONF += --enable-runtime-cpu-detect
 endif
+else
+# WIN32
+ifeq ($(filter arm aarch64, $(ARCH)),)
+# Only enable runtime cpu detect on architectures other than arm/aarch64
+VPX_CONF += --enable-runtime-cpu-detect
+endif
+endif
 
 ifndef BUILD_ENCODERS
 VPX_CONF += --disable-vp8-encoder --disable-vp9-encoder



More information about the vlc-commits mailing list