diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2022-03-24 14:23:07 +0000 |
---|---|---|
committer | ramelg01 <ramy.elgammal@arm.com> | 2022-03-28 15:24:18 +0100 |
commit | b83e67238bf84c5780f9d27c87cf30342099b291 (patch) | |
tree | ae255799924bc3b0ba54f9169e462f9c07a87853 | |
parent | bfd10a1a766831fedc3a2991e70dfe388ebeb422 (diff) | |
download | ComputeLibrary-b83e67238bf84c5780f9d27c87cf30342099b291.tar.gz |
Enable -static-openmp for newer NDK support
Android NDKs >= r21 need the '-static-openmp' flag enabled when using openmp.
The check on the NDK version is performed by querying the compiler binary's clang version.
NDK versions <= r20 use clang 8 and below. Versions >= r21 use clang 9 and above
Resolves: COMPMID-5052
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Change-Id: I910f8d7a0a59866c06b16c1a856ea877bcbd7ad6
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7344
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
(cherry picked from commit 444b43a55bab37fa6dc8628c6283e54e422db3ad)
-rw-r--r-- | SConstruct | 16 | ||||
-rw-r--r-- | tests/SConscript | 8 |
2 files changed, 16 insertions, 8 deletions
diff --git a/SConstruct b/SConstruct index 0f3397278f..fedf856b75 100644 --- a/SConstruct +++ b/SConstruct @@ -25,8 +25,7 @@ import SCons import json import os -import subprocess -import sys +from subprocess import check_output def version_at_least(version, required): @@ -234,7 +233,7 @@ if 'clang++' in cpp_compiler: elif 'armclang' in cpp_compiler: pass elif not 'windows' in env['os']: - env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel','-Wno-misleading-indentation']) + env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel','-Wno-misleading-indentation']) if cpp_compiler == 'g++': # Don't strip comments that could include markers @@ -369,9 +368,9 @@ env['RANLIB'] = prefix + "ranlib" if not GetOption("help"): try: if env['os'] == 'windows': - compiler_ver = subprocess.check_output("clang++ -dumpversion").decode().strip() + compiler_ver = check_output("clang++ -dumpversion").decode().strip() else: - compiler_ver = subprocess.check_output(env['CXX'].split() + ["-dumpversion"]).decode().strip() + compiler_ver = check_output(env['CXX'].split() + ["-dumpversion"]).decode().strip() except OSError: print("ERROR: Compiler '%s' not found" % env['CXX']) Exit(1) @@ -395,6 +394,13 @@ if not GetOption("help"): 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 + + if env['openmp']: + env.Append(LINKFLAGS = ['-static-openmp']) + if env['high_priority'] and env['build_config']: print("The high priority library cannot be built in conjunction with a user-specified build configuration") Exit(1) diff --git a/tests/SConscript b/tests/SConscript index 005699e397..cfe3bc5e82 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -21,7 +21,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import SCons import os.path Import('env') @@ -174,8 +173,11 @@ if test_env['linker_script']: bm_link_flags += ['-Wl,--build-id=none', '-T', env['linker_script']] if test_env['reference_openmp'] and env['os'] not in ['bare_metal', 'macos']: - test_env['CXXFLAGS'].append('-fopenmp') - test_env['LINKFLAGS'].append('-fopenmp') + test_env['CXXFLAGS'].append('-fopenmp') + test_env['LINKFLAGS'].append('-fopenmp') + + if 'ndk_above_r21' in env: + test_env['LINKFLAGS'].append('-static-openmp') if test_env['validation_tests']: arm_compute_validation_framework = env.StaticLibrary('arm_compute_validation_framework', Glob('validation/reference/*.cpp') + Glob('validation/*.cpp'), LINKFLAGS=test_env['LINKFLAGS'], CXXFLAGS=test_env['CXXFLAGS'], LIBS= [ arm_compute_test_framework, arm_compute_core_a]) |