# HG changeset patch # User Dan Minor # Date 1556723088 0 # Node ID f1bc4fcd152e66e858c3a1d0b0afd30a78e9474b # Parent c25bb3353335741cf7045c4430ea4c8c33f6f074 Bug 1540760 - Make it possible to use clang-cl as an assembler; r=firefox-build-system-reviewers,mshal Some media libraries use gas syntax in their assembly files. Rather than converting these arm assembly syntax files for aarch64, we can use clang-cl to build them directly. Differential Revision: https://phabricator.services.mozilla.com/D27785 diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -2110,16 +2110,30 @@ def have_yasm(yasm_asflags): return True set_config('HAVE_NASM', have_nasm) set_config('HAVE_YASM', have_yasm) # Until the YASM variable is not necessary in old-configure. add_old_configure_assignment('YASM', have_yasm) + +# clang-cl integrated assembler support +# ============================================================== +@depends(target) +def clangcl_asflags(target): + asflags = None + if target.os == 'WINNT' and target.cpu == 'aarch64': + asflags = ['--target=aarch64-windows-msvc'] + return asflags + + +set_config('CLANGCL_ASFLAGS', clangcl_asflags) + + # Code Coverage # ============================================================== js_option('--enable-coverage', env='MOZ_CODE_COVERAGE', help='Enable code coverage') @depends('--enable-coverage') def code_coverage(value): diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -2195,16 +2195,24 @@ VARIABLES = { By default, the build will use the toolchain assembler, $(AS), to assemble source files in assembly language (.s or .asm files). Setting this value to ``True`` will cause it to use yasm instead. If yasm is not available on this system, or does not support the current target architecture, an error will be raised. """), + + 'USE_INTEGRATED_CLANGCL_AS': (bool, bool, + """Use the integrated clang-cl assembler to assemble assembly files from SOURCES. + + This allows using clang-cl to assemble assembly files which is useful + on platforms like aarch64 where the alternative is to have to run a + pre-processor to generate files with suitable syntax. + """), } # Sanity check: we don't want any variable above to have a list as storage type. for name, (storage_type, input_types, docs) in VARIABLES.items(): if storage_type == list: raise RuntimeError('%s has a "list" storage type. Use "List" instead.' % name) diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -1353,16 +1353,26 @@ class TreeMetadataEmitter(LoggingMixin): if not nasm: raise SandboxValidationError('nasm is not available', context) passthru.variables['AS'] = nasm passthru.variables['AS_DASH_C_FLAG'] = '' passthru.variables['ASOUTOPTION'] = '-o ' computed_as_flags.resolve_flags('OS', context.config.substs.get('NASM_ASFLAGS', [])) + if context.get('USE_INTEGRATED_CLANGCL_AS') is True: + clangcl = context.config.substs.get('CLANG_CL') + if not clangcl: + raise SandboxValidationError('clang-cl is not available', context) + passthru.variables['AS'] = 'clang-cl' + passthru.variables['AS_DASH_C_FLAG'] = '-c' + passthru.variables['ASOUTOPTION'] = '-o ' + computed_as_flags.resolve_flags('OS', + context.config.substs.get('CLANGCL_ASFLAGS', [])) + if passthru.variables: yield passthru if context.objdir in self._compile_dirs: self._compile_flags[context.objdir] = computed_flags yield computed_link_flags if context.objdir in self._asm_compile_dirs: