Bug 1527471 - part 1 - preprocess aarch64 windows assembly xptcall files; r=dmajor

We need to preprocess these files so we can eventually add unwind
information, for which we need to include C headers.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-02-14 20:58:45 +00:00
parent 85ee22eddd
commit 4935a6e5d2
2 changed files with 49 additions and 1 deletions

View File

@ -40,11 +40,21 @@ elif CONFIG['CPU_ARCH'] == 'aarch64':
'xptcinvoke_aarch64.cpp',
'xptcstubs_aarch64.cpp',
]
SOURCES += [
asm_files = [
'xptcinvoke_asm_aarch64.asm',
'xptcstubs_asm_aarch64.asm',
]
# make gets confused if the srcdir and objdir files have the same name, so
# we generate different names for the objdir files
for src in asm_files:
obj = src.replace('_asm_aarch64', '')
GENERATED_FILES += [obj]
asm = GENERATED_FILES[obj]
asm.script = 'preprocess.py:preprocess'
asm.inputs = [src]
SOURCES += ['!%s' % obj]
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [

View File

@ -0,0 +1,38 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import sys
import os
import shlex
import subprocess
import tempfile
import which
import buildconfig
def preprocess(out, asm_file):
cxx = shlex.split(buildconfig.substs['CXX'])
if not os.path.exists(cxx[0]):
cxx[0] = which.which(cxx[0])
cppflags = buildconfig.substs['OS_CPPFLAGS']
# subprocess.Popen(stdout=) only accepts actual file objects, which `out`,
# above, is not. So fake a temporary file to write to.
(outhandle, tmpout) = tempfile.mkstemp(suffix='.cpp')
# #line directives will confuse armasm64, and /EP is the only way to
# preprocess without emitting #line directives.
command = cxx + ['/EP'] + cppflags + ['/TP', asm_file]
with open(tmpout, 'wb') as t:
result = subprocess.Popen(command, stdout=t).wait()
if result != 0:
sys.exit(result)
with open(tmpout, 'rb') as t:
out.write(t.read())
os.close(outhandle)
os.remove(tmpout)