From fd60fabdf3ee0674e38bda7adbb4bf72906942a2 Mon Sep 17 00:00:00 2001 From: liuweili Date: Fri, 29 Nov 2024 09:48:27 +0800 Subject: [PATCH] =?UTF-8?q?v8=E5=AF=B9=E6=8E=A5hilog=20=EF=BC=88cherry=20p?= =?UTF-8?q?icked=20commit=20from=20=20Signed-of?= =?UTF-8?q?f-by:=20liuweili=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gni/v8.gni | 2 +- src/base/platform/platform-posix.cc | 9 +++++++++ v8_shared/BUILD.gn | 19 +++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gni/v8.gni b/gni/v8.gni index 77ae6f1e1..8332ae9bc 100644 --- a/gni/v8.gni +++ b/gni/v8.gni @@ -216,7 +216,7 @@ v8_add_configs = [ ] v8_add_configs_shared = [ - v8_path_prefix + ":toolchain", + v8_path_prefix + "v8_shared:toolchain_shared", ] if (is_debug && !v8_optimized_debug) { diff --git a/src/base/platform/platform-posix.cc b/src/base/platform/platform-posix.cc index 1e8baca71..e5431fd76 100644 --- a/src/base/platform/platform-posix.cc +++ b/src/base/platform/platform-posix.cc @@ -42,6 +42,11 @@ #include "src/base/platform/time.h" #include "src/base/utils/random-number-generator.h" +#ifdef USING_OHOS +#include "src/utils/hilog.h" +#define HILOG_MAXSIZE 4096 +#endif + #ifdef V8_FAST_TLS_SUPPORTED #include #endif @@ -987,6 +992,10 @@ void OS::PrintError(const char* format, ...) { void OS::VPrintError(const char* format, va_list args) { #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args); +#elif defined(USING_OHOS) + char buffer[HILOG_MAXSIZE]; + (void)VSNPrintF(buffer, HILOG_MAXSIZE, format, args); + HilogPrint(ERROR, "%{public}s", buffer); #else vfprintf(stderr, format, args); #endif diff --git a/v8_shared/BUILD.gn b/v8_shared/BUILD.gn index 260b30fec..d70b3d6f6 100644 --- a/v8_shared/BUILD.gn +++ b/v8_shared/BUILD.gn @@ -1140,10 +1140,7 @@ config("v8_features_shared") { } } -config("toolchain") { - # Only targets in this file and its subdirs can depend on this. - visibility = [ "./*" ] - +config("toolchain_shared") { defines = [] cflags = [] ldflags = [] @@ -1350,8 +1347,6 @@ config("toolchain") { defines += [ "ENABLE_VERIFY_CSA" ] } - v8_enable_runtime_call_stats = true - if (v8_enable_runtime_call_stats) { defines += [ "V8_RUNTIME_CALL_STATS" ] } @@ -1398,6 +1393,18 @@ config("toolchain") { ] } + if (is_ohos) { + cflags += [ + "-flto", + "-fomit-frame-pointer" + ] + ldflags += [ "-flto" ] + import("//ohos_sdk/ohos_sdk.gni") + ldflags += [ "../../ohos_sdk/native/$ohos_sdk_version/sysroot/usr/lib/aarch64-linux-ohos/libhilog_ndk.z.so" ] + include_dirs = [ "../../ohos_sdk/native/$ohos_sdk_version/sysroot/usr/include/hilog" ] + defines += [ "USING_OHOS" ] + } + if (is_win) { cflags += [ "/wd4245", # Conversion with signed/unsigned mismatch. -- Gitee