From: Carsten Schoenert <c.schoenert@t-online.de>
Date: Sat, 5 Oct 2019 19:23:45 +0200
Subject: Don't use LLVM internal assembler on armhf

Avoid the usage of LLVM own assembler implementation on specific parts
as the assembler isn't build with NEON support.

Author: Olivier Tilloy <olivier.tilloy@canonical.com>
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1561819
---
 build/moz.configure/toolchain.configure | 6 ++++--
 gfx/ycbcr/moz.build                     | 3 +++
 media/libjpeg/moz.build                 | 4 ++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
index f7cdd41..a2464e0 100755
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -2192,9 +2192,9 @@ def select_linker(
 set_config("LINKER_KIND", select_linker.KIND)
 
 
-@depends_if(select_linker, target, macos_sdk, sysroot_path, multiarch_dir)
+@depends_if(select_linker, target, macos_sdk, sysroot_path, multiarch_dir, host)
 @imports("os")
-def linker_ldflags(linker, target, macos_sdk, sysroot_path, multiarch_dir):
+def linker_ldflags(linker, target, macos_sdk, sysroot_path, multiarch_dir, host):
     flags = list((linker and linker.LINKER_FLAG) or [])
     if target.kernel == "Darwin":
         if linker and linker.KIND == "ld64":
@@ -2210,6 +2210,8 @@ def linker_ldflags(linker, target, macos_sdk, sysroot_path, multiarch_dir):
                 # Non-Debian-patched binutils linkers (both BFD and gold) don't lookup
                 # in multi-arch directories.
                 flags.append("-Wl,-rpath-link,%s" % multiarch_lib_dir)
+    elif host.cpu == 'arm':
+        flags.append('-Wl,--no-keep-memory')
     return flags
 
 
diff --git a/gfx/ycbcr/moz.build b/gfx/ycbcr/moz.build
index c643fba..59a7eab 100644
--- a/gfx/ycbcr/moz.build
+++ b/gfx/ycbcr/moz.build
@@ -60,6 +60,9 @@ if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['HAVE_ARM_NEON']:
     SOURCES += [
         'yuv_convert_arm.cpp',
     ]
+    # The integrated assembler fails to build yuv_convert_arm.cpp because it doesn't have NEON
+    if CONFIG['CC_TYPE'] == 'clang':
+        CXXFLAGS += ['-fno-integrated-as']
 
 LOCAL_INCLUDES += ['/media/libyuv/libyuv/include']
 
diff --git a/media/libjpeg/moz.build b/media/libjpeg/moz.build
index 879c090..6c07558 100644
--- a/media/libjpeg/moz.build
+++ b/media/libjpeg/moz.build
@@ -219,6 +219,10 @@ if CONFIG['CPU_ARCH'] == 'x86_64':
     ASFLAGS += ['-I%s/media/libjpeg/simd/nasm/' % TOPSRCDIR]
     ASFLAGS += ['-I%s/media/libjpeg/simd/x86_64/' % TOPSRCDIR]
 
+# The integrated assembler fails to build simd/arm/jsimd_neon.S because it doesn't have NEON
+if CONFIG['CC_TYPE'] == 'clang' and CONFIG['CPU_ARCH'] == 'arm':
+    ASFLAGS += ['-fno-integrated-as']
+
 # We allow warnings for third-party code that can be updated from upstream.
 AllowCompilerWarnings()
 
