Skip to content

Commit

Permalink
Bug 1537725 - Use the default stack alignment in windows x86 for libd…
Browse files Browse the repository at this point in the history
…av1d. r=TD-Linux

Differential Revision: https://phabricator.services.mozilla.com/D24785
  • Loading branch information
achronop committed Mar 26, 2019
1 parent 5d03b09 commit 5c5c754
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
13 changes: 9 additions & 4 deletions media/libdav1d/asm/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,26 @@ CFLAGS += [
'-I%s/dist/include/dav1d/' % TOPOBJDIR,
]

# Default stack aligment is 16 bytes.
stack_alignment = 16

stack_alignment = 0
# Attaching config.asm file
if CONFIG['CPU_ARCH'] == 'x86':
# Default stack alignment can be 4 bytes.
if CONFIG['OS_TARGET'] == 'WINNT':
stack_alignment = 4
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/win/' % TOPSRCDIR]
else:
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/' % TOPSRCDIR]
# Default stack aligment can be 4 bytes, change it to 16 bytes.
stack_alignment = 16
# Change stack alignment to 16 bytes.
if CONFIG['CC_TYPE'] == 'clang':
CFLAGS += ['-mstack-alignment=16']
elif CONFIG['CC_TYPE'] == 'gcc':
CFLAGS += ['-mpreferred-stack-boundary=4']


if CONFIG['CPU_ARCH'] == 'x86_64':
# Default stack aligment is 16 bytes.
stack_alignment = 16
if CONFIG['OS_TARGET'] == 'Darwin':
ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/osx/' % TOPSRCDIR]
elif CONFIG['OS_TARGET'] == 'WINNT':
Expand All @@ -62,6 +65,8 @@ if CONFIG['CPU_ARCH'] == 'x86_64':
CFLAGS += ['-mpreferred-stack-boundary=5']

# Set the macro here instead of config.h
if stack_alignment == 0:
error('Stack alignment cannot be zero.')
DEFINES['STACK_ALIGNMENT'] = stack_alignment

if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
Expand Down
2 changes: 1 addition & 1 deletion media/libdav1d/asm/x86_32/win/config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

%define PREFIX 1

%define STACK_ALIGNMENT 16
%define STACK_ALIGNMENT 4

32 changes: 21 additions & 11 deletions media/libdav1d/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,26 @@ DEFINES['DAV1D_API'] = ''
if CONFIG['MOZ_DAV1D_ASM']:
DIRS += ['asm']

# Store the stack alignment that will be used.
stack_alignment = 0

# Default stack alignment can be 4 bytes on x86.
if CONFIG['CPU_ARCH'] == 'x86':
# Update stack alignment to 16 bytes.
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']
if CONFIG['OS_TARGET'] == 'WINNT':
# Allow the default to avoid crashes
stack_alignment = 4
else:
# Update stack alignment to 16 bytes.
stack_alignment = 16
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']

# Expect stack alignment of 16 bytes.
stack_alignment = 16

# The default stack alignment in x86_64 is 16 bytes. On all Linux flavors the
# default is used due to crashes with 32 bytes stack alignment.
Expand All @@ -60,8 +66,12 @@ if CONFIG['MOZ_DAV1D_ASM']:
CFLAGS += ['-mpreferred-stack-boundary=5']
for ep in entrypoint_source_files:
SOURCES[ep].flags += ['-mincoming-stack-boundary=4']
else:
stack_alignment = 16

# Set the macro here instead of config.h
if stack_alignment == 0:
error('Stack alignment cannot be zero.')
DEFINES['STACK_ALIGNMENT'] = stack_alignment

if CONFIG['OS_TARGET'] == 'Linux':
Expand Down

0 comments on commit 5c5c754

Please sign in to comment.