From d25cff72021df3d9c0e394c2327906d56c58d2c3 Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Fri, 9 Feb 2024 16:06:01 +0300 Subject: [PATCH 1/2] [compiler-rt] testing support for ohos with hdc Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/I8PGWS Change-Id: Ide7c3150a930ce197ebd0c1840f43b9cfa6ae67d Signed-off-by: Sukhikh Alexander --- compiler-rt/test/gwp_asan/lit.cfg.py | 4 +-- .../hwasan/TestCases/Linux/lit.local.cfg.py | 2 +- .../TestCases/abort-message-android.cpp | 3 +- .../hwasan/TestCases/libc_thread_freeres.c | 3 +- .../test/hwasan/TestCases/preinit_array.c | 4 +++ .../TestCases/print-memory-usage-android.c | 3 +- compiler-rt/test/hwasan/TestCases/sizes.cpp | 4 +++ compiler-rt/test/hwasan/TestCases/stack-uas.c | 4 +++ compiler-rt/test/hwasan/lit.cfg.py | 3 +- compiler-rt/test/lit.common.cfg.py | 29 ++++++++------- .../ohos_family_commands/hdc_constants.py | 18 ++++++++++ .../ohos_family_commands/ohos_common.py | 33 +++++++++++------ .../ohos_family_commands/ohos_compile.py | 19 +++------- .../ohos_family_commands/ohos_run.py | 35 ++++++++++++++----- compiler-rt/test/scudo/lit.cfg.py | 6 ++-- compiler-rt/test/scudo/malloc.cpp | 6 ++++ compiler-rt/test/scudo/overflow.c | 6 ++++ 17 files changed, 125 insertions(+), 57 deletions(-) create mode 100644 compiler-rt/test/sanitizer_common/ohos_family_commands/hdc_constants.py diff --git a/compiler-rt/test/gwp_asan/lit.cfg.py b/compiler-rt/test/gwp_asan/lit.cfg.py index c806ae2d4727..58658a4551dc 100644 --- a/compiler-rt/test/gwp_asan/lit.cfg.py +++ b/compiler-rt/test/gwp_asan/lit.cfg.py @@ -51,6 +51,6 @@ default_gwp_asan_options += ':' config.substitutions.append(('%env_scudo_options=', 'env SCUDO_OPTIONS=' + default_gwp_asan_options)) -# GWP-ASan tests are currently supported on Linux only. -if config.host_os not in ['Linux']: +# GWP-ASan tests are currently supported on Linux and OHOS only. +if config.host_os not in ['Linux', 'OHOS']: # OHOS_LOCAL config.unsupported = True diff --git a/compiler-rt/test/hwasan/TestCases/Linux/lit.local.cfg.py b/compiler-rt/test/hwasan/TestCases/Linux/lit.local.cfg.py index 57271b8078a4..ce7ce5ddde93 100644 --- a/compiler-rt/test/hwasan/TestCases/Linux/lit.local.cfg.py +++ b/compiler-rt/test/hwasan/TestCases/Linux/lit.local.cfg.py @@ -5,5 +5,5 @@ def getRoot(config): root = getRoot(config) -if root.host_os not in ['Linux']: +if root.host_os not in ['Linux', 'OHOS']: # OHOS_LOCAL config.unsupported = True diff --git a/compiler-rt/test/hwasan/TestCases/abort-message-android.cpp b/compiler-rt/test/hwasan/TestCases/abort-message-android.cpp index f89b929d454d..c038d74a546b 100644 --- a/compiler-rt/test/hwasan/TestCases/abort-message-android.cpp +++ b/compiler-rt/test/hwasan/TestCases/abort-message-android.cpp @@ -1,6 +1,7 @@ // RUN: %clangxx_hwasan -DERR=1 %s -o %t && not %run %t 2>&1 | FileCheck %s // RUN: %clangxx_hwasan -DERR=2 %s -o %t && not %run %t 2>&1 | FileCheck %s -// REQUIRES: android +// OHOS_LOCAL +// REQUIRES: android && !ohos_family #include #include diff --git a/compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c b/compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c index 83451f5bdf40..105213972112 100644 --- a/compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c +++ b/compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c @@ -1,5 +1,6 @@ // RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=random_tags=1 %run %t -// REQUIRES: stable-runtime +// OHOS_LOCAL +// REQUIRES: stable-runtime && !ohos_family #include #include diff --git a/compiler-rt/test/hwasan/TestCases/preinit_array.c b/compiler-rt/test/hwasan/TestCases/preinit_array.c index 54d3ee7eea15..7e9c807fa34c 100644 --- a/compiler-rt/test/hwasan/TestCases/preinit_array.c +++ b/compiler-rt/test/hwasan/TestCases/preinit_array.c @@ -3,6 +3,10 @@ // RUN: %clang_hwasan %s -o %t // RUN: %run %t +// OHOS_LOCAL +// musl doesn't have .preinit_array section +// REQUIRES: !ohos_family + volatile int Global; void StoreToGlobal() { Global = 42; } diff --git a/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c b/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c index 5a057928ba75..3dc8a33bc914 100644 --- a/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c +++ b/compiler-rt/test/hwasan/TestCases/print-memory-usage-android.c @@ -1,6 +1,7 @@ // Tests __hwasan_print_memory_usage through /proc/$PID/maps. // RUN: %clang_hwasan %s -o %t && %env_hwasan_opts=export_memory_stats=1 %run %t 2>&1 | FileCheck %s -// REQUIRES: android +// OHOS_LOCAL +// REQUIRES: android && !ohos_family #include #include diff --git a/compiler-rt/test/hwasan/TestCases/sizes.cpp b/compiler-rt/test/hwasan/TestCases/sizes.cpp index 2cb70f52147a..32c2cfc27e86 100644 --- a/compiler-rt/test/hwasan/TestCases/sizes.cpp +++ b/compiler-rt/test/hwasan/TestCases/sizes.cpp @@ -23,6 +23,10 @@ // allocator can allocate. Tests that an integer overflow in the parameters of // calloc is caught. +// OHOS_LOCAL +// we can't link with libstdc++ +// REQUIRES: !ohos_family + #include #include #include diff --git a/compiler-rt/test/hwasan/TestCases/stack-uas.c b/compiler-rt/test/hwasan/TestCases/stack-uas.c index 7f5a6f26d067..ca81663e00e6 100644 --- a/compiler-rt/test/hwasan/TestCases/stack-uas.c +++ b/compiler-rt/test/hwasan/TestCases/stack-uas.c @@ -17,6 +17,10 @@ // Stack histories currently are not recorded on x86. // XFAIL: x86_64 +// OHOS_LOCAL +// Return value is undefined on OHOS +// XFAIL: ohos_family + void USE(void *x) { // pretend_to_do_something(void *x) __asm__ __volatile__("" : diff --git a/compiler-rt/test/hwasan/lit.cfg.py b/compiler-rt/test/hwasan/lit.cfg.py index 85fda0c70324..4b3313a374ba 100644 --- a/compiler-rt/test/hwasan/lit.cfg.py +++ b/compiler-rt/test/hwasan/lit.cfg.py @@ -53,6 +53,5 @@ config.substitutions.append(('%env_hwasan_opts=', # Default test suffixes. config.suffixes = ['.c', '.cpp'] - -if config.host_os not in ['Linux', 'Android'] or not config.has_lld: +if config.host_os not in ['Linux', 'Android', 'OHOS'] or not config.has_lld: # OHOS_LOCAL config.unsupported = True diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index 4c43a0b0143e..04093624454c 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -7,6 +7,7 @@ import os import platform import re import subprocess +import sys # OHOS_LOCAL import json import lit.formats @@ -273,10 +274,6 @@ elif is_ohos_family_mobile(): config.compile_wrapper = compile_wrapper config.substitutions.append( ('%run', "") ) config.substitutions.append( ('%env ', "env ") ) - # TODO: Implement `%device_rm` to perform removal of files on a device. For - # now just make it a no-op. - lit_config.warning('%device_rm is not implemented') - config.substitutions.append( ('%device_rm', 'echo ') ) elif config.host_os == 'Darwin' and config.apple_platform != "osx": # Darwin tests can be targetting macOS, a device or a simulator. All devices # are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly, @@ -521,14 +518,18 @@ if config.android: # OHOS_LOCAL begin elif config.host_os == 'OHOS': + hdc_imp = os.path.join(os.path.dirname(__file__), 'sanitizer_common', 'ohos_family_commands') + sys.path.append(hdc_imp) + import hdc_constants env = os.environ.copy() - adb = os.environ.get('ADB', 'adb') - device_tmpdir = '/data/local/tmp/Output/' - config.substitutions.append( ('%device_rundir/', device_tmpdir) ) - config.substitutions.append( ('%push_to_device', "%s push " % adb) ) - config.substitutions.append( ('%adb_shell ', "%s shell " % adb) ) - config.substitutions.append( ('%device_rm', "%s shell 'rm ' " % adb) ) - subprocess.check_call([adb, "shell", "mkdir", "-p", device_tmpdir], env=env) + config.substitutions.append( ('%device_rundir/', hdc_constants.TMPDIR) ) + prefix = hdc_constants.get_hdc_cmd_prefix() + prefix_str = ' '.join(prefix) + config.substitutions.append(('%push_to_device', "%s file send " % prefix_str) ) + config.substitutions.append(('%adb_shell ', "%s shell " % prefix_str) ) + config.substitutions.append(('%device_rm', "%s shell 'rm ' " % prefix_str) ) + subprocess.check_call(prefix + ['tconn'], env=env) + subprocess.check_call(prefix + ['shell', 'mkdir', '-p', hdc_constants.TMPDIR], env=env) # OHOS_LOCAL end else: @@ -710,7 +711,11 @@ elif config.android or is_ohos_family_mobile(): # Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL # because the test hangs or fails on one configuration and not the other. -if config.android or (config.target_arch not in ['arm', 'armhf', 'aarch64']): +# OHOS_LOCAL begin +if config.android or config.host_os == 'OHOS' or ( + config.target_arch not in ['arm', 'armhf', 'aarch64'] + ): +# OHOS_LOCAL end config.available_features.add('stable-runtime') if config.asan_shadow_scale: diff --git a/compiler-rt/test/sanitizer_common/ohos_family_commands/hdc_constants.py b/compiler-rt/test/sanitizer_common/ohos_family_commands/hdc_constants.py new file mode 100644 index 000000000000..af6853ed8b1d --- /dev/null +++ b/compiler-rt/test/sanitizer_common/ohos_family_commands/hdc_constants.py @@ -0,0 +1,18 @@ + +import os + +# TODO: move this to the cmake ? +HDC = os.environ.get('HDC', 'hdc') +HDC_SERVER_IP_PORT = os.environ.get('HDC_SERVER_IP_PORT') +HDC_UTID = os.environ.get('HDC_UTID') +TMPDIR = os.environ.get('OHOS_REMOTE_TMP_DIR', '/data/local/tmp/Output') + +# emit warning on import if some required constants are not set +if not HDC_SERVER_IP_PORT or not HDC_UTID: + print('Please set "HDC_SERVER_IP_PORT" and "HDC_UTID" environment variables ' + 'to be able to debug on remote device') + +def get_hdc_cmd_prefix(): + server = ['-s', HDC_SERVER_IP_PORT] if HDC_SERVER_IP_PORT else [] + device = ['-t', HDC_UTID] if HDC_UTID else [] + return [HDC, *server, *device] diff --git a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_common.py b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_common.py index d4a94c03a654..de2aabe8107e 100755 --- a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_common.py +++ b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_common.py @@ -1,9 +1,7 @@ #!/usr/bin/env python3 import os, subprocess, tempfile - -HOS_TMPDIR = '/data/local/tmp/Output' -ADB = os.environ.get('ADB', 'adb') +import hdc_constants verbose = False if os.environ.get('HOS_RUN_VERBOSE') == '1': @@ -11,10 +9,14 @@ if os.environ.get('HOS_RUN_VERBOSE') == '1': def host_to_device_path(path): rel = os.path.relpath(path, "/") - dev = os.path.join(HOS_TMPDIR, rel) + dev = os.path.join(hdc_constants.TMPDIR, rel) return dev -def adb(args, attempts = 1): +def hdc_output(args): + command = hdc_constants.get_hdc_cmd_prefix() + args + return subprocess.check_output(command, stderr=subprocess.STDOUT) + +def hdc(args, attempts=1, check_stdout=''): if verbose: print (args) tmpname = tempfile.mktemp() @@ -22,11 +24,13 @@ def adb(args, attempts = 1): ret = 255 while attempts > 0 and ret != 0: attempts -= 1 - ret = subprocess.call([ADB] + args, stdout=out, stderr=subprocess.STDOUT) - if attempts != 0: - ret = 5 + ret = 0 + output = hdc_output(args) + # hdc exit code is always zero + if check_stdout not in output.decode(): + ret = 255 if ret != 0: - print ("adb command failed", args) + print ("hdc command failed", args) print (tmpname) out.close() out = open(tmpname, 'r') @@ -36,12 +40,19 @@ def adb(args, attempts = 1): return ret def pull_from_device(path): + # hdc can't download empty files + file_sz = hdc_output(['shell', 'du', path]).split() + if file_sz and file_sz[0] == b'0': + return '' + tmp = tempfile.mktemp() - adb(['pull', path, tmp], 5) + hdc(['file', 'recv', path, tmp], attempts=5, check_stdout='FileTransfer finish') text = open(tmp, 'r').read() os.unlink(tmp) return text def push_to_device(path): dst_path = host_to_device_path(path) - adb(['push', path, dst_path], 5) + # hdc do not auto create directories on device + hdc(['shell', 'mkdir', '-p', os.path.dirname(dst_path)]) + hdc(['file', 'send', path, dst_path], attempts=5, check_stdout='FileTransfer finish') diff --git a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_compile.py b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_compile.py index 265a4a9f8f09..9006dac3d3b9 100755 --- a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_compile.py +++ b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_compile.py @@ -21,31 +21,20 @@ while args: output_type = 'object' elif arg == '-o': output = args.pop(0) - elif arg == '-target': - check_trgt = True - elif check_trgt or arg.startswith('--target='): - check_trgt = False - if arg.endswith('-linux-ohos'): - arg = arg.split('=')[-1] - dyld = 'unknown_hos_dyld' - # FIXME: Handle -mfloat-abi=hard for arm - # TODO: Support x86_64 - if arg.startswith('arm'): - dyld = 'ld-musl-arm.so.1' - elif arg.startswith('aarch64'): - dyld = 'ld-musl-aarch64.so.1' - append_args += ['-Wl,--dynamic-linker=' + os.path.join(HOS_TMPDIR, dyld)] if output == None: print ("No output file name!") sys.exit(1) -ret = subprocess.call(sys.argv[1:] + append_args) +with open(f'{output}.stderr', 'w') as f: + ret = subprocess.call(sys.argv[1:] + append_args, stderr=f) + if ret != 0: sys.exit(ret) if output_type in ['executable', 'shared']: push_to_device(output) + hdc(['shell', 'chmod', '+x', host_to_device_path(output)]) if output_type == 'executable': os.rename(output, output + '.real') diff --git a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py index 84a8d9fb709c..c53c94c46ce9 100755 --- a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py +++ b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import os, signal, sys, subprocess import re @@ -8,10 +8,28 @@ device_binary = host_to_device_path(sys.argv[0]) def build_env(): args = [] + sanitizers = ( + 'HWASAN', 'ASAN', 'LSAN', 'MEMPROF', 'MSAN', 'TSAN', 'UBSAN', 'SCUDO' + ) + for san in sanitizers: + # for all sanitizers we need 'abort_on_error=0', + # so prepare key for them, to set value later + opt_str = '%s_OPTIONS' % san + if opt_str not in os.environ: + os.environ[opt_str] = '' + + # All sanitizers need external symbolizers for some tests + # set them by default to llvm-symbolizer + symb_name = '%s_SYMBOLIZER_PATH' % san + args.append('%s=%s' % (symb_name, os.environ.get('LLVM_SYMBOLIZER_PATH', + os.path.join(hdc_constants.TMPDIR,'llvm-symbolizer-aarch64')))) # HOS linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir. - args.append('LD_LIBRARY_PATH=%s' % (HOS_TMPDIR,)) + args.append('LD_LIBRARY_PATH=%s' % ( hdc_constants.TMPDIR,)) for (key, value) in os.environ.items(): - if key in ['ASAN_ACTIVATION_OPTIONS', 'SCUDO_OPTIONS'] or key.endswith('SAN_OPTIONS'): + san_opt = key.endswith('SAN_OPTIONS') + if san_opt: + value += ':abort_on_error=0' + if key in ['ASAN_ACTIVATION_OPTIONS', 'SCUDO_OPTIONS'] or san_opt: args.append('%s="%s"' % (key, value)) return ' '.join(args) @@ -22,11 +40,12 @@ device_stderr = device_binary + '.stderr' device_exitcode = device_binary + '.exitcode' device_linker = '' -ret = adb(['shell', 'cd %s && %s %s %s %s >%s 2>%s ; echo $? >%s' % - (HOS_TMPDIR, device_env, device_linker, device_binary, device_args, - device_stdout, device_stderr, device_exitcode)]) -if ret != 0: - sys.exit(ret) +# Currently OHOS set log_path in UBSAN_OPTIONS +# Tests expects to see output in stdout/stderr and fails when it is not there +# So unset UBSAN_OPTIONS before run tests. +hdc(['shell', 'unset UBSAN_OPTIONS && cd %s && %s %s %s %s >%s 2>%s ; echo $? >%s' % + (hdc_constants.TMPDIR, device_env, device_linker, device_binary, device_args, + device_stdout, device_stderr, device_exitcode)]) sys.stdout.write(pull_from_device(device_stdout)) sys.stderr.write(pull_from_device(device_stderr)) diff --git a/compiler-rt/test/scudo/lit.cfg.py b/compiler-rt/test/scudo/lit.cfg.py index 236d645f3b94..60cdeb65bd50 100644 --- a/compiler-rt/test/scudo/lit.cfg.py +++ b/compiler-rt/test/scudo/lit.cfg.py @@ -45,7 +45,7 @@ config.substitutions.append(("%shared_minlibscudo", shared_minlibscudo)) # Platform-specific default SCUDO_OPTIONS for lit tests. default_scudo_opts = '' -if config.android: +if config.android or config.host_os == 'OHOS': # OHOS_LOCAL # Android defaults to abort_on_error=1, which doesn't work for us. default_scudo_opts = 'abort_on_error=0' @@ -59,6 +59,6 @@ if default_scudo_opts: config.substitutions.append(('%env_scudo_opts=', 'env SCUDO_OPTIONS=' + default_scudo_opts)) -# Hardened Allocator tests are currently supported on Linux only. -if config.host_os not in ['Linux']: +# Hardened Allocator tests are currently supported on Linux and OHOS only. +if config.host_os not in ['Linux', 'OHOS']: # OHOS_LOCAL config.unsupported = True diff --git a/compiler-rt/test/scudo/malloc.cpp b/compiler-rt/test/scudo/malloc.cpp index afa7ee47c03b..e0ba5deace3e 100644 --- a/compiler-rt/test/scudo/malloc.cpp +++ b/compiler-rt/test/scudo/malloc.cpp @@ -11,6 +11,12 @@ #include +// OHOS_LOCAL begin +#ifdef __OHOS__ +#include +#endif +// OHOS_LOCAL end + int main(int argc, char **argv) { void *p; std::vector sizes{1, 8, 16, 32, 1024, 32768, diff --git a/compiler-rt/test/scudo/overflow.c b/compiler-rt/test/scudo/overflow.c index 7df9f8ba3534..8c0d797cc086 100644 --- a/compiler-rt/test/scudo/overflow.c +++ b/compiler-rt/test/scudo/overflow.c @@ -8,6 +8,12 @@ #include #include +// OHOS_LOCAL begin +#ifdef __OHOS__ +#include +#endif +// OHOS_LOCAL end + int main(int argc, char **argv) { ssize_t offset = sizeof(void *) == 8 ? 8 : 0; -- Gitee From 1302f071d4be91f9a31544d460d7d741b28a9c80 Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Fri, 9 Feb 2024 16:06:57 +0300 Subject: [PATCH 2/2] [compiler-rt] TMP: disable not working tests and runtimes Disable scudo-standalone build and its dependecies until https://gitee.com/openharmony/third_party_musl/pulls/1094 is merged Also disable scudo and gwp-asan for arm and mips More info here: https://gitee.com/openharmony/third_party_llvm-project/issues/I91GO7 Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/I8PGWS Change-Id: Ibb90c86e38ab14d5226e088d344564661f9db715 Signed-off-by: Sukhikh Alexander --- compiler-rt/cmake/config-ix.cmake | 1 + compiler-rt/lib/CMakeLists.txt | 18 +++++++++++++++--- compiler-rt/test/CMakeLists.txt | 18 ++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index a549732afea0..ac88d54ccfd2 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -814,6 +814,7 @@ else() endif() #TODO(kostyak): add back Android & Fuchsia when the code settles a bit. +# TODO: Add OHOS when https://gitee.com/openharmony/third_party_musl/pulls/1235 is merged if (SCUDO_STANDALONE_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux" AND COMPILER_RT_HAS_AUXV) set(COMPILER_RT_HAS_SCUDO_STANDALONE TRUE) diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index 18eed2446dc6..678bc03a8df2 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -28,9 +28,11 @@ function(compiler_rt_build_runtime runtime) if(${runtime} STREQUAL tsan) add_subdirectory(tsan/dd) endif() - if(${runtime} STREQUAL scudo) - add_subdirectory(scudo/standalone) - endif() + # Disable standalone scudo until this PR merged + # https://gitee.com/openharmony/third_party_musl/pulls/1235/files + # if(${runtime} STREQUAL scudo) + # add_subdirectory(scudo/standalone) + # endif() endif() endfunction() @@ -38,6 +40,16 @@ if(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_MEMPROF) compiler_rt_build_runtime(interception) endif() +# OHOS_LOCAL begin +if(COMPILER_RT_DEFAULT_TARGET_TRIPLE MATCHES "arm-linux-ohos|mipsel-linux-ohos") + # temporary disable scudo and gwp_asan for arm + # arm scudo build failed due to the abcsence of the `_aeabi_unwind_cpp_pr1` symbol + # on mipsel -latomic is not found. + # gwp_asan depends on scudo + list(REMOVE_ITEM COMPILER_RT_SANITIZERS_TO_BUILD "scudo" "gwp_asan") +endif() +# OHOS_LOCAL end + if(COMPILER_RT_BUILD_SANITIZERS) if(COMPILER_RT_HAS_SANITIZER_COMMON) add_subdirectory(stats) diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt index 3cbfc4b0e544..e23d48147834 100644 --- a/compiler-rt/test/CMakeLists.txt +++ b/compiler-rt/test/CMakeLists.txt @@ -58,6 +58,16 @@ function(compiler_rt_test_runtime runtime) endif() endfunction() +# OHOS_LOCAL begin +if(COMPILER_RT_DEFAULT_TARGET_TRIPLE MATCHES "arm-linux-ohos|mipsel-linux-ohos") + # temporary disable scudo and gwp_asan for arm + # arm scudo build failed due to the abcsence of the `_aeabi_unwind_cpp_pr1` symbol + # on mipsel -latomic is not found. + # gwp_asan depends on scudo + list(REMOVE_ITEM COMPILER_RT_SANITIZERS_TO_BUILD "scudo" "gwp_asan") +endif() +# OHOS_LOCAL end + # Run sanitizer tests only if we're sure that clang would produce # working binaries. if(COMPILER_RT_CAN_EXECUTE_TESTS) @@ -79,9 +89,13 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS) foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD}) # cfi testing is gated on ubsan - if(NOT ${sanitizer} STREQUAL cfi) - compiler_rt_test_runtime(${sanitizer}) + # OHOS_LOCAL begin + # can't test gwp-asan, because it is depends on scudo-standalone + if(NOT ${sanitizer} STREQUAL cfi AND + NOT ${sanitizer} STREQUAL gwp_asan) + compiler_rt_test_runtime(${sanitizer}) endif() + # OHOS_LOCAL end endforeach() endif() if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) -- Gitee