diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index 2fd934299e411f3f9e4cca6b791354158cfd1e29..878b9fecbd6b0a59b0aadb57f6f1edb4d1648165 100644 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -162,6 +162,11 @@ class ArkPy: "Add --gn-args=\"run_with_qemu=true\" to command when running unittest of non-host type with qemu.", "gn_targets_depend_on": ["unittest_packages"], }, + "workload": { + "flags": ["workload", "work-load", "work_load"], + "description": "Compile arkcompiler target and run workload with arkcompiler target.", + "gn_targets_depend_on": ["default"], + }, "gn_target": { "flags": [""], # any other flags "description": @@ -304,7 +309,7 @@ class ArkPy: # Command template help_msg += "\033[32mCommand template:\033[0m\n{}\n\n".format( " python3 ark.py \033[92m[os_cpu].[mode] [gn_target] [option]\033[0m\n" - " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --aot] [none, file or dir] [option]\033[0m\n" + " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --aot] [none or --pgo] [none, file or dir] [option]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [unittest] [option]\033[0m") # Command examples help_msg += "\033[32mCommand examples:\033[0m\n{}\n\n".format( @@ -313,7 +318,7 @@ class ArkPy: " python3 ark.py \033[92mx64.release ark_js_vm es2panda\033[0m\n" " python3 ark.py \033[92mx64.release ark_js_vm es2panda --clean\033[0m\n" " python3 ark.py \033[92mx64.release test262\033[0m\n" - " python3 ark.py \033[92mx64.release test262 --aot\033[0m\n" + " python3 ark.py \033[92mx64.release test262 --aot --pgo\033[0m\n" " python3 ark.py \033[92mx64.release test262 built-ins/Array\033[0m\n" " python3 ark.py \033[92mx64.release test262 built-ins/Array/name.js\033[0m\n" " python3 ark.py \033[92mx64.release unittest\033[0m") @@ -370,7 +375,7 @@ class ArkPy: print("=== ninja success! ===\n") return - def build_for_test262(self, out_path, gn_args: list, arg_list: list, log_file_name: str, aot_mode: bool): + def build_for_test262(self, out_path, gn_args: list, arg_list: list, log_file_name: str, aot_mode: bool, run_pgo=False): args_to_test262_cmd = "" if len(arg_list) == 0: args_to_test262_cmd = "--es2021 all" @@ -382,19 +387,59 @@ class ArkPy: else: print("\033[92m\"test262\" not support multiple additional arguments.\033[0m\n".format()) sys.exit(0) + + if any('target_cpu="arm64"' in arg for arg in gn_args): + if 'release' in out_path: + x64_out_path = 'out/x64.release' + if 'debug' in out_path: + x64_out_path = 'out/x64.debug' + gn_args.append("so_dir_for_qemu=\"../../{0}/common/common/libc/\"".format(out_path)) + gn_args.append("run_with_qemu=true".format(out_path)) + if not os.path.exists(x64_out_path): + os.makedirs(x64_out_path) + self.build_for_gn_target( + x64_out_path, ['target_os="linux"', 'target_cpu="x64"', 'is_debug=false'], + self.ARG_DICT["target"]["test262"]["gn_targets_depend_on"], log_file_name) + self.build_for_gn_target( out_path, gn_args, self.ARG_DICT["target"]["test262"]["gn_targets_depend_on"], log_file_name) - + if aot_mode: print("running test262 in AotMode\n") - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout 180000" \ + if any('target_cpu="arm64"' in arg for arg in gn_args): + if run_pgo: + test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout 180000" \ + " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu:../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + " --ark-arch aarch64" \ + " --ark-arch-root=../../{1}/common/common/libc/" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-aot" \ + " --ark-frontend=es2panda"\ + "{3}".format(args_to_test262_cmd, out_path, x64_out_path, " --run-pgo") + else: + test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout 180000" \ + " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{2}/thirdparty/icu/" \ + " --ark-arch aarch64" \ + " --ark-arch-root=../../{1}/common/common/libc/" \ + " --ark-aot" \ + " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path) + else: + test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout 180000" \ " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu:../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ " --ark-aot" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path) + " --ark-frontend=es2panda"\ + "{2}".format(args_to_test262_cmd, out_path, " --run-pgo" if run_pgo else "") else: print("running test262 in AsmMode\n") test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout 180000" \ @@ -430,7 +475,10 @@ class ArkPy: self.build_for_gn_target(out_path, gn_args, ["default"], self.GN_TARGET_LOG_FILE_NAME) elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["test262"], arg_list[0]): if len(arg_list) >= 2 and arg_list[1] == "--aot": - self.build_for_test262(out_path, gn_args, arg_list[2:], self.TEST262_LOG_FILE_NAME, True) + if len(arg_list) >= 3 and arg_list[2] == "--pgo": + self.build_for_test262(out_path, gn_args, arg_list[3:], self.TEST262_LOG_FILE_NAME, True, True) + else: + self.build_for_test262(out_path, gn_args, arg_list[2:], self.TEST262_LOG_FILE_NAME, True) else: self.build_for_test262(out_path, gn_args, arg_list[1:], self.TEST262_LOG_FILE_NAME, False) elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["unittest"], arg_list[0]): diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 36caf1fcd93ceaf5a910c09b8ea0aeecc567f6ef..6480c6c4eef9381f87b8122bfed252b8af1b41bd 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -16,6 +16,7 @@ declare_args() { use_musl = true build_root = "//arkcompiler/toolchain/build" run_with_qemu = false + so_dir_for_qemu = "common/common/libc" enable_lto_O0 = false } diff --git a/build/config/ohos/config.gni b/build/config/ohos/config.gni index 97efcd47f207f04259f5925a223d5d34e3a38ae3..1da4bc2f34ba46f5169bac7ff7c17a0cac024247 100644 --- a/build/config/ohos/config.gni +++ b/build/config/ohos/config.gni @@ -30,4 +30,5 @@ if (is_ohos) { } libclang_rt_file = "${clang_base_path}/lib/clang/15.0.4/lib/${abi_target}/libclang_rt.builtins.a" libcxxabi_file = "${clang_base_path}/lib/${abi_target}/libc++abi.a" + libcxxso_file = "${clang_base_path}/lib/${abi_target}/libc++.so" } diff --git a/build/third_party_gn/bounds_checking_function/BUILD.gn b/build/third_party_gn/bounds_checking_function/BUILD.gn index e5b1510121b76f2f276a78d9237a7edf083c8f95..bdf5b5648ed6b37c1d4963d3f846a87be1308a5e 100644 --- a/build/third_party_gn/bounds_checking_function/BUILD.gn +++ b/build/third_party_gn/bounds_checking_function/BUILD.gn @@ -33,6 +33,9 @@ ohos_static_library("libsec_static") { ] } +SEC_SHARED_SUBSYS_NAME = "thirdparty" +SEC_SHARED_PART_NAME = "bounds_checking_function" + ohos_shared_library("libsec_shared") { stack_protector_ret = false sources = libsec_sources @@ -46,10 +49,19 @@ ohos_shared_library("libsec_shared") { "-D_INC_STDLIB_S", "-D_INC_MEMORY_S", ] - part_name = "bounds_checking_function" - subsystem_name = "thirdparty" + + part_name = "${SEC_SHARED_PART_NAME}" + subsystem_name = "${SEC_SHARED_SUBSYS_NAME}" install_images = [ "system", "updater", ] } +if (is_ohos && run_with_qemu) { + copy("libsec_shared_for_qemu") { + deps = [ ":libsec_shared" ] + + sources = [ "${root_out_dir}/${SEC_SHARED_SUBSYS_NAME}/${SEC_SHARED_PART_NAME}/libsec_shared.so" ] + outputs = [ "${root_out_dir}/${so_dir_for_qemu}/lib/libsec_shared.so" ] + } +} diff --git a/build/third_party_gn/musl/musl_template.gni b/build/third_party_gn/musl/musl_template.gni index a3ceff55c049af3492b20e0edf62b7bbc519a735..21f5dd2c10f19c62b0f37623336aad1a4ad6704f 100644 --- a/build/third_party_gn/musl/musl_template.gni +++ b/build/third_party_gn/musl/musl_template.gni @@ -27,7 +27,7 @@ musl_linker_so_out_dir = "${root_out_dir}/common/common/libc/${_libs_path_prefix}" musl_linker_so_out_path = "${musl_linker_so_out_dir}/ld-musl-${musl_arch}${asan}.so.1" -musl_linker_so_out_dir_for_qemu = "${musl_linker_so_out_dir}/lib" +musl_linker_so_out_dir_for_qemu = "${root_out_dir}/${so_dir_for_qemu}/lib" musl_linker_so_out_path_for_qemu = "${musl_linker_so_out_dir_for_qemu}/ld-musl-${musl_arch}${asan}.so.1"