Bug 1480834 - 5. Keep target flag when building for Android on Linux; r=glandium

Currently, when building for Android x86-64 on Linux x86-64, we drop the
'--target' flag, which causes the build to fail. This patch adds a check
for OS mismatch, so we keep the '--target' flag in this situation.

Differential Revision: https://phabricator.services.mozilla.com/D4483
This commit is contained in:
Jim Chen 2018-09-13 12:09:26 -04:00
Родитель 216db72bef
Коммит 6ce80dbdc4
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -352,6 +352,8 @@ def try_preprocess(compiler, language, source):
_import='CPU_preprocessor_checks')
@imports(_from='mozbuild.configure.constants',
_import='kernel_preprocessor_checks')
@imports(_from='mozbuild.configure.constants',
_import='OS_preprocessor_checks')
@imports(_from='textwrap', _import='dedent')
def get_compiler_info(compiler, language):
'''Returns information about the given `compiler` (command line in the
@ -408,6 +410,7 @@ def get_compiler_info(compiler, language):
for name, preprocessor_checks in (
('CPU', CPU_preprocessor_checks),
('KERNEL', kernel_preprocessor_checks),
('OS', OS_preprocessor_checks),
):
for n, (value, condition) in enumerate(preprocessor_checks.iteritems()):
check += dedent('''\
@ -475,12 +478,15 @@ def get_compiler_info(compiler, language):
cpu=data.get('CPU'),
kernel=data.get('KERNEL'),
endianness=data.get('ENDIANNESS'),
os=data.get('OS'),
language='C++' if cplusplus else 'C',
language_version=cplusplus if cplusplus else stdc_version,
)
@imports(_from='mozbuild.shellutil', _import='quote')
@imports(_from='mozbuild.configure.constants',
_import='OS_preprocessor_checks')
def check_compiler(compiler, language, target):
info = get_compiler_info(compiler, language)
@ -555,12 +561,21 @@ def check_compiler(compiler, language, target):
if info.type == 'clang':
append_flag('--target=%s' % target.toolchain)
# Add target flag when there is an OS mismatch (e.g. building for Android on
# Linux). However, only do this if the target OS is in our whitelist, to
# keep things the same on other platforms.
if target.os in OS_preprocessor_checks and (
not info.os or info.os != target.os):
if info.type == 'clang':
append_flag('--target=%s' % target.toolchain)
return namespace(
type=info.type,
version=info.version,
target_cpu=info.cpu,
target_kernel=info.kernel,
target_endianness=info.endianness,
target_os=info.os,
flags=flags,
)

Просмотреть файл

@ -106,3 +106,11 @@ kernel_preprocessor_checks = {
}
assert sorted(kernel_preprocessor_checks.keys()) == sorted(Kernel.POSSIBLE_VALUES)
OS_preprocessor_checks = {
'Android': '__ANDROID__',
}
# We intentionally don't include all possible OSes in our checks, because we
# only care about OS mismatches for specific target OSes.
# assert sorted(OS_preprocessor_checks.keys()) == sorted(OS.POSSIBLE_VALUES)