From 66b120079fb21ed38cab0900c63360b0a7853eaa Mon Sep 17 00:00:00 2001
From: Christopher Larson <chris_larson@mentor.com>
Date: Tue, 13 Dec 2016 14:22:32 -0700
Subject: [PATCH] Fix X32 build by disabling asm

This applies gentoo's x32 patch, adjusted slightly, which disables asm support
for x32 as well as correcting -m.

Debian has a different patch which does the same, and there's a superior yet
out of date patch series on the x264 list which keeps asm support enabled, but
doesn't successfully build at this time, and my assembly is very rusty.

Upstream-Status: Pending
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 configure | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/configure
+++ b/configure
@@ -771,7 +771,13 @@ case $host_cpu in
         AS_EXT=".asm"
         ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -I\$(SRCPATH)/common/x86/"
         stack_alignment=16
-        [ $compiler = GNU ] && CFLAGS="-m64 $CFLAGS" && LDFLAGS="-m64 $LDFLAGS"
+        if [ $compiler = GNU ]; then
+            if cpp_check "" "" "__ILP32__" ; then
+                CFLAGS="-mx32 $CFLAGS" && LDFLAGS="-mx32 $LDFLAGS"
+            else
+                CFLAGS="-m64 $CFLAGS" && LDFLAGS="-m64 $LDFLAGS"
+            fi
+        fi
         if [ "$SYS" = MACOSX ]; then
             ASFLAGS="$ASFLAGS -f macho64 -DPREFIX"
             if cc_check '' "-arch x86_64"; then
@@ -790,7 +796,11 @@ case $host_cpu in
                 RCFLAGS="--target=pe-x86-64 $RCFLAGS"
             fi
         else
-            ASFLAGS="$ASFLAGS -f elf64"
+            if cpp_check "" "" "__ILP32__" ; then
+                asm=no
+            else
+                ASFLAGS="$ASFLAGS -f elf64"
+            fi
         fi
         ;;
     powerpc*)
