2018-11-17 03:21:53 +01:00
|
|
|
import("//llvm/utils/gn/build/buildflags.gni")
|
|
|
|
import("//llvm/utils/gn/build/mac_sdk.gni")
|
|
|
|
import("//llvm/utils/gn/build/toolchain/compiler.gni")
|
2019-01-15 22:24:00 +01:00
|
|
|
import("//llvm/utils/gn/build/toolchain/target_flags.gni")
|
2018-11-17 03:21:53 +01:00
|
|
|
|
|
|
|
config("compiler_defaults") {
|
2018-12-13 00:57:21 +01:00
|
|
|
defines = []
|
|
|
|
|
2018-11-17 03:21:53 +01:00
|
|
|
if (!llvm_enable_assertions) {
|
|
|
|
defines += [ "NDEBUG" ]
|
|
|
|
}
|
|
|
|
|
2019-01-15 22:24:00 +01:00
|
|
|
cflags = target_flags + target_cflags
|
|
|
|
ldflags = target_flags + target_ldflags
|
2018-11-17 03:21:53 +01:00
|
|
|
|
|
|
|
if (host_os == "mac" && clang_base_path != "") {
|
|
|
|
cflags += [
|
|
|
|
"-isysroot",
|
|
|
|
mac_sdk_path,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host_os != "win") {
|
|
|
|
if (is_debug) {
|
|
|
|
cflags += [ "-g" ]
|
|
|
|
} else {
|
|
|
|
cflags += [ "-O3" ]
|
|
|
|
}
|
|
|
|
cflags += [ "-fdiagnostics-color" ]
|
|
|
|
cflags_cc = [
|
|
|
|
"-std=c++11",
|
|
|
|
"-fno-exceptions",
|
|
|
|
"-fvisibility-inlines-hidden",
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
if (is_debug) {
|
|
|
|
cflags += [ "/Zi" ]
|
|
|
|
} else {
|
|
|
|
cflags += [
|
|
|
|
"/O2",
|
|
|
|
"/Zc:inline",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
defines += [
|
|
|
|
"_CRT_SECURE_NO_DEPRECATE",
|
|
|
|
"_CRT_SECURE_NO_WARNINGS",
|
|
|
|
"_CRT_NONSTDC_NO_DEPRECATE",
|
|
|
|
"_CRT_NONSTDC_NO_WARNINGS",
|
|
|
|
"_SCL_SECURE_NO_DEPRECATE",
|
|
|
|
"_SCL_SECURE_NO_WARNINGS",
|
|
|
|
|
|
|
|
"_HAS_EXCEPTIONS=0",
|
|
|
|
"_UNICODE",
|
|
|
|
"UNICODE",
|
|
|
|
]
|
2019-01-15 03:43:33 +01:00
|
|
|
cflags += [ "/EHs-c-" ]
|
2018-11-17 03:21:53 +01:00
|
|
|
|
|
|
|
# The MSVC default value (1 MB) is not enough for parsing recursive C++
|
|
|
|
# templates in Clang.
|
|
|
|
ldflags = [ "/STACK:10000000" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Warning setup.
|
|
|
|
if (host_os == "win" && !is_clang) {
|
|
|
|
cflags += [
|
|
|
|
# Suppress ''modifier' : used more than once' (__forceinline and inline).
|
|
|
|
"-wd4141",
|
|
|
|
|
|
|
|
# Suppress 'conversion from 'type1' to 'type2', possible loss of data'.
|
|
|
|
"-wd4244",
|
|
|
|
|
|
|
|
# Suppress 'conversion from 'size_t' to 'type', possible loss of data'.
|
|
|
|
"-wd4267",
|
|
|
|
|
|
|
|
# Suppress 'no matching operator delete found'.
|
|
|
|
"-wd4291",
|
|
|
|
|
|
|
|
# Suppress 'noexcept used with no exception handling mode specified'.
|
|
|
|
"-wd4577",
|
|
|
|
|
|
|
|
# Suppress 'destructor was implicitly defined as deleted'.
|
|
|
|
"-wd4624",
|
|
|
|
|
|
|
|
# Suppress 'unsafe mix of type <type> and type <type> in operation'.
|
|
|
|
"-wd4805",
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
if (host_os == "win") {
|
|
|
|
cflags += [ "/W4" ]
|
|
|
|
} else {
|
|
|
|
cflags += [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
]
|
|
|
|
}
|
2019-01-25 01:29:17 +01:00
|
|
|
cflags += [ "-Wno-unused-parameter" ]
|
2018-11-17 03:21:53 +01:00
|
|
|
if (is_clang) {
|
2019-01-25 01:29:17 +01:00
|
|
|
cflags += [
|
|
|
|
"-Wdelete-non-virtual-dtor",
|
|
|
|
"-Wstring-conversion",
|
|
|
|
]
|
|
|
|
} else {
|
|
|
|
cflags += [
|
|
|
|
# GCC's -Wcomment complains about // comments ending with '\' if the
|
|
|
|
# next line is also a // comment.
|
|
|
|
"-Wno-comment",
|
|
|
|
|
|
|
|
# Disable gcc's potentially uninitialized use analysis as it presents
|
|
|
|
# lots of false positives.
|
|
|
|
"-Wno-maybe-uninitialized",
|
|
|
|
]
|
|
|
|
cflags_cc += [
|
|
|
|
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not
|
|
|
|
# useful.
|
|
|
|
"-Wno-noexcept-type",
|
|
|
|
]
|
2018-11-17 03:21:53 +01:00
|
|
|
}
|
|
|
|
if (is_clang && use_goma) {
|
|
|
|
# goma converts all paths to lowercase on the server, breaking this
|
|
|
|
# warning.
|
|
|
|
cflags += [ "-Wno-nonportable-include-path" ]
|
|
|
|
}
|
|
|
|
}
|
2019-01-15 22:24:00 +01:00
|
|
|
|
2019-01-28 20:32:52 +01:00
|
|
|
# On Windows, the linker is not invoked through the compiler driver.
|
|
|
|
if (use_lld && host_os != "win") {
|
2019-01-15 22:24:00 +01:00
|
|
|
ldflags += [ "-fuse-ld=lld" ]
|
|
|
|
}
|
2018-11-17 03:21:53 +01:00
|
|
|
}
|
|
|
|
|
2019-01-15 03:43:33 +01:00
|
|
|
config("no_rtti") {
|
|
|
|
if (current_os == "win") {
|
|
|
|
cflags_cc = [ "/GR-" ]
|
|
|
|
} else {
|
|
|
|
cflags_cc = [ "-fno-rtti" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-17 03:21:53 +01:00
|
|
|
config("llvm_code") {
|
|
|
|
include_dirs = [
|
|
|
|
"//llvm/include",
|
|
|
|
"$root_gen_dir/llvm/include",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
config("lld_code") {
|
|
|
|
include_dirs = [
|
|
|
|
"//lld/include",
|
|
|
|
"$root_gen_dir/lld/include",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
config("clang_code") {
|
2019-01-25 01:29:17 +01:00
|
|
|
if (host_os != "win") {
|
|
|
|
cflags = [ "-fno-strict-aliasing" ]
|
|
|
|
}
|
2018-11-17 03:21:53 +01:00
|
|
|
include_dirs = [
|
|
|
|
"//clang/include",
|
|
|
|
"$root_gen_dir/clang/include",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-01-15 22:08:21 +01:00
|
|
|
config("crt_code") {
|
|
|
|
include_dirs = [ "//compiler-rt/lib" ]
|
|
|
|
cflags = [
|
|
|
|
"-fPIC",
|
|
|
|
"-funwind-tables",
|
|
|
|
"-gline-tables-only",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-11-17 03:21:53 +01:00
|
|
|
config("warn_covered_switch_default") {
|
|
|
|
if (is_clang) {
|
|
|
|
cflags = [ "-Wcovered-switch-default" ]
|
|
|
|
}
|
|
|
|
}
|