From 81b9caea9a74e34dd75751b5d3e43091f5ccf14c Mon Sep 17 00:00:00 2001 From: Lyupa Anastasia Date: Wed, 29 Mar 2023 15:46:25 +0300 Subject: [PATCH 1/2] [OHOS] Fix using of ohos compile wrapper Strip wrapper from config.clang when get libs in crt. Define %device_rundir, %push_to_device, %adb_shell, %device_rm. Update ohos compile wrapper to python3 compatibility. Signed-off-by: Lyupa Anastasia --- compiler-rt/test/crt/lit.cfg.py | 7 +++---- compiler-rt/test/lit.common.cfg.py | 13 +++++++++++++ .../ohos_family_commands/ohos_common.py | 10 ++++++---- .../ohos_family_commands/ohos_compile.py | 4 ++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/compiler-rt/test/crt/lit.cfg.py b/compiler-rt/test/crt/lit.cfg.py index c8d59edf5eba..079937ac7053 100644 --- a/compiler-rt/test/crt/lit.cfg.py +++ b/compiler-rt/test/crt/lit.cfg.py @@ -23,7 +23,7 @@ else: execute_external = (not sys.platform in ['win32']) def get_library_path(file): - cmd = subprocess.Popen([config.clang.strip(), + cmd = subprocess.Popen([config.clang.split()[-1].strip(), # OHOS_LOCAL '-print-file-name=%s' % file] + shlex.split(config.target_cflags), stdout=subprocess.PIPE, @@ -39,7 +39,7 @@ def get_library_path(file): def get_libgcc_file_name(): - cmd = subprocess.Popen([config.clang.strip(), + cmd = subprocess.Popen([config.clang.split()[-1].strip(), # OHOS_LOCAL '-print-libgcc-file-name'] + shlex.split(config.target_cflags), stdout=subprocess.PIPE, @@ -55,8 +55,7 @@ def get_libgcc_file_name(): def build_invocation(compile_flags): - # OHOS_LOCAL - return ' ' + ' '.join([config.compile_wrapper, config.clang] + compile_flags) + ' ' + return ' ' + ' '.join([config.clang] + compile_flags) + ' ' # Setup substitutions. diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index a49c3c0bbfde..4c43a0b0143e 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -518,6 +518,19 @@ if config.android: subprocess.check_call([adb, "shell", "mkdir", "-p", android_tmpdir], env=env) for file in config.android_files_to_push: subprocess.check_call([adb, "push", file, android_tmpdir], env=env) +# OHOS_LOCAL begin + +elif config.host_os == 'OHOS': + 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) + +# OHOS_LOCAL end else: config.substitutions.append( ('%device_rundir/', "") ) config.substitutions.append( ('%push_to_device', "echo ") ) 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 da6e6b9d2fd4..d4a94c03a654 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,3 +1,5 @@ +#!/usr/bin/env python3 + import os, subprocess, tempfile HOS_TMPDIR = '/data/local/tmp/Output' @@ -14,7 +16,7 @@ def host_to_device_path(path): def adb(args, attempts = 1): if verbose: - print args + print (args) tmpname = tempfile.mktemp() out = open(tmpname, 'w') ret = 255 @@ -24,11 +26,11 @@ def adb(args, attempts = 1): if attempts != 0: ret = 5 if ret != 0: - print "adb command failed", args - print tmpname + print ("adb command failed", args) + print (tmpname) out.close() out = open(tmpname, 'r') - print out.read() + print (out.read()) out.close() os.unlink(tmpname) return ret 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 3a4769a5196b..265a4a9f8f09 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 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import os, sys, subprocess from ohos_common import * @@ -37,7 +37,7 @@ while args: append_args += ['-Wl,--dynamic-linker=' + os.path.join(HOS_TMPDIR, dyld)] if output == None: - print "No output file name!" + print ("No output file name!") sys.exit(1) ret = subprocess.call(sys.argv[1:] + append_args) -- Gitee From c1fa1885c30b26db98be36e5a626c103fbbf5484 Mon Sep 17 00:00:00 2001 From: Lyupa Anastasia Date: Tue, 4 Apr 2023 15:47:14 +0300 Subject: [PATCH 2/2] [compiler-rt][OHOS] Update crt test Run dlclose_ubsan_standalone test for OHOS only Signed-off-by: Lyupa Anastasia --- compiler-rt/test/crt/dlclose_ubsan_standalone.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler-rt/test/crt/dlclose_ubsan_standalone.cpp b/compiler-rt/test/crt/dlclose_ubsan_standalone.cpp index 65046cbe5893..2b9d276ffcd8 100644 --- a/compiler-rt/test/crt/dlclose_ubsan_standalone.cpp +++ b/compiler-rt/test/crt/dlclose_ubsan_standalone.cpp @@ -5,6 +5,7 @@ // RUN: %clangxx %s -DRT=\"%device_rundir/libclang_rt.ubsan_standalone.so\" -o %t -ldl // RUN: %push_to_device %shared_ubsan_standalone %device_rundir/libclang_rt.ubsan_standalone.so // RUN: %run %t 2>&1 | FileCheck %s +// REQUIRES: ohos_family #include #include -- Gitee