1declare_args() { 2 # The target archs LLVM should support. Defaults to the host arch. 3 # Set to a list, e.g. `llvm_targets_to_build = [ "X86", "ARM" ]`, 4 # or to the string "all" to get all known targets. 5 llvm_targets_to_build = "host" 6} 7 8# FIXME: Port the remaining targets. 9llvm_all_targets = [ 10 "AArch64", 11 "AMDGPU", 12 "ARM", 13 "AVR", 14 "BPF", 15 "Hexagon", 16 "Lanai", 17 "Mips", 18 "NVPTX", 19 "PowerPC", 20 "RISCV", 21 "Sparc", 22 "SystemZ", 23 "WebAssembly", 24 "X86", 25] 26 27if (llvm_targets_to_build == "host") { 28 if (host_cpu == "arm64") { 29 llvm_targets_to_build = [ "AArch64" ] 30 } else if (host_cpu == "arm") { 31 llvm_targets_to_build = [ "ARM" ] 32 } else if (host_cpu == "ppc" || host_cpu == "ppc64") { 33 llvm_targets_to_build = [ "PowerPC" ] 34 } else if (host_cpu == "x86" || host_cpu == "x64") { 35 llvm_targets_to_build = [ "X86" ] 36 } else { 37 assert(false, "add your host_cpu above") 38 } 39} else if (llvm_targets_to_build == "all") { 40 llvm_targets_to_build = llvm_all_targets 41} 42 43# Validate that llvm_targets_to_build is set to a list of valid targets, 44# and remember which targets are built where needed (for conditionally-built 45# unittest targets). 46llvm_build_AArch64 = false 47llvm_build_AMDGPU = false 48llvm_build_ARM = false 49llvm_build_BPF = false 50llvm_build_Mips = false 51llvm_build_PowerPC = false 52llvm_build_WebAssembly = false 53llvm_build_X86 = false 54foreach(target, llvm_targets_to_build) { 55 if (target == "AArch64") { 56 llvm_build_AArch64 = true 57 } else if (target == "AMDGPU") { 58 llvm_build_AMDGPU = true 59 } else if (target == "ARM") { 60 llvm_build_ARM = true 61 } else if (target == "BPF") { 62 llvm_build_BPF = true 63 } else if (target == "Mips") { 64 llvm_build_Mips = true 65 } else if (target == "PowerPC") { 66 llvm_build_PowerPC = true 67 } else if (target == "WebAssembly") { 68 llvm_build_WebAssembly = true 69 } else if (target == "X86") { 70 llvm_build_X86 = true 71 } else if (target == "AVR" || target == "Hexagon" || target == "Lanai" || 72 target == "NVPTX" || target == "RISCV" || target == "Sparc" || 73 target == "SystemZ") { 74 # Nothing to do. 75 } else { 76 all_targets_string = "" 77 foreach(target, llvm_all_targets) { 78 all_targets_string += "$0x0a " + target 79 } 80 assert(false, "Unknown target '$target' in llvm_targets_to_build. " + 81 "Known targets:" + all_targets_string) 82 } 83} 84 85# FIXME: This should be based off target_cpu once cross compiles work. 86if (host_cpu == "arm64") { 87 native_target = "AArch64" 88} else if (host_cpu == "arm") { 89 native_target = "ARM" 90} else if (host_cpu == "ppc" || host_cpu == "ppc64") { 91 native_target = "PowerPC" 92} else if (host_cpu == "x86" || host_cpu == "x64") { 93 native_target = "X86" 94} else { 95 assert(false, "Unsuppored host_cpu '$host_cpu'.") 96} 97