Enable integrated assembler for Androidâ„¢ 13 and onwards only

Since Androidâ„¢ 13, the underlying NDK has deprecated system assembler
and favors integrated assembler instead

Please also see https://github.com/android/ndk/wiki/Changelog-r23

Resolves COMPMID-5410

Signed-off-by: SiCong Li <sicong.li@arm.com>
Change-Id: Ib9fa8a22f6cdb5cb4f0095e15bf332484f709630
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7956
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-by: Ramy Elgammal <ramy.elgammal@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
diff --git a/SConstruct b/SConstruct
index 7f0ebc1..9e04616 100644
--- a/SConstruct
+++ b/SConstruct
@@ -426,12 +426,21 @@
         if not version_at_least(compiler_ver, '7.0.0') and env['os'] == 'bare_metal':
             env.Append(LINKFLAGS = ['-fstack-protector-strong'])
 
-    # For NDK >= r21, clang 9 or above is used
-    if env['os'] == 'android' and version_at_least(compiler_ver, '9.0.0'):
-        env['ndk_above_r21'] = True
+    # Add Android NDK toolchain specific flags
+    if 'clang++' in cpp_compiler and env['os'] == 'android':
+        # For NDK >= r21, clang 9 or above is used
+        if version_at_least(compiler_ver, '9.0.0'):
+            env['ndk_above_r21'] = True
 
-        if env['openmp']:
-            env.Append(LINKFLAGS = ['-static-openmp'])
+            if env['openmp']:
+                env.Append(LINKFLAGS = ['-static-openmp'])
+
+        # For NDK >= r23, clang 12 or above is used. This condition detects NDK < r23
+        if not version_at_least(compiler_ver, '12.0.0'):
+            # System assembler is deprecated and integrated assembler is preferred since r23.
+            # However integrated assembler has always been suppressed for NDK < r23.
+            # Thus for backward compatibility, we include this flag only for NDK < r23
+            env.Append(CXXFLAGS = ['-no-integrated-as'])
 
 if env['high_priority'] and env['build_config']:
     print("The high priority library cannot be built in conjunction with a user-specified build configuration")