shithub: openh264

Download patch

ref: 94be01301881f1062f56549f4612305cc8fb0407
parent: 3cbdb84fd048410e59e6facde7b46409f2096296
author: Martin Storsjö <[email protected]>
date: Wed Sep 16 19:53:11 EDT 2020

meson: Fix building for arm/aarch64 mingw (with clang)

For aarch64, gas-preprocessor isn't needed at all. This requires
changing all the if statements surrounding the use of asm_gen for
aarch64.

For arm, gas-preprocessor is needed, but can be invoked differently
to produce code that clang can assemble, instead of armasm.

--- a/codec/common/meson.build
+++ b/codec/common/meson.build
@@ -40,7 +40,7 @@
     'arm/intra_pred_common_neon.S',
     'arm/mc_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
@@ -53,7 +53,7 @@
     'arm64/intra_pred_common_aarch64_neon.S',
     'arm64/mc_aarch64_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
--- a/codec/decoder/meson.build
+++ b/codec/decoder/meson.build
@@ -34,7 +34,7 @@
     'core/arm/block_add_neon.S',
     'core/arm/intra_pred_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
@@ -44,7 +44,7 @@
     'core/arm64/block_add_aarch64_neon.S',
     'core/arm64/intra_pred_aarch64_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
--- a/codec/encoder/meson.build
+++ b/codec/encoder/meson.build
@@ -55,7 +55,7 @@
     'core/arm/reconstruct_neon.S',
     'core/arm/svc_motion_estimation.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
@@ -69,7 +69,7 @@
     'core/arm64/reconstruct_aarch64_neon.S',
     'core/arm64/svc_motion_estimation_aarch64_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
--- a/codec/processing/meson.build
+++ b/codec/processing/meson.build
@@ -33,7 +33,7 @@
     'src/arm/pixel_sad_neon.S',
     'src/arm/vaa_calc_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
@@ -45,7 +45,7 @@
 	'src/arm64/pixel_sad_aarch64_neon.S',
 	'src/arm64/vaa_calc_aarch64_neon.S',
   ]
-  if system == 'windows'
+  if use_asm_gen
     objs_asm = asm_gen.process(asm_sources)
   else
     cpp_sources += asm_sources
--- a/meson.build
+++ b/meson.build
@@ -106,16 +106,17 @@
     asm_args += ['-DWIN64']
     asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'x86', '')
   elif cpu_family == 'arm'
-    if cpp.get_argument_syntax() != 'msvc'
-      error('Windows ARM is currently only supported with Visual Studio-like compilers')
+    if cpp.get_argument_syntax() == 'msvc'
+      asm_format = 'armasm'
+      asm_args += ['-nologo', '-DHAVE_NEON', '-ignore', '4509']
+      asm_cmds = ['armasm']
+    else
+      asm_format = 'clang'
+      asm_args += ['-DHAVE_NEON', '-mimplicit-it=always']
+      asm_cmds = cpp.cmd_array()
     endif
-    asm_format = 'armasm'
-    asm_args += ['-nologo', '-DHAVE_NEON', '-ignore', '4509']
     asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'arm', '')
   elif cpu_family == 'aarch64'
-    if cpp.get_argument_syntax() != 'msvc'
-      error('Windows ARM64 is currently only supported with Visual Studio-like compilers')
-    endif
     asm_format = 'armasm'
     asm_args += ['-nologo', '-DHAVE_NEON_AARCH64']
     asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'arm64', '')
@@ -126,9 +127,11 @@
   error('FIXME: Unhandled system @0@'.format(system))
 endif
 
+use_asm_gen = false
 if cpu_family in ['x86', 'x86_64']
   nasm = find_program('nasm')
 
+  use_asm_gen = true
   asm_gen = generator(nasm,
     output : '@[email protected]',
     arguments : [
@@ -137,29 +140,38 @@
       '@INPUT@',
       '-o', '@OUTPUT@'] + asm_args)
 elif system == 'windows'
-  gasprep = find_program('gas-preprocessor.pl')
   if  cpu_family == 'arm'
+    # For ARM, gas-preprocessor is needed for converting the asm to be
+    # buildable as thumb even with Clang.
+    use_asm_gen = true
+    gasprep = find_program('gas-preprocessor.pl')
     asm_gen = generator(gasprep,
       output : '@[email protected]',
       arguments : [
         '-as-type', asm_format,
         '-force-thumb',
-        '--',
-        'armasm',
+        '--'
+        ] + asm_cmds + [
         '-I' + asm_inc] + asm_args + [
         '@INPUT@',
         '-c', '-o', '@OUTPUT@'])
   elif cpu_family == 'aarch64'
-    asm_gen = generator(gasprep,
-      output : '@[email protected]',
-      arguments : [
-        '-as-type', asm_format,
-        '-arch', 'aarch64',
-        '--',
-        'armasm64',
-        '-I' + asm_inc] + asm_args + [
-        '@INPUT@',
-        '-c', '-o', '@OUTPUT@'])
+    # For ARM64, Clang can build the assembly as-is without needing to use
+    # either gas-preprocessor or armasm64.
+    if cpp.get_argument_syntax() == 'msvc'
+      use_asm_gen = true
+      gasprep = find_program('gas-preprocessor.pl')
+      asm_gen = generator(gasprep,
+        output : '@[email protected]',
+        arguments : [
+          '-as-type', asm_format,
+          '-arch', 'aarch64',
+          '--',
+          'armasm64',
+          '-I' + asm_inc] + asm_args + [
+          '@INPUT@',
+          '-c', '-o', '@OUTPUT@'])
+    endif
   else
     # Windows only supports x86, x86_64, arm, arm64
     error('unreachable code')