1# This sets up the target triples based on the cpu/os configuration used for the 2# build. 3# Based on LLVM `/llvm/lib/Target/targets.gni` 4 5import("//build_overrides/clspv.gni") 6 7declare_args() { 8 # The target archs LLVM should support. Defaults to the host arch. 9 # Set to a list, e.g. `llvm_targets_to_build = [ "X86", "ARM" ]`, 10 # or to the string "all" to get all known targets. 11 llvm_targets_to_build = "host" 12} 13 14# FIXME: Port the remaining targets. 15llvm_all_stable_targets = [ 16 "AArch64", 17 "AMDGPU", 18 "ARM", 19 "AVR", 20 "BPF", 21 "Hexagon", 22 "Lanai", 23 "LoongArch", 24 "Mips", 25 "NVPTX", 26 "PowerPC", 27 "RISCV", 28 "Sparc", 29 "SystemZ", 30 "WebAssembly", 31 "X86", 32] 33 34llvm_all_experimental_targets = [] 35 36llvm_all_targets = llvm_all_stable_targets + llvm_all_experimental_targets 37 38# FIXME: This should be based off target_cpu once cross compiles work. 39if (host_cpu == "arm64") { 40 native_target = "AArch64" 41} else if (host_cpu == "arm") { 42 native_target = "ARM" 43} else if (host_cpu == "ppc" || host_cpu == "ppc64") { 44 native_target = "PowerPC" 45} else if (host_cpu == "x86" || host_cpu == "x64") { 46 native_target = "X86" 47} else { 48 assert(false, "add your host_cpu above") 49} 50 51if (llvm_targets_to_build == "host") { 52 llvm_targets_to_build = [ native_target ] 53} else if (llvm_targets_to_build == "all") { 54 llvm_targets_to_build = llvm_all_stable_targets 55} else if (llvm_targets_to_build == "experimental") { 56 llvm_targets_to_build = llvm_all_targets 57} 58 59# Validate that llvm_targets_to_build is set to a list of valid targets, 60# and remember which targets are built where needed (for conditionally-built 61# unittest targets). 62llvm_build_AArch64 = false 63llvm_build_AMDGPU = false 64llvm_build_ARM = false 65llvm_build_BPF = false 66llvm_build_LoongArch = false 67llvm_build_Mips = false 68llvm_build_PowerPC = false 69llvm_build_RISCV = false 70llvm_build_SystemZ = false 71llvm_build_WebAssembly = false 72llvm_build_X86 = false 73llvm_build_native = false 74foreach(target, llvm_targets_to_build) { 75 if (target == native_target) { 76 llvm_build_native = true 77 } 78 if (target == "AArch64") { 79 llvm_build_AArch64 = true 80 } else if (target == "AMDGPU") { 81 llvm_build_AMDGPU = true 82 } else if (target == "ARM") { 83 llvm_build_ARM = true 84 } else if (target == "BPF") { 85 llvm_build_BPF = true 86 } else if (target == "LoongArch") { 87 llvm_build_LoongArch = true 88 } else if (target == "Mips") { 89 llvm_build_Mips = true 90 } else if (target == "PowerPC") { 91 llvm_build_PowerPC = true 92 } else if (target == "RISCV") { 93 llvm_build_RISCV = true 94 } else if (target == "SystemZ") { 95 llvm_build_SystemZ = true 96 } else if (target == "WebAssembly") { 97 llvm_build_WebAssembly = true 98 } else if (target == "X86") { 99 llvm_build_X86 = true 100 } else if (target == "AVR" || target == "Hexagon" || target == "Lanai" || 101 target == "NVPTX" || target == "RISCV" || target == "Sparc" || 102 target == "SystemZ") { 103 # Nothing to do. 104 } else { 105 all_targets_string = "" 106 foreach(target, llvm_all_targets) { 107 all_targets_string += "$0x0a " + target 108 } 109 assert(false, "Unknown target '$target' in llvm_targets_to_build. " + 110 "Known targets:" + all_targets_string) 111 } 112} 113 114# we dont need below as we set these in the BUILDCONFIG.gn ourselves 115if (false) { 116 supported_android_toolchains = [] 117 118 if (android_ndk_path != "") { 119 if (llvm_build_AArch64) { 120 supported_android_toolchains += [ "../../toolchain:android_aarch64" ] 121 } 122 if (llvm_build_ARM) { 123 supported_android_toolchains += [ "../../toolchain:android_arm" ] 124 } 125 if (llvm_build_X86) { 126 assert(true, "X86 build for android is not supported for now") 127 supported_android_toolchains += [ 128 "//$clspv_llvm_dir/llvm/utils/gn/build/toolchain:stage2_android_x64", 129 "//$clspv_llvm_dir/llvm/utils/gn/build/toolchain:stage2_android_x86", 130 ] 131 } 132 } 133} 134