From 674bb74dd40615ba887339e24c5c437662f28d99 Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Wed, 30 Apr 2025 22:08:10 +0800 Subject: [PATCH] modify of hybrid-vm Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IC5IIB Change-Id: I0394f393749eb4bd2aeb181c351f77d89f9b49bc Signed-off-by: wengchangcheng --- BUILD.gn | 23 +++++++++++++++++++ build/compile_script/ark.py | 30 ++++++++++++++++--------- build/config/BUILDCONFIG.gn | 2 ++ build/core/gn/BUILD.gn | 13 +++++++++-- tooling/client/ark_multi/main.cpp | 1 + tooling/test/BUILD.gn | 5 ++++- tooling/test/client_utils/test_list.cpp | 10 +++++++-- 7 files changed, 68 insertions(+), 16 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 40bf3889..9226c047 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -189,11 +189,34 @@ config("ark_toolchain_common_config") { } else { defines += [ "NDEBUG" ] } + + if (defined(enable_cmc_gc) && enable_cmc_gc) { + defines += [ "USE_CMC_GC" ] + defines += [ "USE_READ_BARRIER" ] + } } config("ark_toolchain_public_config") { defines = [] + if (defined(enable_cmc_gc) && enable_cmc_gc) { + cflags_cc = [ + "-Wno-unused-command-line-argument", + "-Wno-variadic-macros", + "-Wno-gnu-anonymous-struct", + "-Wno-zero-length-array", + "-Wno-nested-anon-types", + "-Wno-c99-extensions", + "-Wno-unused-parameter", + "-Wno-shadow", + "-Wno-pedantic", + "-Wno-gnu-zero-variadic-macro-arguments", + "-Wno-unused-lambda-capture", + "-Wno-unused-function", + "-Wno-unused-variable", + ] + } + # debug is not compatible with ios for now if (!is_mingw && !is_mac && target_os != "ios") { defines += [ diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index 60035a4c..9c360092 100755 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -279,6 +279,10 @@ class ArkPy: "description": "Keep running unittest etc. until errors occured less than N times" " (use 0 to ignore all errors).", }, + "fast-rebuild": { + "flags": ["--fast-rebuild", "-fast-rebuild"], + "description": "Skip gn gen when not modify gn file", + }, }, "help": { "flags": ["help", "--help", "--h", "-help", "-h"], @@ -295,6 +299,7 @@ class ArkPy: enable_verbose = False enable_keepdepfile = False ignore_errors = 1 + fast_rebuild = False def __main__(self, arg_list: list): enable_ccache() @@ -828,15 +833,18 @@ class ArkPy: _write(build_log_path, str_to_build_log, "a") # gn command print("=== gn gen start ===") - code = call_with_output( - "{0} gen {1} --args=\"{2}\" --export-compile-commands".format( - self.gn_binary_path, out_path, " ".join(gn_args).replace("\"", "\\\"")), - build_log_path) - if code != 0: - print("=== gn gen failed! ===\n") - sys.exit(code) + if self.fast_rebuild: + print("=== skip gn gen ===") else: - print("=== gn gen success! ===\n") + code = call_with_output( + "{0} gen {1} --args=\"{2}\" --export-compile-commands".format( + self.gn_binary_path, out_path, " ".join(gn_args).replace("\"", "\\\"")), + build_log_path) + if code != 0: + print("=== gn gen failed! ===\n") + sys.exit(code) + else: + print("=== gn gen success! ===\n") # ninja command # Always add " -d keeprsp" to ninja command to keep response file("*.rsp"), thus we could get shared libraries # of an excutable from its response file. @@ -1015,9 +1023,6 @@ class ArkPy: elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("test262"), arg_list[0]): self.build_for_test262(out_path, gn_args, arg_list) elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("unittest"), arg_list[0]): - if len(arg_list) > 1: - print("\033[92m\"unittest\" not support additional arguments.\033[0m\n".format()) - sys.exit(0) self.build_for_unittest(out_path, gn_args, self.UNITTEST_LOG_FILE_NAME) elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("runtime_core_unittest"), arg_list[0]): if len(arg_list) > 1: @@ -1074,6 +1079,9 @@ class ArkPy: input_value )) sys.exit(0) + # match [option][fast-rebuild] flag + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("fast-rebuild"), arg): + self.fast_rebuild = True # make a new list with flag that do not match any flag in [option] else: arg_list_ret.append(arg) diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 6f9d1fbf..1b0b1cdb 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -12,6 +12,7 @@ # limitations under the License. declare_args() { ark_standalone_build = true + ark_hybrid = false use_musl = true build_root = "//arkcompiler/toolchain/build" run_with_qemu = false @@ -19,6 +20,7 @@ declare_args() { enable_lto_O0 = false disable_force_gc = false timeout = 1200 + enable_cmc_gc = false } check_mac_system_and_cpu_script = diff --git a/build/core/gn/BUILD.gn b/build/core/gn/BUILD.gn index d91c7f3c..3541be9c 100644 --- a/build/core/gn/BUILD.gn +++ b/build/core/gn/BUILD.gn @@ -101,7 +101,12 @@ group("static_core") { deps += [ "$ark_root/static_core/static_linker:static_linker" ] } if (target_os != "mingw" && target_os != "mac") { - deps += [ "$ark_root/static_core/runtime:libarkruntime" ] + if (ark_hybrid) { + deps += [ "$js_root:libark_jsruntime" ] + } else { + deps += [ "$ark_root/static_core/runtime:libarkruntime" ] + } + } } @@ -109,7 +114,6 @@ group("hybrid") { deps = [ ":ets_frontend", ":ets_runtime", - ":static_core", "$ark_root/static_core/plugins/ets:etsstdlib(${host_toolchain})", ] if (target_os != "mingw" && target_os != "mac") { @@ -118,6 +122,11 @@ group("hybrid") { "$ark_root/static_core/tools/ark_js_napi_cli:ark_js_napi_cli", ] } + + if (!ark_hybrid) { + deps += [ ":static_core" ] + } + } group("toolchain") { diff --git a/tooling/client/ark_multi/main.cpp b/tooling/client/ark_multi/main.cpp index 0cf44374..20dab54c 100644 --- a/tooling/client/ark_multi/main.cpp +++ b/tooling/client/ark_multi/main.cpp @@ -16,6 +16,7 @@ #include #include "ecmascript/js_runtime_options.h" +#include "ecmascript/napi/include/jsnapi_expo.h" #include "ecmascript/platform/file.h" #include "tooling/utils/utils.h" #ifdef PANDA_TARGET_MACOS diff --git a/tooling/test/BUILD.gn b/tooling/test/BUILD.gn index 46dd78d9..a9fe03da 100644 --- a/tooling/test/BUILD.gn +++ b/tooling/test/BUILD.gn @@ -223,13 +223,16 @@ host_unittest_action("DebuggerTest") { # hiviewdfx libraries external_deps = hiviewdfx_ext_deps + # libuv should be before libark_jsruntime + # because there are libuv weak symbols in libark_jsruntime + # and libuv should be loaded before their resolution + external_deps += [ "libuv:uv" ] external_deps += [ "bounds_checking_function:libsec_shared", "cJSON:cjson", "ets_runtime:libark_jsruntime", "icu:shared_icui18n", "icu:shared_icuuc", - "libuv:uv", "runtime_core:libarkbase_static", ] deps += hiviewdfx_deps diff --git a/tooling/test/client_utils/test_list.cpp b/tooling/test/client_utils/test_list.cpp index 24e7883d..f261ce16 100644 --- a/tooling/test/client_utils/test_list.cpp +++ b/tooling/test/client_utils/test_list.cpp @@ -90,8 +90,11 @@ static void RegisterTests() TestUtil::RegisterTest("JsSourceTest", GetJsSourceTest()); TestUtil::RegisterTest("JsTracingTest", GetJsTracingTest()); TestUtil::RegisterTest("JsWatchTest", GetJsWatchTest()); +#ifndef USE_CMC_GC + // TODO: Need support heapdump TestUtil::RegisterTest("JsHeapdumpTest", GetJsHeapdumpTest()); - TestUtil::RegisterTest("JsAllocationtrackTest", GetJsAllocationtrackTest()); + TestUtil::RegisterTest("JsHeapdumpLoopTest", GetJsHeapdumpLoopTest()); +#endif TestUtil::RegisterTest("JsStepintoTest", GetJsStepintoTest()); TestUtil::RegisterTest("JsStepoutTest", GetJsStepoutTest()); TestUtil::RegisterTest("JsStepoverTest", GetJsStepoverTest()); @@ -110,9 +113,12 @@ static void RegisterTests() TestUtil::RegisterTest("JsHeapusageTest", GetJsHeapusageTest()); TestUtil::RegisterTest("JsHeapusageAsyncTest", GetJsHeapusageAsyncTest()); TestUtil::RegisterTest("JsHeapusageStepTest", GetJsHeapusageStepTest()); - TestUtil::RegisterTest("JsHeapdumpLoopTest", GetJsHeapdumpLoopTest()); +#ifndef USE_CMC_GC + // TODO: Need support allocation tracker + TestUtil::RegisterTest("JsAllocationtrackTest", GetJsAllocationtrackTest()); TestUtil::RegisterTest("JsAllocationTrackLoopTest", GetJsAllocationTrackLoopTest()); TestUtil::RegisterTest("JsAllocationTrackRecursionTest", GetJsAllocationTrackRecursionTest()); +#endif TestUtil::RegisterTest("JsJsWatchBasicTypeTest", GetJsWatchBasicTypeTest()); TestUtil::RegisterTest("JsJsWatchSetTypeTest", GetJsWatchSetTypeTest()); TestUtil::RegisterTest("JsJsWatchOtherTypeTest", GetJsWatchOtherTypeTest()); -- Gitee