Commit 42916760 authored by Alex Chronopoulos's avatar Alex Chronopoulos
Browse files

Bug 1540124 - Enable aarch64 assembly builds for libdav1d. r=dminor

Differential Revision: https://phabricator.services.mozilla.com/D30185

--HG--
extra : moz-landing-system : lando
parent e74a4352
Loading
Loading
Loading
Loading
+19 −13
Original line number Original line Diff line number Diff line
@@ -55,6 +55,9 @@ elif CONFIG['CPU_ARCH'] == 'x86_64':
        # The rest of the platforms are all Linux flavors
        # The rest of the platforms are all Linux flavors
        # Linux,OpenBSD,NetBSD,FreeBSD,DragonFly,SunOS
        # Linux,OpenBSD,NetBSD,FreeBSD,DragonFly,SunOS
        ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/linux/' % TOPSRCDIR]
        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:
else:
    error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])
    error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])


@@ -144,20 +147,12 @@ elif CONFIG['CPU_ARCH'] == 'arm' or CONFIG['CPU_ARCH'] == 'aarch64':
    # BITDEPTH c file
    # BITDEPTH c file
    relative_path = '../../../third_party/dav1d/src/arm/'
    relative_path = '../../../third_party/dav1d/src/arm/'
    bitdepth_basenames = [
    bitdepth_basenames = [
        'cdef_init_tmpl.c',
        'loopfilter_init_tmpl.c',
        'looprestoration_init_tmpl.c',
        'looprestoration_init_tmpl.c',
        'mc_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 += [
    GENERATED_FILES += [
        '16bd_%s' % p for p in bitdepth_basenames
        '16bd_%s' % p for p in bitdepth_basenames
    ]
    ]
@@ -188,11 +183,22 @@ elif CONFIG['CPU_ARCH'] == 'arm' or CONFIG['CPU_ARCH'] == 'aarch64':


    # BITDEPTH .S files
    # BITDEPTH .S files
    if CONFIG['CPU_ARCH'] == 'aarch64':
    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':
    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',
        ]


if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
    USE_NASM = True
    USE_NASM = True
elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['OS_TARGET'] == 'WINNT':
    USE_INTEGRATED_CLANGCL_AS = True


FINAL_LIBRARY = 'gkmedias'
FINAL_LIBRARY = 'gkmedias'


+8 −0
Original line number Original line Diff line number Diff line
@@ -42,6 +42,14 @@
#  define HAVE_ASM 0
#  define HAVE_ASM 0
#endif
#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
// The following macros are defined from autoconf
// according to the system configuration.
// according to the system configuration.
// (HAVE_MEMALIGN | HAVE_ALIGNED_MALLOC | HAVE_POSIX_MEMALIGN)
// (HAVE_MEMALIGN | HAVE_ALIGNED_MALLOC | HAVE_POSIX_MEMALIGN)
+2 −2
Original line number Original line Diff line number Diff line
@@ -51,8 +51,8 @@ if CONFIG['MOZ_DAV1D_ASM']:
                CFLAGS += ['-mpreferred-stack-boundary=4']
                CFLAGS += ['-mpreferred-stack-boundary=4']
                for ep in entrypoint_source_files:
                for ep in entrypoint_source_files:
                    SOURCES[ep].flags += ['-mincoming-stack-boundary=2']
                    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.
        # The default stack alignment is 16 bytes.
        stack_alignment = 16
        stack_alignment = 16
    else:
    else:
        error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])
        error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH'])
+8 −5
Original line number Original line Diff line number Diff line
@@ -443,7 +443,10 @@ def av1(value):


@depends(target, nasm_version, when=av1 & compile_environment)
@depends(target, nasm_version, when=av1 & compile_environment)
def dav1d_asm(target, nasm_version):
def dav1d_asm(target, nasm_version):
    if target.os != 'Android' and target.cpu in ('x86', 'x86_64'):
    if target.os != 'Android':
        if target.cpu == 'aarch64':
            return True
        elif target.cpu in ('x86', 'x86_64'):
            if nasm_version < '2.13':
            if nasm_version < '2.13':
                die('nasm 2.13 or greater is required for AV1 support. '
                die('nasm 2.13 or greater is required for AV1 support. '
                    'Either install nasm or add --disable-av1 to your configure options.')
                    'Either install nasm or add --disable-av1 to your configure options.')