1# Copyright (c) 2024 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//arkcompiler/ets_runtime/js_runtime_config.gni") 15 16config("libark_llvmcodegen_set_config") { 17 if (compile_llvm_online) { 18 lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ] 19 } else { 20 if (is_mingw) { 21 lib_dirs = [ 22 "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_windows/build/lib", 23 "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32", 24 ] 25 } else if (is_mac) { 26 if (host_cpu == "arm64") { 27 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_arm64/build/lib" ] 28 } else { 29 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_x64/build/lib" ] 30 } 31 } else { 32 if (host_cpu == "arm64" && host_os == "linux") { 33 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_linux_aarch64/build/lib" ] 34 } else { 35 if (current_cpu == "arm64") { 36 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/build/lib" ] 37 } else { 38 lib_dirs = [ 39 "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib", 40 ] 41 } 42 } 43 } 44 } 45 46 libs = [ 47 "LLVMTarget", 48 "LLVMObject", 49 "LLVMMC", 50 "LLVMSupport", 51 "LLVMCore", 52 "LLVMExecutionEngine", 53 "LLVMInterpreter", 54 "LLVMMCJIT", 55 "LLVMExegesis", 56 "LLVMRuntimeDyld", 57 "LLVMInstCombine", 58 "LLVMAnalysis", 59 "LLVMScalarOpts", 60 "LLVMBinaryFormat", 61 "LLVMDebugInfoDWARF", 62 "LLVMRemarks", 63 "LLVMTextAPI", 64 "LLVMScalarOpts", 65 "LLVMTransformUtils", 66 "LLVMBitReader", 67 "LLVMAsmPrinter", 68 "LLVMProfileData", 69 "LLVMBitstreamReader", 70 "LLVMSelectionDAG", 71 "LLVMGlobalISel", 72 "LLVMLTO", 73 "LLVMCFGuard", 74 "LLVMVectorize", 75 "LLVMDemangle", 76 "LLVMipo", 77 "LLVMInstrumentation", 78 "LLVMDebugInfoCodeView", 79 "LLVMAggressiveInstCombine", 80 "LLVMAsmParser", 81 "LLVMMCParser", 82 "LLVMMIRParser", 83 "LLVMMCDisassembler", 84 "LLVMCodeGen", 85 "LLVMTransformUtils", 86 "LLVMIRReader", 87 "LLVMAArch64Utils", 88 "LLVMAArch64CodeGen", 89 "LLVMAArch64Info", 90 "LLVMAArch64Desc", 91 "LLVMAArch64Disassembler", 92 "LLVMAArch64AsmParser", 93 "LLVMFrontendOpenMP", 94 "LLVMBitWriter", 95 ] 96 97 if (!is_mac && !is_ios) { 98 libs += [ "LLVMParts" ] 99 } 100 101 # Only support compiling aarch64 target at device-side(arm64 platform). 102 # So these os-related libs of x86 are not needed on arm64 platform. 103 if (is_mac || current_cpu != "arm64") { 104 libs += [ 105 "LLVMX86AsmParser", 106 "LLVMX86CodeGen", 107 "LLVMX86Desc", 108 "LLVMX86Disassembler", 109 "LLVMX86Info", 110 ] 111 } 112} 113 114ohos_source_set("libark_llvmcodegen_set") { 115 stack_protector_ret = false 116 public_configs = [ 117 "$js_root:include_llvm", 118 "$js_root:ark_jsruntime_common_config", 119 ":libark_llvmcodegen_set_config", 120 ] 121 sources = [ "llvm_interface.cpp" ] 122 part_name = "ets_runtime" 123 subsystem_name = "arkcompiler" 124} 125 126ohos_shared_library("libark_llvmcodegen") { 127 stack_protector_ret = false 128 deps = [ ":libark_llvmcodegen_set" ] 129 _used_symbols = [ 130 "LLVMGetInlineAsm", 131 "LLVMPassManagerBuilderCreate", 132 "LLVMCreateSimpleMCJITMemoryManager", 133 "LLVMLinkInMCJIT", 134 "LLVMVerifyModule", 135 "LLVMCreateDisasm", 136 "LLVMCreateRewriteStatepointsForGCLegacyPass", 137 "LLVMLinkAllBuiltinGCs", 138 139 "LLVMInitializeAArch64Target", 140 "LLVMInitializeAArch64AsmParser", 141 "LLVMInitializeAArch64Disassembler", 142 "LLVMInitializeAArch64AsmPrinter", 143 ] 144 ldflags = [] 145 foreach(symbol, _used_symbols) { 146 ldflags += [ "-Wl,-u," + symbol ] 147 } 148 install_enable = true 149 if (!is_mingw && !is_mac) { 150 output_extension = "so" 151 } 152 part_name = "ets_runtime" 153 subsystem_name = "arkcompiler" 154} 155