Bug 1540124 - Enable aarch64 assembly builds for libdav1d. r=dminor
authorAlex Chronopoulos <achronop@gmail.com>
Wed, 08 May 2019 15:59:15 +0000
changeset 531902 c49518b4191c5985f6bfb21fab850c3b73313234
parent 531901 f6b5ab8f054ad48b1826c5af211a1a6c0bb214bb
child 531903 3429489885f855dc1658504c7d3b91de52446e3f
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1540124
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1540124 - Enable aarch64 assembly builds for libdav1d. r=dminor Differential Revision: https://phabricator.services.mozilla.com/D30185
media/libdav1d/asm/moz.build
media/libdav1d/config.h
media/libdav1d/moz.build
toolkit/moz.configure
--- a/media/libdav1d/asm/moz.build
+++ b/media/libdav1d/asm/moz.build
@@ -50,16 +50,19 @@ elif CONFIG['CPU_ARCH'] == 'x86_64':
     elif CONFIG['OS_TARGET'] == 'WINNT':
         ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/win/' % TOPSRCDIR]
     elif CONFIG['OS_TARGET'] == 'Android':
         error('Platform %s is not expected' % CONFIG['OS_TARGET'])
     else:
         # The rest of the platforms are all Linux flavors
         # Linux,OpenBSD,NetBSD,FreeBSD,DragonFly,SunOS
         ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/linux/' % TOPSRCDIR]
+elif CONFIG['CPU_ARCH'] == 'aarch64':
+    stack_alignment = 16
+    ASFLAGS += ['-I%s/dist/include/dav1d/' % TOPOBJDIR]
 else:
     error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])
 
 # Set the macro here instead of config.h
 if stack_alignment == 0:
     error('Stack alignment cannot be zero.')
 DEFINES['STACK_ALIGNMENT'] = stack_alignment
 
@@ -139,30 +142,22 @@ elif CONFIG['CPU_ARCH'] == 'arm' or CONF
     ]
     EXPORTS += [
         '../../../third_party/dav1d/src/arm/cpu.h',
     ]
 
     # BITDEPTH c file
     relative_path = '../../../third_party/dav1d/src/arm/'
     bitdepth_basenames = [
+        'cdef_init_tmpl.c',
+        'loopfilter_init_tmpl.c',
         'looprestoration_init_tmpl.c',
         'mc_init_tmpl.c',
     ]
 
-    if CONFIG['CPU_ARCH'] == 'aarch64':
-        bitdepth_basenames += [
-            '64/looprestoration.',
-            '64/mc.S',
-        ]
-    elif CONFIG['CPU_ARCH'] == 'arm':
-        bitdepth_basenames += [
-            '32/mc.S',
-        ]
-
     GENERATED_FILES += [
         '16bd_%s' % p for p in bitdepth_basenames
     ]
 
     SOURCES += [
         '!16bd_%s' % p for p in bitdepth_basenames
     ]
 
@@ -183,18 +178,29 @@ elif CONFIG['CPU_ARCH'] == 'arm' or CONF
     for f in bitdepth_basenames:
         a = GENERATED_FILES['8bd_%s' % f]
         a.script = '../generate_source.py:add_define'
         a.inputs = [relative_path + f]
         a.flags = ['BITDEPTH', '8']
 
     # BITDEPTH .S files
     if CONFIG['CPU_ARCH'] == 'aarch64':
-        SOURCES += ['../../../third_party/dav1d/src/arm/64/mc.S']
+        SOURCES += [
+            '../../../third_party/dav1d/src/arm/64/cdef.S',
+            '../../../third_party/dav1d/src/arm/64/loopfilter.S',
+            '../../../third_party/dav1d/src/arm/64/looprestoration.S',
+            '../../../third_party/dav1d/src/arm/64/mc.S',
+        ]
     elif CONFIG['CPU_ARCH'] == 'arm':
