blob: 8d18e212d0ca7636c9f09aff611e5596edd7aa9b [file] [log] [blame]
# Copyright 2023 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
%$%generated_file_comment
import("../../src/swiftshader.gni")
# Need a separate config to ensure the warnings are added to the end.
config("swiftshader_llvm_private_config") {
cflags = [
"-DBLAKE3_NO_AVX512",
"-DBLAKE3_NO_AVX2",
"-DBLAKE3_NO_SSE41",
"-DBLAKE3_NO_SSE2",
"-DBLAKE3_USE_NEON=0",
]
if (is_win) {
cflags += [
"/wd4005",
"/wd4018",
"/wd4065",
"/wd4141",
"/wd4146",
"/wd4244",
"/wd4245",
"/wd4267",
"/wd4310",
"/wd4319",
"/wd4334",
"/wd4389",
"/wd4624",
"/wd4701",
"/wd4702",
"/wd4703",
"/wd4706",
"/wd4800",
"/wd4805",
"/wd4828",
]
if (!is_debug) {
cflags += [ "/wd4324" ]
}
if (is_clang) {
cflags += [
"-Wno-format",
"-Wno-sign-compare",
"-Wno-macro-redefined",
]
}
}
if (is_fuchsia) {
# Ignore #warning for unimplemented features in Process.inc.
cflags += [ "-Wno-cpp" ]
}
if (is_clang) {
cflags += [
"-Wno-attributes",
"-Wno-bitwise-instead-of-logical",
"-Wno-deprecated-anon-enum-enum-conversion",
"-Wno-deprecated-declarations",
"-Wno-deprecated-pragma",
"-Wno-deprecated-enum-enum-conversion",
"-Wno-enum-compare",
"-Wno-header-hygiene",
"-Wno-range-loop-bind-reference",
"-Wno-unused-function",
"-Wno-unused-local-typedef",
"-Wno-unused-private-field",
"-Wno-unused-result",
"-Wno-unused-variable",
]
}
defines = [
"__STDC_CONSTANT_MACROS",
"__STDC_LIMIT_MACROS",
]
}
llvm_include_dirs = [
"llvm/include/",
"llvm/lib/Target/AArch64/",
"llvm/lib/Target/ARM/",
"llvm/lib/Target/LoongArch/",
"llvm/lib/Target/Mips/",
"llvm/lib/Target/PowerPC/",
"llvm/lib/Target/RISCV/",
"llvm/lib/Target/X86/",
"configs/common/include/",
"configs/common/lib/ExecutionEngine/JITLink/",
"configs/common/lib/IR/",
"configs/common/lib/Target/AArch64/",
"configs/common/lib/Target/ARM/",
"configs/common/lib/Target/LoongArch/",
"configs/common/lib/Target/Mips/",
"configs/common/lib/Target/PowerPC/",
"configs/common/lib/Target/RISCV/",
"configs/common/lib/Target/X86/",
"configs/common/lib/Transforms/InstCombine/",
]
if (is_linux || is_chromeos) {
llvm_include_dirs += [ "configs/linux/include/" ]
} else if (is_fuchsia) {
llvm_include_dirs += [ "configs/fuchsia/include/" ]
} else if (is_win) {
llvm_include_dirs += [ "configs/windows/include/" ]
} else if (is_android) {
llvm_include_dirs += [ "configs/android/include/" ]
} else if (is_mac) {
llvm_include_dirs += [ "configs/darwin/include/" ]
} else {
assert(false, "llvm-10.0 not configured for target platform")
}
template("swiftshader_llvm_source_set") {
swiftshader_source_set(target_name) {
configs = [ ":swiftshader_llvm_private_config" ]
include_dirs = llvm_include_dirs
forward_variables_from(invoker, "*", [ "configs" ])
if (defined(invoker.configs)) {
configs += invoker.configs
}
}
}
swiftshader_llvm_source_set("swiftshader_llvm") {
# This class is declared on all platforms but only used on ARM. UBSanVPtr
# builds require that all declared classes have a definition even if they're
# not used.
if (is_ubsan_vptr) {
sources = [
"llvm/lib/MC/MCWasmObjectTargetWriter.cpp",
"llvm/lib/MC/MCXCOFFObjectTargetWriter.cpp",
"llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp",
"llvm/lib/Target/TargetIntrinsicInfo.cpp",
]
}
deps = [
%$%llvm_deps
]
if (is_debug) {
deps += [ ":swiftshader_llvm_debug" ]
}
if (current_cpu == "arm64") {
deps += [ ":swiftshader_llvm_aarch64" ]
} else if (current_cpu == "arm") {
deps += [ ":swiftshader_llvm_arm" ]
} else if (current_cpu == "loong64") {
deps += [ ":swiftshader_llvm_loongarch64" ]
} else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
deps += [ ":swiftshader_llvm_mips" ]
} else if (current_cpu == "ppc64") {
deps += [ ":swiftshader_llvm_ppc" ]
} else if (current_cpu == "riscv64") {
deps += [ ":swiftshader_llvm_riscv64" ]
} else if (current_cpu == "x86" || current_cpu == "x64") {
deps += [ ":swiftshader_llvm_x86" ]
} else {
assert(false, "Unsupported current_cpu")
}
if ((current_cpu != current_cpu &&
(current_cpu == "x86" || current_cpu == "x64")) ||
# Windows ARM64 does cross compilation on Windows x64 host, and requires native
# x86 target.
(is_win && current_cpu == "arm64")) {
deps += [ ":swiftshader_llvm_x86" ]
}
}
# This source_set would contain all source files, except that GN doesn't allow for duplicate source
# file names, even if they are in different subdirectories. Because of this, some files are
# split out into their own source_set.
%$%llvm_source_sets
swiftshader_llvm_source_set("swiftshader_llvm_debug") {
sources = [
%$%files_llvm_debug
]
}
swiftshader_llvm_source_set("swiftshader_llvm_aarch64") {
sources = [
%$%files_AArch64
]
}
swiftshader_llvm_source_set("swiftshader_llvm_arm") {
sources = [
%$%files_ARM
]
# When is_ubsan_vptr is true, this file is added to swiftshader_llvm instead.
if (!is_ubsan_vptr) {
sources += [ "llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp" ]
}
}
swiftshader_llvm_source_set("swiftshader_llvm_loongarch64") {
sources = [
%$%files_LoongArch
]
}
swiftshader_llvm_source_set("swiftshader_llvm_mips") {
sources = [
%$%files_Mips
]
}
swiftshader_llvm_source_set("swiftshader_llvm_ppc") {
sources = [
%$%files_PowerPC
]
}
swiftshader_llvm_source_set("swiftshader_llvm_x86") {
sources = [
%$%files_x86
]
}
swiftshader_llvm_source_set("swiftshader_llvm_riscv64") {
sources = [
%$%files_RISCV
]
}