Fix builtins.d.abc option when target compilation

Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I79KE5?from=project-issue
Signed-off-by: zhangyukun <zhangyukun8@huawei.com>

Change-Id: If95c812213e42c6e3c510be0e36d435314a2d190
This commit is contained in:
zhangyukun 2023-05-30 20:38:41 +08:00
parent 7117a0611e
commit cd8e0d43bc
5 changed files with 36 additions and 20 deletions

View File

@ -907,6 +907,9 @@ ohos_source_set("libark_jsruntime_set") {
rebase_path("$root_gen_dir/arkcompiler/ets_runtime/stub.an")
}
defines = [ "STUB_AN_FILE=\"${stub_an_file_path}\"" ]
target_builtins_dts_path =
"/system/lib64/${arkcompiler_relative_lib_path}/lib_ark_builtins.d.abc"
defines += [ "TARGET_BUILTINS_DTS_PATH=\"${target_builtins_dts_path}\"" ]
sources = ecma_source
sources += ecma_profiler_source
@ -981,6 +984,10 @@ ohos_source_set("libark_jsruntime_test_set") {
rebase_path("$root_gen_dir/arkcompiler/ets_runtime/stub.an")
}
defines += [ "STUB_AN_FILE=\"${stub_an_file_path}\"" ]
target_builtins_dts_path =
"/system/lib64/${arkcompiler_relative_lib_path}/lib_ark_builtins.d.abc"
defines += [ "TARGET_BUILTINS_DTS_PATH=\"${target_builtins_dts_path}\"" ]
deps = [
"$ark_third_party_root/icu/icu4c:shared_icui18n",
"$ark_third_party_root/icu/icu4c:shared_icuuc",

View File

@ -407,10 +407,6 @@ ohos_executable("ark_aot_compiler") {
]
}
target_builtins_dts_path =
"/system/lib64/${arkcompiler_relative_lib_path}/lib_ark_builtins.d.abc"
defines = [ "TARGET_BUILTINS_DTS_PATH=\"${target_builtins_dts_path}\"" ]
# hiviewdfx libraries
external_deps += hiviewdfx_ext_deps
deps += hiviewdfx_deps

View File

@ -127,6 +127,7 @@ int Main(const int argc, const char **argv)
// ark_aot_compiler running need disable asm interpreter to disable the loading of AOT files.
runtimeOptions.SetEnableAsmInterpreter(false);
runtimeOptions.DisableReportModuleResolvingFailure();
runtimeOptions.SetOptionsForTargetCompilation();
EcmaVM *vm = JSNApi::CreateEcmaVM(runtimeOptions);
if (vm == nullptr) {
LOG_COMPILER(ERROR) << "Cannot Create vm";
@ -138,22 +139,6 @@ int Main(const int argc, const char **argv)
std::string delimiter = GetFileDelimiter();
arg_list_t pandaFileNames = base::StringHelper::SplitString(files, delimiter);
if (runtimeOptions.IsTargetCompilerMode()) {
runtimeOptions.SetTargetTriple("aarch64-unknown-linux-gnu");
runtimeOptions.WasSet(CommandValues::OPTION_BUILTINS_DTS);
std::string builtinsDtsPath = TARGET_BUILTINS_DTS_PATH;
runtimeOptions.SetBuiltinsDTS(builtinsDtsPath);
if (runtimeOptions.IsPartialCompilerMode()) {
runtimeOptions.SetEnableOptPGOType(true);
if (runtimeOptions.IsPGOProfilerPathEmpty()) {
LOG_ECMA(ERROR) << "no pgo profile file in partial mode!";
}
} else {
runtimeOptions.SetEnableOptPGOType(false);
runtimeOptions.SetPGOProfilerPath("");
}
}
std::string triple = runtimeOptions.GetTargetTriple();
if (runtimeOptions.GetAOTOutputFile().empty()) {
runtimeOptions.SetAOTOutputFile("aot_file");

View File

@ -799,4 +799,28 @@ void JSRuntimeOptions::ParseListArgParam(const std::string &option, arg_list_t *
}
return;
}
void JSRuntimeOptions::SetTargetBuiltinsDtsPath()
{
WasSet(CommandValues::OPTION_BUILTINS_DTS);
std::string builtinsDtsPath = TARGET_BUILTINS_DTS_PATH;
SetBuiltinsDTS(builtinsDtsPath);
}
void JSRuntimeOptions::SetOptionsForTargetCompilation()
{
if (IsTargetCompilerMode()) {
SetTargetBuiltinsDtsPath();
SetTargetTriple("aarch64-unknown-linux-gnu");
if (IsPartialCompilerMode()) {
SetEnableOptPGOType(true);
if (IsPGOProfilerPathEmpty()) {
LOG_ECMA(ERROR) << "no pgo profile file in partial mode!";
}
} else {
SetEnableOptPGOType(false);
SetPGOProfilerPath("");
}
}
}
}

View File

@ -1103,6 +1103,10 @@ public:
return hapAbcSize_;
}
void SetTargetBuiltinsDtsPath();
void SetOptionsForTargetCompilation();
private:
static bool StartsWith(const std::string &haystack, const std::string &needle)
{