-        SOURCES += ['../../../third_party/dav1d/src/arm/32/mc.S']
+        SOURCES += [
+            '../../../third_party/dav1d/src/arm/32/looprestoration.S',
+            '../../../third_party/dav1d/src/arm/32/mc.S',
+        ]
 
-USE_NASM = True
+if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
+    USE_NASM = True
+elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['OS_TARGET'] == 'WINNT':
+    USE_INTEGRATED_CLANGCL_AS = True
 
 FINAL_LIBRARY = 'gkmedias'
 
 # We allow warnings for third-party code that can be updated from upstream.
 AllowCompilerWarnings()
--- a/media/libdav1d/config.h
+++ b/media/libdav1d/config.h
@@ -37,16 +37,24 @@
 
 // Enable asm
 #if defined(MOZ_DAV1D_ASM)
 #  define HAVE_ASM 1
 #else
 #  define HAVE_ASM 0
 #endif
 
+#if ARCH_AARCH64 == 1
+// Those values are copied from the auto generated
+// config file produced by stand alone dav1d build.
+#define HAVE_AS_FUNC 0
+#define HAVE_GETAUXVAL 1
+#define PIC 3
+#endif
+
 // The following macros are defined from autoconf
 // according to the system configuration.
 // (HAVE_MEMALIGN | HAVE_ALIGNED_MALLOC | HAVE_POSIX_MEMALIGN)
 // HAVE_UNISTD_H
 
 // Important when asm is enabled
 #if defined(__APPLE__) || (ARCH_x86_32 == 1 && defined(_WIN32))
 #  define PREFIX 1
--- a/media/libdav1d/moz.build
+++ b/media/libdav1d/moz.build
@@ -46,18 +46,18 @@ if CONFIG['MOZ_DAV1D_ASM']:
             if CONFIG['CC_TYPE'] == 'clang':
                 CFLAGS += ['-mstack-alignment=16']
                 for ep in entrypoint_source_files:
                     SOURCES[ep].flags += ['-mstackrealign']
             elif CONFIG['CC_TYPE'] == 'gcc':
                 CFLAGS += ['-mpreferred-stack-boundary=4']
                 for ep in entrypoint_source_files:
                     SOURCES[ep].flags += ['-mincoming-stack-boundary=2']
-    elif CONFIG['CPU_ARCH'] == 'x86_64':
-        # The default stack alignment in x86_64 is 16 bytes.
+    elif CONFIG['CPU_ARCH'] in ('x86_64', 'aarch64'):
+        # The default stack alignment is 16 bytes.
         stack_alignment = 16
     else:
         error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])
 
     # Set the macro here instead of config.h
     if stack_alignment == 0:
         error('Stack alignment cannot be zero.')
     DEFINES['STACK_ALIGNMENT'] = stack_alignment
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -438,21 +438,24 @@ option('--disable-av1',
 
 @depends('--enable-av1')
 def av1(value):
     if value:
         return True
 
 @depends(target, nasm_version, when=av1 & compile_environment)
 def dav1d_asm(target, nasm_version):
-    if target.os != 'Android' and target.cpu in ('x86', 'x86_64'):
-        if nasm_version < '2.13':
-            die('nasm 2.13 or greater is required for AV1 support. '
-                'Either install nasm or add --disable-av1 to your configure options.')
-        return True
+    if target.os != 'Android':
+        if target.cpu == 'aarch64':
+            return True
+        elif target.cpu in ('x86', 'x86_64'):
+            if nasm_version < '2.13':
+                die('nasm 2.13 or greater is required for AV1 support. '
+                    'Either install nasm or add --disable-av1 to your configure options.')
+            return True
 
 
 set_config('MOZ_DAV1D_ASM', dav1d_asm)
 set_define('MOZ_DAV1D_ASM', dav1d_asm)
 set_config('MOZ_AV1', av1)
 set_define('MOZ_AV1', av1)
 
 # Built-in fragmented MP4 support.