1# Copyright 2023 The SwiftShader Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15%$%generated_file_comment 16 17import("../../src/swiftshader.gni") 18 19# Need a separate config to ensure the warnings are added to the end. 20config("swiftshader_llvm_private_config") { 21 cflags = [ 22 "-DBLAKE3_NO_AVX512", 23 "-DBLAKE3_NO_AVX2", 24 "-DBLAKE3_NO_SSE41", 25 "-DBLAKE3_NO_SSE2", 26 "-DBLAKE3_USE_NEON=0", 27 ] 28 29 if (is_win) { 30 cflags += [ 31 "/wd4005", 32 "/wd4018", 33 "/wd4065", 34 "/wd4141", 35 "/wd4146", 36 "/wd4244", 37 "/wd4245", 38 "/wd4267", 39 "/wd4310", 40 "/wd4319", 41 "/wd4334", 42 "/wd4389", 43 "/wd4624", 44 "/wd4701", 45 "/wd4702", 46 "/wd4703", 47 "/wd4706", 48 "/wd4800", 49 "/wd4805", 50 "/wd4828", 51 ] 52 53 if (!is_debug) { 54 cflags += [ "/wd4324" ] 55 } 56 57 if (is_clang) { 58 cflags += [ 59 "-Wno-format", 60 "-Wno-sign-compare", 61 "-Wno-macro-redefined", 62 ] 63 } 64 } 65 66 if (is_fuchsia) { 67 # Ignore #warning for unimplemented features in Process.inc. 68 cflags += [ "-Wno-cpp" ] 69 } 70 71 if (is_clang) { 72 cflags += [ 73 "-Wno-attributes", 74 "-Wno-bitwise-instead-of-logical", 75 "-Wno-deprecated-anon-enum-enum-conversion", 76 "-Wno-deprecated-declarations", 77 "-Wno-deprecated-pragma", 78 "-Wno-deprecated-enum-enum-conversion", 79 "-Wno-enum-compare", 80 "-Wno-header-hygiene", 81 "-Wno-range-loop-bind-reference", 82 "-Wno-unused-function", 83 "-Wno-unused-local-typedef", 84 "-Wno-unused-private-field", 85 "-Wno-unused-result", 86 "-Wno-unused-variable", 87 ] 88 } 89 90 defines = [ 91 "__STDC_CONSTANT_MACROS", 92 "__STDC_LIMIT_MACROS", 93 ] 94} 95 96llvm_include_dirs = [ 97 "llvm/include/", 98 "llvm/lib/Target/AArch64/", 99 "llvm/lib/Target/ARM/", 100 "llvm/lib/Target/LoongArch/", 101 "llvm/lib/Target/Mips/", 102 "llvm/lib/Target/PowerPC/", 103 "llvm/lib/Target/RISCV/", 104 "llvm/lib/Target/X86/", 105 "configs/common/include/", 106 "configs/common/lib/ExecutionEngine/JITLink/", 107 "configs/common/lib/IR/", 108 "configs/common/lib/Target/AArch64/", 109 "configs/common/lib/Target/ARM/", 110 "configs/common/lib/Target/LoongArch/", 111 "configs/common/lib/Target/Mips/", 112 "configs/common/lib/Target/PowerPC/", 113 "configs/common/lib/Target/RISCV/", 114 "configs/common/lib/Target/X86/", 115 "configs/common/lib/Transforms/InstCombine/", 116] 117 118if (is_linux || is_chromeos) { 119 llvm_include_dirs += [ "configs/linux/include/" ] 120} else if (is_fuchsia) { 121 llvm_include_dirs += [ "configs/fuchsia/include/" ] 122} else if (is_win) { 123 llvm_include_dirs += [ "configs/windows/include/" ] 124} else if (is_android) { 125 llvm_include_dirs += [ "configs/android/include/" ] 126} else if (is_mac) { 127 llvm_include_dirs += [ "configs/darwin/include/" ] 128} else { 129 assert(false, "llvm-10.0 not configured for target platform") 130} 131 132template("swiftshader_llvm_source_set") { 133 swiftshader_source_set(target_name) { 134 configs = [ ":swiftshader_llvm_private_config" ] 135 include_dirs = llvm_include_dirs 136 137 forward_variables_from(invoker, "*", [ "configs" ]) 138 if (defined(invoker.configs)) { 139 configs += invoker.configs 140 } 141 } 142} 143 144swiftshader_llvm_source_set("swiftshader_llvm") { 145 # This class is declared on all platforms but only used on ARM. UBSanVPtr 146 # builds require that all declared classes have a definition even if they're 147 # not used. 148 if (is_ubsan_vptr) { 149 sources = [ 150 "llvm/lib/MC/MCWasmObjectTargetWriter.cpp", 151 "llvm/lib/MC/MCXCOFFObjectTargetWriter.cpp", 152 "llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp", 153 "llvm/lib/Target/TargetIntrinsicInfo.cpp", 154 ] 155 } 156 157 deps = [ 158%$%llvm_deps 159 ] 160 161 if (is_debug) { 162 deps += [ ":swiftshader_llvm_debug" ] 163 } 164 165 if (current_cpu == "arm64") { 166 deps += [ ":swiftshader_llvm_aarch64" ] 167 } else if (current_cpu == "arm") { 168 deps += [ ":swiftshader_llvm_arm" ] 169 } else if (current_cpu == "loong64") { 170 deps += [ ":swiftshader_llvm_loongarch64" ] 171 } else if (current_cpu == "mipsel" || current_cpu == "mips64el") { 172 deps += [ ":swiftshader_llvm_mips" ] 173 } else if (current_cpu == "ppc64") { 174 deps += [ ":swiftshader_llvm_ppc" ] 175 } else if (current_cpu == "riscv64") { 176 deps += [ ":swiftshader_llvm_riscv64" ] 177 } else if (current_cpu == "x86" || current_cpu == "x64") { 178 deps += [ ":swiftshader_llvm_x86" ] 179 } else { 180 assert(false, "Unsupported current_cpu") 181 } 182 183 if ((current_cpu != current_cpu && 184 (current_cpu == "x86" || current_cpu == "x64")) || 185 # Windows ARM64 does cross compilation on Windows x64 host, and requires native 186 # x86 target. 187 (is_win && current_cpu == "arm64")) { 188 deps += [ ":swiftshader_llvm_x86" ] 189 } 190} 191 192# This source_set would contain all source files, except that GN doesn't allow for duplicate source 193# file names, even if they are in different subdirectories. Because of this, some files are 194# split out into their own source_set. 195%$%llvm_source_sets 196 197swiftshader_llvm_source_set("swiftshader_llvm_debug") { 198 sources = [ 199%$%files_llvm_debug 200 ] 201} 202 203swiftshader_llvm_source_set("swiftshader_llvm_aarch64") { 204 sources = [ 205%$%files_AArch64 206 ] 207} 208 209swiftshader_llvm_source_set("swiftshader_llvm_arm") { 210 sources = [ 211%$%files_ARM 212 ] 213 214 # When is_ubsan_vptr is true, this file is added to swiftshader_llvm instead. 215 if (!is_ubsan_vptr) { 216 sources += [ "llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp" ] 217 } 218} 219 220swiftshader_llvm_source_set("swiftshader_llvm_loongarch64") { 221 sources = [ 222%$%files_LoongArch 223 ] 224} 225 226swiftshader_llvm_source_set("swiftshader_llvm_mips") { 227 sources = [ 228%$%files_Mips 229 ] 230} 231 232swiftshader_llvm_source_set("swiftshader_llvm_ppc") { 233 sources = [ 234%$%files_PowerPC 235 ] 236} 237 238swiftshader_llvm_source_set("swiftshader_llvm_x86") { 239 sources = [ 240%$%files_x86 241 ] 242} 243 244swiftshader_llvm_source_set("swiftshader_llvm_riscv64") { 245 sources = [ 246%$%files_RISCV 247 ] 248} 249