Bug 1521062 - Configure assembly builds for libdav1d on Windows. r=TD-Linux

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Chronopoulos 2019-03-07 09:32:15 +00:00
parent ec976d82a9
commit ec9ec63b46
5 changed files with 64 additions and 16 deletions

View File

@ -25,24 +25,31 @@ CFLAGS += [
'-I%s/dist/include/dav1d/' % TOPOBJDIR,
]
# This is Linux only for now
# This code is only built on Windows and Linux for now.
# Attaching config.asm file
if CONFIG['CPU_ARCH'] == 'x86':
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/' % TOPSRCDIR]
if CONFIG['OS_TARGET'] == 'WINNT':
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/win/' % TOPSRCDIR]
else:
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/' % TOPSRCDIR]
if CONFIG['CPU_ARCH'] == 'x86_64':
if CONFIG['OS_TARGET'] == 'Linux':
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/linux/' % TOPSRCDIR]
elif CONFIG['OS_TARGET'] == 'Darwin':
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/osx/' % TOPSRCDIR]
elif CONFIG['OS_TARGET'] == 'WINNT':
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/' % TOPSRCDIR]
else:
error('Platform %s is not expected' % CONFIG['OS_TARGET'])
if CONFIG['OS_TARGET'] in ('Darwin', 'WINNT'):
# Change the default stack aligment (16) to 32
if CONFIG['CC_TYPE'] == 'clang':
CFLAGS += ['-mstack-alignment=32']
elif CONFIG['CC_TYPE'] == 'gcc':
CFLAGS += ['-mpreferred-stack-boundary=5']
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/osx/' % TOPSRCDIR]
else:
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/' % TOPSRCDIR]
if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
SOURCES += [
@ -54,16 +61,22 @@ if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
]
# ASM source files
if CONFIG['CPU_ARCH'] == 'x86_64':
# Empty file on all other archs. Nasm produces
# an error when it compiles empty files.
SOURCES += [
'../../../third_party/dav1d/src/x86/cdef.asm',
'../../../third_party/dav1d/src/x86/ipred.asm',
'../../../third_party/dav1d/src/x86/itx.asm',
'../../../third_party/dav1d/src/x86/loopfilter.asm',
'../../../third_party/dav1d/src/x86/looprestoration.asm',
'../../../third_party/dav1d/src/x86/mc.asm',
]
SOURCES += [
'../../../third_party/dav1d/src/x86/cdef.asm',
'../../../third_party/dav1d/src/x86/cpuid.asm',
'../../../third_party/dav1d/src/x86/ipred.asm',
'../../../third_party/dav1d/src/x86/ipred_ssse3.asm',
'../../../third_party/dav1d/src/x86/itx.asm',
'../../../third_party/dav1d/src/x86/itx_ssse3.asm',
'../../../third_party/dav1d/src/x86/loopfilter.asm',
'../../../third_party/dav1d/src/x86/looprestoration.asm',
'../../../third_party/dav1d/src/x86/mc.asm',
'../../../third_party/dav1d/src/x86/mc_ssse3.asm',
]

View File

@ -0,0 +1,13 @@
; Autogenerated by the Meson build system.
; Do not edit, your changes will be lost.
%define ARCH_X86_32 1
%define ARCH_X86_64 0
%define PIC 1
%define PREFIX 1
%define STACK_ALIGNMENT 16

View File

@ -36,8 +36,7 @@
#define CONFIG_8BPC 1
// Enable asm
#if (ARCH_x86_32 == 1 || ARCH_X86_64 == 1) && defined(__linux__) && \
!defined(__ANDROID__)
#if defined(MOZ_DAV1D_ASM)
# define HAVE_ASM 1
#else
# define HAVE_ASM 0
@ -49,7 +48,8 @@
// HAVE_UNISTD_H
// Important when asm is enabled
#if defined(__APPLE__)
#if defined(__APPLE__) || \
(ARCH_x86_32 == 1 && defined(_WIN32))
# define PREFIX 1
#endif
@ -59,3 +59,10 @@
#else
# define STACK_ALIGNMENT 32
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
// _WIN32_WINNT 0x0601 is set in global macros
#define UNICODE 1
#define _UNICODE 1
#define __USE_MINGW_ANSI_STDIO 1
#endif

View File

@ -19,10 +19,11 @@ EXPORTS.dav1d += [
]
# entrypoint source files
SOURCES += [
entrypoint_source_files = [
'../../third_party/dav1d/src/lib.c',
'../../third_party/dav1d/src/thread_task.c',
]
SOURCES += [f for f in entrypoint_source_files]
# Don't export DAV1D_API symbols from libxul
# see: third_party/dav1d/include/dav1d/common.h
@ -31,6 +32,16 @@ DEFINES['DAV1D_API'] = ''
if CONFIG['MOZ_DAV1D_ASM']:
# Default stack aligment is 16 bytes
DIRS += ['asm']
if CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'x86_64':
# Update stack aligment to 32 bytes
if CONFIG['CC_TYPE'] == 'clang':
CFLAGS += ['-mstack-alignment=32']
for ep in entrypoint_source_files:
SOURCES[ep].flags += ['-mstackrealign']
elif CONFIG['CC_TYPE'] == 'gcc':
CFLAGS += ['-mpreferred-stack-boundary=5']
for ep in entrypoint_source_files:
SOURCES[ep].flags += ['-mincoming-stack-boundary=4']
# common sources
SOURCES += [

View File

@ -443,7 +443,10 @@ def av1(value):
@depends(target, nasm_version, when=av1 & compile_environment)
def dav1d_asm(target, nasm_version):
if target.os == 'GNU' and target.kernel == 'Linux' and target.cpu in ('x86', 'x86_64'):
if (
target.os == 'GNU' and target.kernel == 'Linux' and target.cpu in ('x86', 'x86_64') or
target.os == 'WINNT' 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.')
@ -451,6 +454,7 @@ def dav1d_asm(target, nasm_version):
set_config('MOZ_DAV1D_ASM', dav1d_asm)
set_define('MOZ_DAV1D_ASM', dav1d_asm)
set_config('MOZ_AV1', av1)
set_define('MOZ_AV1', av1)