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 if (current_os == "ohos") { 34 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/build/lib" ] 35 } else { 36 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_linux_aarch64/build/lib" ] 37 } 38 } else { 39 if (current_cpu == "arm64") { 40 lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/build/lib" ] 41 } else { 42 lib_dirs = [ 43 "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib", 44 ] 45 } 46 } 47 } 48 } 49 50 libs = [ 51 "LLVMTarget", 52 "LLVMObject", 53 "LLVMMC", 54 "LLVMSupport", 55 "LLVMCore", 56 "LLVMExecutionEngine", 57 "LLVMInterpreter", 58 "LLVMMCJIT", 59 "LLVMExegesis", 60 "LLVMRuntimeDyld", 61 "LLVMInstCombine", 62 "LLVMAnalysis", 63 "LLVMScalarOpts", 64 "LLVMBinaryFormat", 65 "LLVMDebugInfoDWARF", 66 "LLVMRemarks", 67 "LLVMTextAPI", 68 "LLVMScalarOpts", 69 "LLVMTransformUtils", 70 "LLVMBitReader", 71 "LLVMAsmPrinter", 72 "LLVMProfileData", 73 "LLVMBitstreamReader", 74 "LLVMSelectionDAG", 75 "LLVMGlobalISel", 76 "LLVMLTO", 77 "LLVMCFGuard", 78 "LLVMVectorize", 79 "LLVMDemangle", 80 "LLVMipo", 81 "LLVMInstrumentation", 82 "LLVMDebugInfoCodeView", 83 "LLVMAggressiveInstCombine", 84 "LLVMAsmParser", 85 "LLVMMCParser", 86 "LLVMMIRParser", 87 "LLVMMCDisassembler", 88 "LLVMCodeGen", 89 "LLVMTransformUtils", 90 "LLVMIRReader", 91 "LLVMAArch64Utils", 92 "LLVMAArch64CodeGen", 93 "LLVMAArch64Info", 94 "LLVMAArch64Desc", 95 "LLVMAArch64Disassembler", 96 "LLVMAArch64AsmParser", 97 "LLVMFrontendOpenMP", 98 "LLVMBitWriter", 99 ] 100 101 if (!is_mac && !is_ios) { 102 libs += [ "LLVMParts" ] 103 } 104 105 # Only support compiling aarch64 target at device-side(arm64 platform). 106 # So these os-related libs of x86 are not needed on arm64 platform. 107 if (is_mac || current_cpu != "arm64") { 108 libs += [ 109 "LLVMX86AsmParser", 110 "LLVMX86CodeGen", 111 "LLVMX86Desc", 112 "LLVMX86Disassembler", 113 "LLVMX86Info", 114 ] 115 } 116} 117 118ohos_source_set("libark_llvmcodegen_set") { 119 stack_protector_ret = false 120 public_configs = [ 121 "$js_root:include_llvm", 122 "$js_root:ark_jsruntime_common_config", 123 ":libark_llvmcodegen_set_config", 124 ] 125 sources = [ "llvm_interface.cpp" ] 126 part_name = "ets_runtime" 127 subsystem_name = "arkcompiler" 128} 129 130ohos_shared_library("libark_llvmcodegen") { 131 stack_protector_ret = false 132 deps = [ ":libark_llvmcodegen_set" ] 133 _used_symbols = [ 134 "LLVMGetInlineAsm", 135 "LLVMPassManagerBuilderCreate", 136 "LLVMCreateSimpleMCJITMemoryManager", 137 "LLVMLinkInMCJIT", 138 "LLVMVerifyModule", 139 "LLVMCreateDisasm", 140 "LLVMCreateRewriteStatepointsForGCLegacyPass", 141 "LLVMLinkAllBuiltinGCs", 142 143 "LLVMInitializeAArch64Target", 144 "LLVMInitializeAArch64AsmParser", 145 "LLVMInitializeAArch64Disassembler", 146 "LLVMInitializeAArch64AsmPrinter", 147 ] 148 ldflags = [] 149 foreach(symbol, _used_symbols) { 150 ldflags += [ "-Wl,-u," + symbol ] 151 } 152 install_enable = true 153 if (!is_mingw && !is_mac) { 154 output_extension = "so" 155 } 156 part_name = "ets_runtime" 157 subsystem_name = "arkcompiler" 158} 159