imported patch dav1d-win-arm64 draft
authorAlex Chronopoulos <achronop@gmail.com>
Mon, 01 Apr 2019 12:53:02 +0300
changeset 1942909 15461a18a2fb4ce7cfcd4bafa413850fa6538a8c
parent 1942908 3306ffc498e745d28db2ebde7d658ce96a3aa565
child 1942910 1e528a7a82e40868c5f4e71dc0f65f3a57a268a9
push id346652
push usercholler@mozilla.com
push dateMon, 01 Apr 2019 12:17:31 +0000
treeherdertry@1e528a7a82e4 [default view] [failures only]
milestone68.0a1
imported patch dav1d-win-arm64
browser/config/mozconfigs/linux64-aarch64/common-opt
media/libdav1d/asm/moz.build
media/libdav1d/config.h
media/libdav1d/moz.build
toolkit/moz.configure
--- a/browser/config/mozconfigs/linux64-aarch64/common-opt
+++ b/browser/config/mozconfigs/linux64-aarch64/common-opt
@@ -7,16 +7,18 @@ ac_add_options --with-google-location-se
 ac_add_options --with-google-safebrowsing-api-keyfile=/builds/sb-gapi.data
 ac_add_options --with-mozilla-api-keyfile=/builds/mozilla-desktop-geoloc-api.key
 
 . $topsrcdir/build/unix/mozconfig.linux
 
 unset NASM
 ac_add_options --target=aarch64
 
+export AS="${topsrcdir}/binutils/aarch64-unknown-linux-gnu/bin/as"
+
 # Needed to enable breakpad in application.ini
 export MOZILLA_OFFICIAL=1
 
 export MOZ_TELEMETRY_REPORTING=1
 
 # Package js shell.
 export MOZ_PACKAGE_JSSHELL=1
 
--- a/media/libdav1d/asm/moz.build
+++ b/media/libdav1d/asm/moz.build
@@ -50,16 +50,21 @@ 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]
+    if CONFIG['CC_TYPE'] == 'clang':
+        ASFLAGS += ['-no-integrated-as']
 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
 
@@ -138,30 +143,21 @@ 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',
         '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
     ]
 
@@ -182,18 +178,26 @@ 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/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
 
 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,22 @@
 
 // Enable asm
 #if defined(MOZ_DAV1D_ASM)
 #  define HAVE_ASM 1
 #else
 #  define HAVE_ASM 0
 #endif
 
+#if ARCH_AARCH64 == 1
+#define HAVE_AS_FUNC 1
+#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,17 +46,17 @@ 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':
+    elif CONFIG['CPU_ARCH'] in ('x86_64' 'aarch64'):
         # The default stack alignment in x86_64 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.')
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -438,17 +438,19 @@ 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 target.os != 'Android' and target.cpu == 'aarch64':
+        return True
+    elif 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
 
 
 set_config('MOZ_DAV1D_ASM', dav1d_asm)
 set_define('MOZ_DAV1D_ASM', dav1d_asm)