From 50ad4fb178d4dbe834adc1108477c2d920beced1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=88=E6=84=BF?= Date: Thu, 10 Jul 2025 16:15:07 +0800 Subject: [PATCH] Fix the independent compilation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICLG7Z Signed-off-by: chenlong --- BUILD.gn | 184 ++++++++++++++++++++++++++++++++++++++++++++- ark_config.gni | 59 +++++++++++++++ ark_root.gni | 31 ++++++++ merge_abc/BUILD.gn | 66 +++++++++++++--- 4 files changed, 328 insertions(+), 12 deletions(-) create mode 100644 ark_config.gni create mode 100644 ark_root.gni diff --git a/BUILD.gn b/BUILD.gn index eae01ab2b8..b64b11fd4b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,7 +11,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/ark_config.gni") +if (defined(ark_standalone_build) && ark_standalone_build) { + import("//arkcompiler/runtime_core/ark_config.gni") +} else { + import("//arkcompiler/ets_frontend/ark_config.gni") +} group("ets_frontend_build") { deps = [ @@ -19,3 +23,181 @@ group("ets_frontend_build") { "./merge_abc:merge_proto_abc_build", ] } + +# Common config for ark source +config("ark_config") { + visibility = [ + "./*", + "//arkcompiler/ets_frontend/*", + ] + + include_dirs = [ "$ark_root" ] + defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ] + + if (is_linux) { + defines += [ + "PANDA_TARGET_UNIX", + "PANDA_TARGET_LINUX", + "PANDA_WITH_BYTECODE_OPTIMIZER", + "PANDA_WITH_COMPILER", + "PANDA_USE_FUTEX", + ] + } else if (is_mingw) { + defines += [ + "PANDA_TARGET_WINDOWS", + "PANDA_WITH_BYTECODE_OPTIMIZER", + "PANDA_WITH_COMPILER", + "_CRTBLD", + "__LIBMSVCRT__", + ] + } else if (is_mac) { + defines += [ + "PANDA_TARGET_UNIX", + "PANDA_TARGET_MACOS", + "PANDA_WITH_BYTECODE_OPTIMIZER", + "PANDA_WITH_COMPILER", + ] + } else if (target_os == "ios") { + defines += [ + "PANDA_TARGET_UNIX", + "PANDA_TARGET_IOS", + "PANDA_WITH_BYTECODE_OPTIMIZER", + "PANDA_WITH_COMPILER", + ] + } else if (is_mob) { + defines += [ + "PANDA_TARGET_OHOS", + "PANDA_TARGET_UNIX", + "PANDA_USE_FUTEX", + "PANDA_TARGET_MOBILE", + "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS", + ] + } else if (is_ohos) { + if (is_build_sdk) { + defines += [ + "PANDA_TARGET_OHOS", + "PANDA_TARGET_UNIX", + "PANDA_WITH_BYTECODE_OPTIMIZER", + "PANDA_USE_FUTEX", + ] + } else { + defines += [ + "PANDA_TARGET_OHOS", + "PANDA_TARGET_UNIX", + "PANDA_USE_FUTEX", + ] + } + } else { + defines += [ + "PANDA_TARGET_UNIX", + "PANDA_USE_FUTEX", + ] + } + + if (current_os == "android" && defined(is_arkui_x) && is_arkui_x) { + defines += [ "PANDA_TARGET_ARKUI_X" ] + } + + if (enable_hilog) { + defines += [ "ENABLE_HILOG" ] + } + + if (!is_debug) { + defines += [ "NDEBUG" ] + } + + cflags_cc = [ + "-std=c++17", + "-pedantic", + "-Wall", + "-Wextra", + "-Werror", + "-fno-rtti", + "-Wno-invalid-offsetof", + + "-Wno-gnu-statement-expression", + "-Wno-unused-parameter", + "-Wno-unused-result", + "-Wno-unused-but-set-variable", + ] + if (defined(ohos_indep_compiler_enable) && !ohos_indep_compiler_enable) { + cflags_cc += [ "-fno-exceptions" ] + } + + cflags_c = [] + + if (!is_mac && use_pbqp) { + cflags_cc += [ + # PBQP regalloc + "-mllvm", + "-regalloc=pbqp", + ] + } + + if (is_fastverify) { + cflags_cc += [ + "-O3", + "-ggdb3", + "-gdwarf-4", + "-fno-omit-frame-pointer", + "-D_GLIBCXX_ASSERTIONS", + ] + cflags_c += [ + "-O3", + "-ggdb3", + "-gdwarf-4", + "-fno-omit-frame-pointer", + "-D_GLIBCXX_ASSERTIONS", + ] + } else if (is_debug) { + cflags_cc += [ + "-Og", + "-ggdb3", + "-gdwarf-4", + ] + } + + if (enable_relayout_profile) { + defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ] + } + + configs = [] + foreach(plugin, enabled_plugins) { + configs += [ "$ark_root/plugins/$plugin:ark_config" ] + } + + if (current_cpu == "arm") { + cflags_cc += [ + "-march=armv7-a", + "-mfloat-abi=${arm_float_abi}", + "-marm", + "-mfpu=vfp", + ] + + if (arm_float_abi == "soft") { + defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ] + } else if (arm_float_abi == "softfp") { + defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ] + } else if (arm_float_abi == "hard") { + defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ] + } + + defines += [ "PANDA_TARGET_ARM32" ] + } else if (current_cpu == "arm64") { + defines += [ + "PANDA_TARGET_ARM64", + "PANDA_TARGET_64", + "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", + "PANDA_USE_32_BIT_POINTER", + ] + } else if (current_cpu == "x86") { + defines += [ "PANDA_TARGET_X86" ] + } else if (current_cpu == "amd64" || current_cpu == "x64" || + current_cpu == "x86_64") { + defines += [ + "PANDA_TARGET_64", + "PANDA_TARGET_AMD64", + "PANDA_USE_32_BIT_POINTER", + ] + } +} diff --git a/ark_config.gni b/ark_config.gni new file mode 100644 index 0000000000..581cf22b00 --- /dev/null +++ b/ark_config.gni @@ -0,0 +1,59 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("ark_root.gni") + +if (is_standard_system) { + default_enabled_plugins = [] + platform_libs = [] + platform_ldflags = [ "-static-libstdc++" ] + platform_include_dirs = [] + use_pbqp = false +} else { + default_enabled_plugins = [] + platform_libs = [] + platform_ldflags = [] + platform_include_dirs = [] + use_pbqp = false +} + +enabled_plugins = default_enabled_plugins + +if (current_cpu == "arm") { + if (!defined(arm_float_abi) || arm_float_abi == "") { + arm_float_abi = "softfp" + } + + assert(arm_float_abi == "soft" || arm_float_abi == "softfp" || + arm_float_abi == "hard", + "arm_float_abi should be soft, softfp or hard") +} + +enable_bytecode_optimizer = true +enable_relayout_profile = false + +sdk_libc_secshared_dep = "bounds_checking_function:libsec_shared" +sdk_libc_secshared_config = + "$ark_third_party_root/bounds_checking_function:libsec_public_config" + +if (is_mingw || is_mac || is_linux || target_os == "ios" || + target_os == "android" || (is_build_sdk && is_ohos)) { + sdk_libc_secshared_dep = "bounds_checking_function:libsec_static" +} + +is_mob = !ark_standalone_build && !is_standard_system && + (current_cpu != "arm" || is_wearable_product) + +enable_hilog = + !ark_standalone_build && is_standard_system && current_os == "ohos" && + (current_cpu == "arm64" || current_cpu == "arm") \ No newline at end of file diff --git a/ark_root.gni b/ark_root.gni new file mode 100644 index 0000000000..1fe9083123 --- /dev/null +++ b/ark_root.gni @@ -0,0 +1,31 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (!defined(ark_standalone_build)) { + ark_standalone_build = false +} + +if (!ark_standalone_build) { + ark_third_party_root = "//third_party" + hilog_root = "//base/hiviewdfx/hilog/interfaces/native/innerkits" + build_root = "//build" + import("$build_root/config/components/toolchain/build_type.gni") + import("$build_root/ohos.gni") +} + +ark_root = "//arkcompiler/runtime_core" + +is_build_sdk = false +if (device_name == "sdk") { + is_build_sdk = true +} \ No newline at end of file diff --git a/merge_abc/BUILD.gn b/merge_abc/BUILD.gn index a20f2b5607..80bb16d2f3 100644 --- a/merge_abc/BUILD.gn +++ b/merge_abc/BUILD.gn @@ -12,7 +12,12 @@ # limitations under the License. import("//arkcompiler/ets_frontend/ets_frontend_config.gni") -import("//arkcompiler/runtime_core/ark_config.gni") + +if (defined(ark_standalone_build) && ark_standalone_build) { + import("//arkcompiler/runtime_core/ark_config.gni") +} else { + import("//arkcompiler/ets_frontend/ark_config.gni") +} THIRDPARTY_PROTOBUF_SUBSYS_NAME = "thirdparty" THIRDPARTY_PROTOBUF_PART_NAME = "protobuf" @@ -51,12 +56,24 @@ config("panda_assembly_proto_public_config") { ] } -assembly_proto_configs = [ - "$ark_root:ark_config", +if (defined(ark_standalone_build) && ark_standalone_build) { + assembly_proto_configs = [ "$ark_root:ark_config" ] +} else { + assembly_proto_configs = [ + "//arkcompiler/ets_frontend:ark_config" + ] +} + +if (ark_standalone_build) { + assembly_proto_configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libpandabase:arkbase_public_config", + ] +} + +assembly_proto_configs += [ ":panda_assembly_proto_public_config", - "$ark_root/assembler:arkassembler_public_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", ] if (defined(is_arkui_x) && is_arkui_x) { @@ -173,6 +190,14 @@ ohos_source_set("assembly_proto_static") { ] } + if (!ark_standalone_build) { + external_deps += [ + "runtime_core:arkassembler_public_headers", + "runtime_core:arkbase_public_headers", + "runtime_core:arkfile_public_headers", + ] + } + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { external_deps += [ "abseil-cpp:absl_base_static", @@ -218,12 +243,22 @@ ohos_executable("merge_abc") { include_dirs = [ "./src" ] - configs = [ - "$ark_root:ark_config", + if (defined(ark_standalone_build) && ark_standalone_build) { + configs = [ "$ark_root:ark_config" ] + } else { + configs = [ "//arkcompiler/ets_frontend:ark_config" ] + } + + if (ark_standalone_build) { + configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libpandabase:arkbase_public_config", + ] + } + + configs += [ ":panda_assembly_proto_public_config", - "$ark_root/assembler:arkassembler_public_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", ":proto_file_cpp_config", ] @@ -246,6 +281,15 @@ ohos_executable("merge_abc") { "protobuf:protobuf_static", ] } + + if (!ark_standalone_build) { + external_deps += [ + "runtime_core:arkassembler_public_headers", + "runtime_core:arkbase_public_headers", + "runtime_core:arkfile_public_headers", + ] + } + ldflags = [] if (is_linux) { if (build_public_version) { -- Gitee