diff --git a/gni/v8.gni b/gni/v8.gni index 77ae6f1e149691c72f818ee4615bb50cb8f36844..8332ae9bceede26159106454c81b8a064a5689a4 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 1e8baca714daebd87b55f2c6792a301623d27ecf..e5431fd762c9afeaf19a0142e3b797af555173a9 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 260b30fec43e4795683ec86a00f256e0358cb1d9..d70b3d6f6e6ac9648e09e8adfe6c5cdd2083f28b 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.