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_SystemZ = false 53llvm_build_WebAssembly = false 54llvm_build_X86 = false 55foreach(target, llvm_targets_to_build) { 56 if (target == "AArch64") { 57 llvm_build_AArch64 = true 58 } else if (target == "AMDGPU") { 59 llvm_build_AMDGPU = true 60 } else if (target == "ARM") { 61 llvm_build_ARM = true 62 } else if (target == "BPF") { 63 llvm_build_BPF = true 64 } else if (target == "Mips") { 65 llvm_build_Mips = true 66 } else if (target == "PowerPC") { 67 llvm_build_PowerPC = true 68 } else if (target == "SystemZ") { 69 llvm_build_SystemZ = true 70 } else if (target == "WebAssembly") { 71 llvm_build_WebAssembly = true 72 } else if (target == "X86") { 73 llvm_build_X86 = true 74 } else if (target == "AVR" || target == "Hexagon" || target == "Lanai" || 75 target == "NVPTX" || target == "RISCV" || target == "Sparc" || 76 target == "SystemZ") { 77 # Nothing to do. 78 } else { 79 all_targets_string = "" 80 foreach(target, llvm_all_targets) { 81 all_targets_string += "$0x0a " + target 82 } 83 assert(false, "Unknown target '$target' in llvm_targets_to_build. " + 84 "Known targets:" + all_targets_string) 85 } 86} 87 88# FIXME: This should be based off target_cpu once cross compiles work. 89if (host_cpu == "arm64") { 90 native_target = "AArch64" 91} else if (host_cpu == "arm") { 92 native_target = "ARM" 93} else if (host_cpu == "ppc" || host_cpu == "ppc64") { 94 native_target = "PowerPC" 95} else if (host_cpu == "x86" || host_cpu == "x64") { 96 native_target = "X86" 97} else { 98 assert(false, "Unsuppored host_cpu '$host_cpu'.") 99} 100