From 0ea37df4286e913b686ff0e85e686b6e6a494bda Mon Sep 17 00:00:00 2001
From: Dylan Baker <dylan@pnwbakers.com>
Date: Mon, 25 Mar 2019 16:28:06 -0700
Subject: [PATCH] meson: store ARM SIMD and NEON tests as text files

This is unfortunately required to make the tests work correctly, as
otherwise meson assumes that the files are C code not assembly. I've
opened https://github.com/mesonbuild/meson/issues/5151, to discuss
fixing the issue in meson upstream.

Fixes #29
---
 arm-simd-test.S | 10 ++++++++++
 meson.build     | 32 ++------------------------------
 neon-test.S     | 12 ++++++++++++
 3 files changed, 24 insertions(+), 30 deletions(-)
 create mode 100644 arm-simd-test.S
 create mode 100644 neon-test.S

diff --git a/arm-simd-test.S b/arm-simd-test.S
new file mode 100644
index 00000000..910c814d
--- /dev/null
+++ b/arm-simd-test.S
@@ -0,0 +1,10 @@
+.text
+.arch armv6
+.object_arch armv4
+.arm
+.altmacro
+#ifndef __ARM_EABI__
+#error EABI is required (to be sure that calling conventions are compatible)
+#endif
+pld [r0]
+uqadd8 r0, r0, r0
diff --git a/meson.build b/meson.build
index 6b247d86..7bfbd990 100644
--- a/meson.build
+++ b/meson.build
@@ -224,20 +224,7 @@ use_armv6_simd = get_option('arm-simd')
 have_armv6_simd = false
 if not use_armv6_simd.disabled()
   if host_machine.cpu_family() == 'arm'
-    if cc.compiles('''
-        .text
-        .arch armv6
-        .object_arch armv4
-        .arm
-        .altmacro
-        #ifndef __ARM_EABI__
-        #error EABI is required (to be sure that calling conventions are compatible)
-        #endif
-        pld [r0]
-        uqadd8 r0, r0, r0
-        ''',
-        args : ['-x assembler-with-cpp'],
-        name : 'ARMv6 SIMD Intrinsic Support')
+    if cc.compiles(files('arm-simd-test.S'), name : 'ARMv6 SIMD Intrinsic Support')
       have_armv6_simd = true
     endif
   endif
@@ -253,22 +240,7 @@ use_neon = get_option('neon')
 have_neon = false
 if not use_neon.disabled()
   if host_machine.cpu_family() == 'arm'
-    if cc.compiles('''
-        .text
-        .fpu neon
-        .arch armv7a
-        .object_arch armv4
-        .eabi_attribute 10, 0
-        .arm
-        .altmacro
-        #ifndef __ARM_EABI__
-        #error EABI is required (to be sure that calling conventions are compatible)
-        #endif
-        pld [r0]
-        vmovn.u16 d0, q0
-        ''',
-        args : ['-x assembler-with-cpp'],
-        name : 'NEON Intrinsic Support')
+    if cc.compiles(files('neon-test.S'), name : 'NEON Intrinsic Support')
       have_neon = true
     endif
   endif
diff --git a/neon-test.S b/neon-test.S
new file mode 100644
index 00000000..c30a3990
--- /dev/null
+++ b/neon-test.S
@@ -0,0 +1,12 @@
+.text
+.fpu neon
+.arch armv7a
+.object_arch armv4
+.eabi_attribute 10, 0
+.arm
+.altmacro
+#ifndef __ARM_EABI__
+#error EABI is required (to be sure that calling conventions are compatible)
+#endif
+pld [r0]
+vmovn.u16 d0, q0
-- 
GitLab