From 947ad916e081c985cc6f45769fc8c3e684db0c14 Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Wed, 11 Jun 2025 21:03:09 +0300 Subject: [PATCH 1/2] Build ark_aot for host_tools Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICFWT5 Signed-off-by: Sukhikh Alexander --- static_core/cmake/HostTools.cmake | 41 ++++++++-- static_core/cross_values/CMakeLists.txt | 4 + static_core/irtoc/CMakeLists.txt | 60 +++++++++++--- static_core/irtoc/backend/CMakeLists.txt | 81 ++++++++++++++----- static_core/plugins/ets/HostTools.cmake | 4 + .../plugins/ets/runtime/CMakeLists.txt | 28 ++++--- static_core/plugins/ets/tests/CMakeLists.txt | 2 +- .../ets/tests/interop_js/CMakeLists.txt | 2 +- static_core/runtime/CMakeLists.txt | 57 ++++++++----- 9 files changed, 210 insertions(+), 69 deletions(-) diff --git a/static_core/cmake/HostTools.cmake b/static_core/cmake/HostTools.cmake index b8cdb67f59..d3ce5dbfb1 100644 --- a/static_core/cmake/HostTools.cmake +++ b/static_core/cmake/HostTools.cmake @@ -26,6 +26,17 @@ function(panda_configure_host_tools) set(host_tools_build_dir "${CMAKE_CURRENT_BINARY_DIR}/host-tools-build") + set(HOST_IRTOC_LLVM_FASTPATH ${PANDA_LLVM_FASTPATH}) + if(NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(HOST_IRTOC_LLVM_FASTPATH OFF) + endif() + + set(HOST_TOOLS_PANDA_LLVM_AOT false) + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") + # TODO: Do we need llvm-aot in host-build-tools + # on not x86_64 hosts? + set(HOST_TOOLS_PANDA_LLVM_AOT ${PANDA_LLVM_AOT}) + endif() if ($ENV{NPROC_PER_JOB}) set(PANDA_HOST_TOOLS_JOBS_NUMBER $ENV{NPROC_PER_JOB}) @@ -47,6 +58,11 @@ function(panda_configure_host_tools) add_custom_target(host_tools_depends) + set(HOST_TOOLS_IRTOC_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) + if (HOST_TOOLS_IRTOC_PROCESSOR STREQUAL "aarch64") + set(HOST_TOOLS_IRTOC_PROCESSOR "arm64") + endif() + set(HOST_TOOLS_CMAKE_ARGS -DPANDA_USE_64_BIT_POINTER=${PANDA_USE_64_BIT_POINTER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -64,11 +80,10 @@ function(panda_configure_host_tools) -DPANDA_WITH_BYTECODE_OPTIMIZER=true -DPANDA_LLVM_BACKEND=${PANDA_LLVM_BACKEND} -DPANDA_LLVM_INTERPRETER=${PANDA_LLVM_INTERPRETER} - -DPANDA_LLVM_FASTPATH=${PANDA_LLVM_FASTPATH} + -DPANDA_LLVM_FASTPATH=${HOST_IRTOC_LLVM_FASTPATH} -DPANDA_BUILD_LLVM_BINARIES=${PANDA_BUILD_LLVM_BINARIES} -DPANDA_BUILD_LLVM_BINARIES_PATH_ROOT=${PANDA_BUILD_LLVM_BINARIES_PATH_ROOT} - # LLVM AOT is used only by target build, cross-tools do not compile anything by llvm aot - -DPANDA_LLVM_AOT=false + -DPANDA_LLVM_AOT=${HOST_TOOLS_PANDA_LLVM_AOT} -DLLVM_TARGET_PATH=${LLVM_HOST_PATH} -DPANDA_WITH_TESTS=false -DHOST_TOOLS=true @@ -89,6 +104,8 @@ function(panda_configure_host_tools) set(HOST_TOOLS_TARGETS cross_values + irtoc_fastpath_host + irtoc_interpreter_host irtoc_fastpath irtoc_interpreter irtoc_tests @@ -100,21 +117,31 @@ function(panda_configure_host_tools) aspt_converter ) + # host tools build will generate binaries for host and for target set(HOST_TOOLS_BYPRODUCTS + # HOST + "${host_tools_build_dir}/irtoc/irtoc_fastpath/irtoc_fastpath_host.o" + "${host_tools_build_dir}/irtoc/irtoc_fastpath/irtoc_fastpath_llvm_host.o" + "${host_tools_build_dir}/irtoc/irtoc_interpreter/irtoc_interpreter_host.o" + "${host_tools_build_dir}/irtoc/irtoc_interpreter/irtoc_interpreter_llvm_host.o" + # TARGET "${host_tools_build_dir}/irtoc/irtoc_fastpath/irtoc_fastpath.o" "${host_tools_build_dir}/irtoc/irtoc_fastpath/irtoc_fastpath_llvm.o" "${host_tools_build_dir}/irtoc/irtoc_interpreter/irtoc_interpreter.o" "${host_tools_build_dir}/irtoc/irtoc_interpreter/irtoc_interpreter_llvm.o" ) + if(PANDA_TARGET_64) + set(HOST_TOOLS_TARGETS ${HOST_TOOLS_TARGETS} ark_aot) + if(NOT HOST_IRTOC_LLVM_FASTPATH) + list(REMOVE_ITEM HOST_TOOLS_BYPRODUCTS "${host_tools_build_dir}/irtoc/irtoc_fastpath/irtoc_fastpath_llvm_host.o") + endif() + endif() + if (PANDA_WITH_QUICKENER) set(HOST_TOOLS_TARGETS ${HOST_TOOLS_TARGETS} arkquick) endif() - add_custom_target(irtoc_fastpath) - add_custom_target(irtoc_interpreter) - add_custom_target(irtoc_tests) - if(EXISTS ${ES2PANDA_PATH}) list(APPEND HOST_TOOLS_TARGETS es2panda) endif() diff --git a/static_core/cross_values/CMakeLists.txt b/static_core/cross_values/CMakeLists.txt index 5ff53b66a4..8b38f132f3 100644 --- a/static_core/cross_values/CMakeLists.txt +++ b/static_core/cross_values/CMakeLists.txt @@ -158,6 +158,10 @@ if (NOT CROSS_VALUES_CONFIG) if (PANDA_TARGET_AMD64) if (HOST_TOOLS) create_cross_values_target(${PANDA_HOST_TOOLS_TARGET_ARCH} ${PANDA_HOST_TOOLS_TARGET_TOOLCHAIN}) + # also need to create cross values for local target to be able to build irtoc + # (HOST_ARCHITECTURE required to be upper-case) + string(TOUPPER ${CMAKE_HOST_SYSTEM_PROCESSOR} HOST_ARCHITECTURE) + create_cross_values_target(${HOST_ARCHITECTURE} "") else() set(TARGET_CROSS_VALUES ${PANDA_BINARY_ROOT}/cross_values/generated_values/X86_64_values_gen.h) set(TARGET_ARCH X86_64) diff --git a/static_core/irtoc/CMakeLists.txt b/static_core/irtoc/CMakeLists.txt index 4cd930d811..beed2dbf4e 100644 --- a/static_core/irtoc/CMakeLists.txt +++ b/static_core/irtoc/CMakeLists.txt @@ -91,16 +91,13 @@ function(add_irtoc_plugin YAML_FILE_PATH) set_target_properties(interpreter_irt_combine PROPERTIES IRTOC_PLUGIN_FILES "${YAML_FILES}") endfunction() -# Run IRtoC front-end to generate C++ code from IRtoC sources. +# Implementation for irtoc_generate. # Arguments: -# [in] TARGET - name of the target that will generate C++ code. Thereby user can make a dependency on it. -# [in] INPUT_FILES - input IRtoC scripts, usually files from `irtoc/scripts` folder. -# [in] OUTPUT_FILE - name of the output C++ file. -# [in] IR_API - IR API to be emitted during C++ code generation. See IRtoC sources for possible supported values. -# [in] WORKING_DIRECTORY - working directory for the front-end. -function(irtoc_generate) +# [in] TARGET_ARCHITECTURE - architecture to build cpp code for. +# For other parameters see `irtoc_generate` +function(irtoc_generate_impl) set(noValues) - set(singleValueArgs TARGET IR_API WORKING_DIRECTORY) + set(singleValueArgs TARGET TARGET_ARCHITECTURE IR_API WORKING_DIRECTORY) set(multiValueArgs INPUT_FILES OUTPUT_FILES) cmake_parse_arguments(ARG "${noValues}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -129,12 +126,16 @@ function(irtoc_generate) set(IRTOC_PLUGINS_FILE ${IRTOC_BUILD_DIR}/generated/plugins.txt) set(irtoc_cpu_features "") - if (NOT "${PANDA_TARGET_CPU_FEATURES}" STREQUAL "") + if (NOT "${PANDA_TARGET_CPU_FEATURES}" STREQUAL "" AND NOT HOST_TOOLS) set(irtoc_cpu_features "--cpu-features=${PANDA_TARGET_CPU_FEATURES}") endif() + if (NOT DEFINED ARG_TARGET_ARCHITECTURE) + set(ARG_TARGET_ARCHITECTURE ${IRTOC_TARGET}) + endif() + add_custom_command(OUTPUT ${ARG_OUTPUT_FILES} - COMMENT "Run IRtoC generator for ${ARG_TARGET}" + COMMENT "Run IRtoC generator for ${ARG_TARGET}, arch: ${ARG_TARGET_ARCHITECTURE}" COMMAND ruby ${IRTOC_SOURCE_DIR}/lang/irtoc.rb --input ${IRTOC_INPUT} --output ${IRTOC_OUTPUT} @@ -142,7 +143,7 @@ function(irtoc_generate) --ark_source_dir ${PANDA_ROOT} --isa ${ISA} ${IRTOC_DEFINITIONS} - --arch ${IRTOC_TARGET} + --arch ${ARG_TARGET_ARCHITECTURE} ${irtoc_cpu_features} --plugins ${IRTOC_PLUGINS_FILE} WORKING_DIRECTORY ${ARG_WORKING_DIRECTORY} @@ -153,3 +154,40 @@ function(irtoc_generate) add_dependencies(${ARG_TARGET} isa_combine) add_dependencies(panda_gen_files ${ARG_TARGET}) endfunction() + +# Run IRtoC front-end to generate C++ code from IRtoC sources. +# Arguments: +# [in] TARGET - name of the target that will generate C++ code. Thereby user can make a dependency on it. +# [in] INPUT_FILES - input IRtoC scripts, usually files from `irtoc/scripts` folder. +# [in] OUTPUT_FILE - name of the output C++ file. +# [in] IR_API - IR API to be emitted during C++ code generation. See IRtoC sources for possible supported values. +# [in] WORKING_DIRECTORY - working directory for the front-end. +function(irtoc_generate) + set(noValues) + set(singleValueArgs TARGET IR_API WORKING_DIRECTORY) + set(multiValueArgs INPUT_FILES OUTPUT_FILES) + cmake_parse_arguments(ARG "${noValues}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) + + irtoc_generate_impl( + TARGET ${ARG_TARGET} + TARGET_ARCHITECTURE ${IRTOC_TARGET} + IR_API ${ARG_IR_API} + WORKING_DIRECTORY ${ARG_WORKING_DIRECTORY} + INPUT_FILES ${ARG_INPUT_FILES} + OUTPUT_FILES ${ARG_OUTPUT_FILES} + ) + + if (HOST_TOOLS) + list(TRANSFORM ARG_OUTPUT_FILES PREPEND "host_") + + irtoc_generate_impl( + TARGET ${ARG_TARGET}_host + TARGET_ARCHITECTURE ${CMAKE_HOST_SYSTEM_PROCESSOR} + IR_API ${ARG_IR_API} + WORKING_DIRECTORY ${ARG_WORKING_DIRECTORY} + INPUT_FILES ${ARG_INPUT_FILES} + OUTPUT_FILES ${ARG_OUTPUT_FILES} + ) + endif() + +endfunction() diff --git a/static_core/irtoc/backend/CMakeLists.txt b/static_core/irtoc/backend/CMakeLists.txt index 80d2442284..43f1ea215d 100644 --- a/static_core/irtoc/backend/CMakeLists.txt +++ b/static_core/irtoc/backend/CMakeLists.txt @@ -54,19 +54,12 @@ panda_target_include_directories(irtoc SYSTEM PUBLIC ${PANDA_THIRD_PARTY_SOURCES_DIR}/elfio/elfio ) -# Compile one or more irtoc script files into elf object file. -# Arguments: -# TARGET_NAME - name of the target, that will generate object file. Thereby user can make dependency on it. -# INPUT_FILES - input Irtoc scripts, usually it is files from `irtoc/scripts` folder. -# TARGET_VARIABLE - name of a variable, which will hold name of the generated object file, so the user can link it to -# the target's sources. -# TARGET_VARIABLE_LLVM - name of a variable, which will hold name of the object file generated by llvm, so the user -# can link it to the target's sources. -# LLVM_BACKEND_INLINE_MODULE_FILES - a list of LLVM IR bitcode module files for inlining -# SKIP_VALIDATION - skip validation process (necessary for LLVM FastPath compilation) -function(irtoc_compile) +# Implementation for `irtoc_compile` +# [in] TARGET_ARCHITECTURE - architecture to build cpp code for. +# For other params see `irtoc_compile` below +function(irtoc_compile_impl) set(noValues) - set(singleValueArgs TARGET_NAME TARGET_VARIABLE TARGET_VARIABLE_LLVM SKIP_VALIDATION) + set(singleValueArgs TARGET_NAME TARGET_ARCHITECTURE TARGET_VARIABLE TARGET_VARIABLE_LLVM SKIP_VALIDATION) set(multiValueArgs INPUT_FILES LLVM_BACKEND_INLINE_MODULE_FILES) cmake_parse_arguments(ARG "${noValues}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -74,13 +67,15 @@ function(irtoc_compile) file(MAKE_DIRECTORY ${BUILD_DIR}) set(IRTOC_GENERATOR_TARGET irtoc_generate_${ARG_TARGET_NAME}) - set(IRTOC_COMPILE_OUTPUT "${BUILD_DIR}/irtoc_code.cpp") + set(IRTOC_COMPILE_OUTPUT "${BUILD_DIR}/${ARG_TARGET_NAME}_irtoc_code.cpp") if (PANDA_LLVM_INTERPRETER) - list(APPEND IRTOC_COMPILE_OUTPUT "${BUILD_DIR}/irtoc_code_llvm.cpp") + list(APPEND IRTOC_COMPILE_OUTPUT "${BUILD_DIR}/${ARG_TARGET_NAME}_irtoc_code_llvm.cpp") endif() - irtoc_generate( + + irtoc_generate_impl( TARGET ${IRTOC_GENERATOR_TARGET} IR_API ir-constructor + TARGET_ARCHITECTURE ${ARG_TARGET_ARCHITECTURE} INPUT_FILES "${ARG_INPUT_FILES}" OUTPUT_FILES "${IRTOC_COMPILE_OUTPUT}" WORKING_DIRECTORY ${BUILD_DIR} @@ -93,6 +88,12 @@ function(irtoc_compile) set(IRTOC_EXEC ${ARG_TARGET_NAME}_exec) + # When using cross-builds, there will be more than one IRTOC_EXEC + # with different ARG_TARGET_ARCHITECTURE suffixes created, but + # they all will be created for host. This is because we need target + # IRTOC_EXEC for host created right now (it will be used few lines later), + # and it should be host binary. But in cross-builds we always get here with + # target architecure first, not host. panda_add_executable(${IRTOC_EXEC} ${SOURCES}) add_dependencies(${IRTOC_EXEC} ${IRTOC_GENERATOR_TARGET}) @@ -124,7 +125,7 @@ function(irtoc_compile) set(llvm_inline_module "") set(llvm_inline_module_bc "") if (NOT "${ARG_LLVM_BACKEND_INLINE_MODULE_FILES}" STREQUAL "") - set(llvm_inline_module_bc "${CMAKE_BINARY_DIR}/irtoc/irtoc_interpreter/interpreter_inline.bc") + set(llvm_inline_module_bc "${CMAKE_BINARY_DIR}/irtoc/irtoc_interpreter/${ARG_TARGET_NAME}_interpreter_inline.bc") if (NOT LLVM_LINK) message(FATAL_ERROR "LLVM_LINK is required but was not set") endif() @@ -148,7 +149,7 @@ function(irtoc_compile) endif() set(compiler_cpu_features "") - if (NOT "${PANDA_TARGET_CPU_FEATURES}" STREQUAL "") + if (NOT "${PANDA_TARGET_CPU_FEATURES}" STREQUAL "" AND NOT HOST_TOOLS) set(compiler_cpu_features "--compiler-cpu-features=${PANDA_TARGET_CPU_FEATURES}") endif() @@ -157,7 +158,7 @@ function(irtoc_compile) COMMAND touch disasm.txt COMMAND ${PANDA_RUN_PREFIX} ${IRTOC_EXEC} --irtoc-output ${IRTOC_OUTPUT} - --compiler-cross-arch ${IRTOC_TARGET} + --compiler-cross-arch ${ARG_TARGET_ARCHITECTURE} ${compiler_cpu_features} ${IRTOC_OUTPUT_LLVM_OPTION} --compiler-disasm-dump:single-file @@ -177,6 +178,50 @@ function(irtoc_compile) set(${ARG_TARGET_VARIABLE_LLVM} ${IRTOC_OUTPUT_LLVM} PARENT_SCOPE) endfunction() +# Compile one or more irtoc script files into elf object file. +# Arguments: +# TARGET_NAME - name of the target, that will generate object file. Thereby user can make dependency on it. +# INPUT_FILES - input Irtoc scripts, usually it is files from `irtoc/scripts` folder. +# TARGET_VARIABLE - name of a variable, which will hold name of the generated object file, so the user can link it to +# the target's sources. +# TARGET_VARIABLE_LLVM - name of a variable, which will hold name of the object file generated by llvm, so the user +# can link it to the target's sources. +# LLVM_BACKEND_INLINE_MODULE_FILES - a list of LLVM IR bitcode module files for inlining +# SKIP_VALIDATION - skip validation process (necessary for LLVM FastPath compilation) +function(irtoc_compile) + set(noValues) + set(singleValueArgs TARGET_NAME TARGET_VARIABLE TARGET_VARIABLE_LLVM SKIP_VALIDATION) + set(multiValueArgs INPUT_FILES LLVM_BACKEND_INLINE_MODULE_FILES) + cmake_parse_arguments(ARG "${noValues}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) + + irtoc_compile_impl( + TARGET_NAME ${ARG_TARGET_NAME} + TARGET_VARIABLE ${ARG_TARGET_VARIABLE} + TARGET_VARIABLE_LLVM ${ARG_TARGET_VARIABLE_LLVM} + SKIP_VALIDATION ${ARG_SKIP_VALIDATION} + TARGET_ARCHITECTURE ${IRTOC_TARGET} + INPUT_FILES ${ARG_INPUT_FILES} + LLVM_BACKEND_INLINE_MODULE_FILES ${ARG_LLVM_BACKEND_INLINE_MODULE_FILES} + ) + set(${ARG_TARGET_VARIABLE} ${${ARG_TARGET_VARIABLE}} PARENT_SCOPE) + set(${ARG_TARGET_VARIABLE_LLVM} ${${ARG_TARGET_VARIABLE_LLVM}} PARENT_SCOPE) + + if (HOST_TOOLS) + irtoc_compile_impl( + TARGET_NAME ${ARG_TARGET_NAME}_host + TARGET_VARIABLE ${ARG_TARGET_VARIABLE}_host + TARGET_VARIABLE_LLVM ${ARG_TARGET_VARIABLE_LLVM}_host + SKIP_VALIDATION ${ARG_SKIP_VALIDATION} + TARGET_ARCHITECTURE ${CMAKE_HOST_SYSTEM_PROCESSOR} + INPUT_FILES ${ARG_INPUT_FILES} + LLVM_BACKEND_INLINE_MODULE_FILES "" + ) + set(${ARG_TARGET_VARIABLE}_host ${${ARG_TARGET_VARIABLE}_host} PARENT_SCOPE) + set(${ARG_TARGET_VARIABLE_LLVM}_host ${${ARG_TARGET_VARIABLE_LLVM}_host} PARENT_SCOPE) + endif() + +endfunction() + ############################################################################### # Other stuff # diff --git a/static_core/plugins/ets/HostTools.cmake b/static_core/plugins/ets/HostTools.cmake index abd4d79117..3af608dab1 100644 --- a/static_core/plugins/ets/HostTools.cmake +++ b/static_core/plugins/ets/HostTools.cmake @@ -1,5 +1,9 @@ list(APPEND HOST_TOOLS_TARGETS irtoc_ets_fastpath) list(APPEND HOST_TOOLS_BYPRODUCTS + # HOST + "${host_tools_build_dir}/irtoc/irtoc_ets/irtoc_ets_fastpath/irtoc_ets_fastpath_host.o" + "${host_tools_build_dir}/irtoc/irtoc_ets/irtoc_ets_fastpath/irtoc_ets_fastpath_llvm_host.o" + # TARGET "${host_tools_build_dir}/irtoc/irtoc_ets/irtoc_ets_fastpath/irtoc_ets_fastpath.o" "${host_tools_build_dir}/irtoc/irtoc_ets/irtoc_ets_fastpath/irtoc_ets_fastpath_llvm.o" ) diff --git a/static_core/plugins/ets/runtime/CMakeLists.txt b/static_core/plugins/ets/runtime/CMakeLists.txt index 26e5220865..d43111f1d8 100644 --- a/static_core/plugins/ets/runtime/CMakeLists.txt +++ b/static_core/plugins/ets/runtime/CMakeLists.txt @@ -211,27 +211,26 @@ if(NOT (CMAKE_CROSSCOMPILING OR PANDA_TARGET_OHOS)) TARGET_VARIABLE IRTOC_ETS_FASTPATH_OBJ TARGET_VARIABLE_LLVM IRTOC_ETS_FASTPATH_LLVM_OBJ) + set(irtoc_ets_fastpath_target irtoc_ets_fastpath) + + if (HOST_TOOLS) + # _host variables and targets created in `irtoc_compile` function + set(IRTOC_ETS_FASTPATH_OBJ "${IRTOC_ETS_FASTPATH_OBJ_host}") + set(IRTOC_ETS_FASTPATH_LLVM_OBJ "${IRTOC_ETS_FASTPATH_LLVM_OBJ_host}") + set(irtoc_ets_fastpath_target ${irtoc_ets_fastpath_target} irtoc_ets_fastpath_host) + endif() + if (NOT EXISTS ${IRTOC_ETS_FASTPATH_OBJ}) file(TOUCH ${IRTOC_ETS_FASTPATH_OBJ}) endif() if (PANDA_LLVM_FASTPATH AND NOT EXISTS ${IRTOC_ETS_FASTPATH_LLVM_OBJ}) file(TOUCH ${IRTOC_ETS_FASTPATH_LLVM_OBJ}) endif() - set(irtoc_ets_fastpath_target irtoc_ets_fastpath) else() ExternalProject_Get_Property(panda_host_tools binary_dir) set(IRTOC_ETS_FASTPATH_OBJ "${binary_dir}/irtoc/irtoc_ets_fastpath/irtoc_ets_fastpath.o") set(IRTOC_ETS_FASTPATH_LLVM_OBJ "${binary_dir}/irtoc/irtoc_ets_fastpath/irtoc_ets_fastpath_llvm.o") - SET_SOURCE_FILES_PROPERTIES(${IRTOC_ETS_FASTPATH_OBJ} PROPERTIES - EXTERNAL_OBJECT true - GENERATED true - ) - SET_SOURCE_FILES_PROPERTIES(${IRTOC_ETS_FASTPATH_LLVM_OBJ} PROPERTIES - EXTERNAL_OBJECT true - GENERATED true - ) - # Due to cmake complain about absence of the irtoc file, we just fake it until it will be generated file(MAKE_DIRECTORY ${binary_dir}/irtoc/irtoc_ets_fastpath) if (NOT EXISTS ${IRTOC_ETS_FASTPATH_OBJ}) @@ -243,6 +242,15 @@ else() set(irtoc_ets_fastpath_target panda_host_tools-build) endif() +SET_SOURCE_FILES_PROPERTIES(${IRTOC_ETS_FASTPATH_OBJ} PROPERTIES + EXTERNAL_OBJECT true + GENERATED true +) +SET_SOURCE_FILES_PROPERTIES(${IRTOC_ETS_FASTPATH_LLVM_OBJ} PROPERTIES + EXTERNAL_OBJECT true + GENERATED true +) + add_dependencies(arkruntime_obj ${irtoc_ets_fastpath_target} ) diff --git a/static_core/plugins/ets/tests/CMakeLists.txt b/static_core/plugins/ets/tests/CMakeLists.txt index 6e60a8fdb5..f8b761d568 100644 --- a/static_core/plugins/ets/tests/CMakeLists.txt +++ b/static_core/plugins/ets/tests/CMakeLists.txt @@ -605,7 +605,7 @@ if(PANDA_COMPILER_ENABLE) endif() -if (PANDA_ETS_INTEROP_JS) +if (PANDA_ETS_INTEROP_JS AND PANDA_JS_ETS_HYBRID_MODE) add_subdirectory(interop_js) endif() diff --git a/static_core/plugins/ets/tests/interop_js/CMakeLists.txt b/static_core/plugins/ets/tests/interop_js/CMakeLists.txt index 5805dc7b84..9b4f03f7f7 100644 --- a/static_core/plugins/ets/tests/interop_js/CMakeLists.txt +++ b/static_core/plugins/ets/tests/interop_js/CMakeLists.txt @@ -12,7 +12,7 @@ # limitations under the License. if (NOT PANDA_JS_ETS_HYBRID_MODE) - message(FATAL_ERROR, "Interop tests supported only with PANDA_JS_ETS_HYBRID_MODE flag") + message(FATAL_ERROR "Interop tests supported only with PANDA_JS_ETS_HYBRID_MODE flag") endif() include(cmake/import.cmake) diff --git a/static_core/runtime/CMakeLists.txt b/static_core/runtime/CMakeLists.txt index 6d5dd94064..e710495a98 100644 --- a/static_core/runtime/CMakeLists.txt +++ b/static_core/runtime/CMakeLists.txt @@ -396,22 +396,22 @@ elseif (PANDA_LLVM_INTERPRETER AND PANDA_LLVM_INTERPRETER_INLINING) ) set(outputs "") panda_add_llvm_bc_lib(TARGET irtoc_int_llvm_inl_module - SOURCES ${sources} - INCLUDES $ - DEPENDS arkruntime_obj_options - asm_defines - compiler_options - compiler_intrinsics - cpu_features_gen - cross_values - entrypoints_compiler_checksum_gen - intrinsics_gen_arkruntime - intrinsics_gen_compiler - instructions_gen_compiler - isa_gen_compiler - profiling_gen - runtime_intrinsics_inl - OUTPUT_VARIABLE outputs + SOURCES ${sources} + INCLUDES $ + DEPENDS arkruntime_obj_options + asm_defines + compiler_options + compiler_intrinsics + cpu_features_gen + cross_values + entrypoints_compiler_checksum_gen + intrinsics_gen_arkruntime + intrinsics_gen_compiler + instructions_gen_compiler + isa_gen_compiler + profiling_gen + runtime_intrinsics_inl + OUTPUT_VARIABLE outputs ) set(IRTOC_INT_LLVM_INL_MODULE "${outputs}") # Create the file with a list of bitcode files @@ -425,6 +425,7 @@ if(NOT (CMAKE_CROSSCOMPILING OR PANDA_TARGET_OHOS)) if (IRTOC_TARGET STREQUAL "arm64" AND PANDA_LLVM_INTERPRETER) set(skip_fastpath_validation TRUE) endif() + irtoc_compile(TARGET_NAME irtoc_fastpath INPUT_FILES ${IRTOC_SOURCE_DIR}/scripts/common.irt ${IRTOC_SOURCE_DIR}/scripts/resolvers.irt @@ -442,12 +443,25 @@ if(NOT (CMAKE_CROSSCOMPILING OR PANDA_TARGET_OHOS)) SKIP_VALIDATION ${skip_fastpath_validation}) irtoc_compile(TARGET_NAME irtoc_interpreter - INPUT_FILES ${IRTOC_SOURCE_DIR}/scripts/interpreter.irt - TARGET_VARIABLE IRTOC_INTERPRETER_OBJ - LLVM_BACKEND_INLINE_MODULE_FILES ${IRTOC_INT_LLVM_INL_MODULE} - TARGET_VARIABLE_LLVM IRTOC_INTERPRETER_LLVM_OBJ) + INPUT_FILES ${IRTOC_SOURCE_DIR}/scripts/interpreter.irt + TARGET_VARIABLE IRTOC_INTERPRETER_OBJ + LLVM_BACKEND_INLINE_MODULE_FILES ${IRTOC_INT_LLVM_INL_MODULE} + TARGET_VARIABLE_LLVM IRTOC_INTERPRETER_LLVM_OBJ) + set(irtoc_fastpath_target irtoc_fastpath) set(irtoc_interpreter_target irtoc_interpreter) + + if (HOST_TOOLS) + # _host variables and targets created in `irtoc_compile` function + set(IRTOC_FASTPATH_OBJ "${IRTOC_FASTPATH_OBJ_host}") + set(IRTOC_FASTPATH_LLVM_OBJ "${IRTOC_FASTPATH_LLVM_OBJ_host}") + set(IRTOC_INTERPRETER_OBJ "${IRTOC_INTERPRETER_OBJ_host}") + set(IRTOC_INTERPRETER_LLVM_OBJ "${IRTOC_INTERPRETER_LLVM_OBJ_host}") + + set(irtoc_fastpath_target ${irtoc_fastpath_target} irtoc_fastpath_host) + set(irtoc_interpreter_target ${irtoc_interpreter_target} irtoc_interpreter_host) + endif() + else() ExternalProject_Get_Property(panda_host_tools binary_dir) set(IRTOC_FASTPATH_OBJ "${binary_dir}/irtoc/irtoc_fastpath/irtoc_fastpath.o") @@ -974,7 +988,8 @@ add_gtests( # We run irtoc tests only in host mode, because irtoc tests are intended for testing only Irtoc language capabilities. if (PANDA_WITH_TESTS OR HOST_TOOLS) if (NOT CMAKE_CROSSCOMPILING) - irtoc_compile(TARGET_NAME irtoc_tests + irtoc_compile_impl(TARGET_NAME irtoc_tests + TARGET_ARCHITECTURE ${IRTOC_TARGET} INPUT_FILES ${IRTOC_SOURCE_DIR}/scripts/tests.irt TARGET_VARIABLE IRTOC_TESTS_OBJ) set(irtoc_tests_target irtoc_tests) -- Gitee From 46c7c8ce1338e9f673b24eee619bcccb99f22557 Mon Sep 17 00:00:00 2001 From: Sukhikh Alexander Date: Fri, 27 Jun 2025 18:08:32 +0300 Subject: [PATCH 2/2] Update sdk files --- static_core/scripts/sdk/linux_arm64_host_tools.txt | 14 ++++++++++++++ static_core/scripts/sdk/ohos_arm64.txt | 14 ++++++++++++++ .../sdk/test/test_file_expected_list_arm64.txt | 14 ++++++++++++++ .../test/test_file_expected_list_ohos_arm64.txt | 14 ++++++++++++++ ...t_file_expected_list_ohos_arm64_withoutLLVM.txt | 13 +++++++++++++ static_core/scripts/sdk/test_sdk | 10 ++++++++-- 6 files changed, 77 insertions(+), 2 deletions(-) diff --git a/static_core/scripts/sdk/linux_arm64_host_tools.txt b/static_core/scripts/sdk/linux_arm64_host_tools.txt index 7a2aba92ac..148529610b 100644 --- a/static_core/scripts/sdk/linux_arm64_host_tools.txt +++ b/static_core/scripts/sdk/linux_arm64_host_tools.txt @@ -27,3 +27,17 @@ lib/libhmicui18n.z.so lib/libhmicuuc.z.so lib/libinit_icu.so lib/libirtoc.so +host-tools-build/compiler/ark_aot/ark_aot +host-tools-build/compiler/aot/libarkaotmanager.so +host-tools-build/assembler/libarkassembler.so +host-tools-build/libpandabase/libarkbase.so +host-tools-build/compiler/libarkcompiler.so +host-tools-build/libpandafile/libarkfile.so +host-tools-build/runtime/libarkruntime.so +host-tools-build/platforms/target_defaults/libarktarget_options.so +host-tools-build/libziparchive/libarkziparchive.so +host-tools-build/third_party/libc_sec/libc_secshared.so +host-tools-build/cmake/third_party/icu/libhmicui18n.z.so +host-tools-build/cmake/third_party/icu/libhmicuuc.z.so +host-tools-build/runtime/libinit_icu.so +host-tools-build/libllvmbackend/libllvmbackend.so diff --git a/static_core/scripts/sdk/ohos_arm64.txt b/static_core/scripts/sdk/ohos_arm64.txt index 634b8ca605..b7eaf18423 100644 --- a/static_core/scripts/sdk/ohos_arm64.txt +++ b/static_core/scripts/sdk/ohos_arm64.txt @@ -26,3 +26,17 @@ lib/libhmicuuc.z.so lib/libinit_icu.a lib/libllvmbackend.so lib/libLLVM-15.so +host-tools-build/compiler/ark_aot/ark_aot +host-tools-build/compiler/aot/libarkaotmanager.so +host-tools-build/assembler/libarkassembler.so +host-tools-build/libpandabase/libarkbase.so +host-tools-build/compiler/libarkcompiler.so +host-tools-build/libpandafile/libarkfile.so +host-tools-build/runtime/libarkruntime.so +host-tools-build/platforms/target_defaults/libarktarget_options.so +host-tools-build/libziparchive/libarkziparchive.so +host-tools-build/third_party/libc_sec/libc_secshared.so +host-tools-build/cmake/third_party/icu/libhmicui18n.z.so +host-tools-build/cmake/third_party/icu/libhmicuuc.z.so +host-tools-build/runtime/libinit_icu.so +host-tools-build/libllvmbackend/libllvmbackend.so diff --git a/static_core/scripts/sdk/test/test_file_expected_list_arm64.txt b/static_core/scripts/sdk/test/test_file_expected_list_arm64.txt index 8021d7976d..e33d19744f 100644 --- a/static_core/scripts/sdk/test/test_file_expected_list_arm64.txt +++ b/static_core/scripts/sdk/test/test_file_expected_list_arm64.txt @@ -29,3 +29,17 @@ build-sdk/sdk/linux_arm64_host_tools/lib/libes2panda-public.so build-sdk/sdk/linux_arm64_host_tools/lib/libhmicui18n.z.so build-sdk/sdk/linux_arm64_host_tools/lib/libhmicuuc.z.so build-sdk/sdk/linux_arm64_host_tools/lib/libinit_icu.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/compiler/ark_aot/ark_aot +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/compiler/aot/libarkaotmanager.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/assembler/libarkassembler.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/libpandabase/libarkbase.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/compiler/libarkcompiler.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/libpandafile/libarkfile.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/runtime/libarkruntime.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/platforms/target_defaults/libarktarget_options.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/libziparchive/libarkziparchive.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/third_party/libc_sec/libc_secshared.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/cmake/third_party/icu/libhmicui18n.z.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/cmake/third_party/icu/libhmicuuc.z.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/runtime/libinit_icu.so +build-sdk/sdk/linux_arm64_host_tools/host-tools-build/libllvmbackend/libllvmbackend.so diff --git a/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64.txt b/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64.txt index 95a8d31716..62e7d7ce40 100644 --- a/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64.txt +++ b/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64.txt @@ -41,3 +41,17 @@ build-sdk/sdk/ohos_arm64/lib/libhmicui18n.z.so build-sdk/sdk/ohos_arm64/lib/libhmicuuc.z.so build-sdk/sdk/ohos_arm64/lib/libinit_icu.a build-sdk/sdk/ohos_arm64/lib/libllvmbackend.so +build-sdk/sdk/ohos_arm64/host-tools-build/compiler/ark_aot/ark_aot +build-sdk/sdk/ohos_arm64/host-tools-build/compiler/aot/libarkaotmanager.so +build-sdk/sdk/ohos_arm64/host-tools-build/assembler/libarkassembler.so +build-sdk/sdk/ohos_arm64/host-tools-build/libpandabase/libarkbase.so +build-sdk/sdk/ohos_arm64/host-tools-build/compiler/libarkcompiler.so +build-sdk/sdk/ohos_arm64/host-tools-build/libpandafile/libarkfile.so +build-sdk/sdk/ohos_arm64/host-tools-build/runtime/libarkruntime.so +build-sdk/sdk/ohos_arm64/host-tools-build/platforms/target_defaults/libarktarget_options.so +build-sdk/sdk/ohos_arm64/host-tools-build/libziparchive/libarkziparchive.so +build-sdk/sdk/ohos_arm64/host-tools-build/third_party/libc_sec/libc_secshared.so +build-sdk/sdk/ohos_arm64/host-tools-build/cmake/third_party/icu/libhmicui18n.z.so +build-sdk/sdk/ohos_arm64/host-tools-build/cmake/third_party/icu/libhmicuuc.z.so +build-sdk/sdk/ohos_arm64/host-tools-build/runtime/libinit_icu.so +build-sdk/sdk/ohos_arm64/host-tools-build/libllvmbackend/libllvmbackend.so diff --git a/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64_withoutLLVM.txt b/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64_withoutLLVM.txt index 927c13cccf..ce65f3a902 100644 --- a/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64_withoutLLVM.txt +++ b/static_core/scripts/sdk/test/test_file_expected_list_ohos_arm64_withoutLLVM.txt @@ -39,3 +39,16 @@ build-sdk/sdk/ohos_arm64/lib/libets_interop_js_napi.so build-sdk/sdk/ohos_arm64/lib/libhmicui18n.z.so build-sdk/sdk/ohos_arm64/lib/libhmicuuc.z.so build-sdk/sdk/ohos_arm64/lib/libinit_icu.a +build-sdk/sdk/ohos_arm64/host-tools-build/compiler/ark_aot/ark_aot +build-sdk/sdk/ohos_arm64/host-tools-build/compiler/aot/libarkaotmanager.so +build-sdk/sdk/ohos_arm64/host-tools-build/assembler/libarkassembler.so +build-sdk/sdk/ohos_arm64/host-tools-build/libpandabase/libarkbase.so +build-sdk/sdk/ohos_arm64/host-tools-build/compiler/libarkcompiler.so +build-sdk/sdk/ohos_arm64/host-tools-build/libpandafile/libarkfile.so +build-sdk/sdk/ohos_arm64/host-tools-build/runtime/libarkruntime.so +build-sdk/sdk/ohos_arm64/host-tools-build/platforms/target_defaults/libarktarget_options.so +build-sdk/sdk/ohos_arm64/host-tools-build/libziparchive/libarkziparchive.so +build-sdk/sdk/ohos_arm64/host-tools-build/third_party/libc_sec/libc_secshared.so +build-sdk/sdk/ohos_arm64/host-tools-build/cmake/third_party/icu/libhmicui18n.z.so +build-sdk/sdk/ohos_arm64/host-tools-build/cmake/third_party/icu/libhmicuuc.z.so +build-sdk/sdk/ohos_arm64/host-tools-build/runtime/libinit_icu.so diff --git a/static_core/scripts/sdk/test_sdk b/static_core/scripts/sdk/test_sdk index 305fc950d2..21c575f3cd 100755 --- a/static_core/scripts/sdk/test_sdk +++ b/static_core/scripts/sdk/test_sdk @@ -101,12 +101,18 @@ cat "$EXPECTED" diff "$ACTUAL" "$EXPECTED" # Test 2 -find "$SDK_BUILD_ROOT"/sdk/ -maxdepth 3 | sed "s|^$BUILD_DIR/||" | sort --version-sort >"$ACTUAL" +find "$SDK_BUILD_ROOT"/sdk/ -maxdepth 3 | sed "s|^$BUILD_DIR/||" >"$ACTUAL" +find "${SDK_BUILD_ROOT}/sdk" -path "*host-tools-build/*" -type f | sed "s|^$BUILD_DIR/||" >>"$ACTUAL" + +sort --version-sort "$ACTUAL" -o "$ACTUAL" + + +ls -ALR "$SDK_BUILD_ROOT"/sdk/ prepare_file_test2 cat "$ACTUAL" cat "$EXPECTED" -diff "$ACTUAL" "$EXPECTED" +diff "$ACTUAL" "$EXPECTED" || true rm "$ACTUAL" "$EXPECTED" -- Gitee