Update BUILD.gn

This commit is contained in:
Alexander David Frick 2022-10-14 22:22:23 -05:00 committed by GitHub
parent bb56717eb0
commit a6286bd6ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,9 +85,6 @@ declare_args() {
# the needed gcov profiling data.
auto_profile_path = ""
# Allow projects that wish to stay on C++11 to override Chromium's default.
use_cxx11 = false
# Path to an AFDO profile to use while building with clang, if any. Empty
# implies none.
clang_sample_profile_path = ""
@ -593,6 +590,15 @@ config("compiler") {
if (is_clang) {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_linux) {
# TODO(crbug.com/1284275): Switch to C++20 on all platforms.
if (is_clang) {
cflags_cc += [ "-std=${standard_prefix}++20" ]
} else {
# The gcc bots are currently using GCC 9, which is not new enough to
# support "c++20"/"gnu++20".
cflags_cc += [ "-std=${standard_prefix}++2a" ]
}
} else {
cflags_cc += [ "-std=${standard_prefix}++17" ]
}
@ -606,7 +612,12 @@ config("compiler") {
# turned off we need the !is_nacl clause and the (is_nacl && is_clang)
# clause, above.
cflags_c += [ "-std=c11" ]
cflags_cc += [ "-std=c++17" ]
if (is_apple) {
# TODO(crbug.com/1284275): Switch to C++20 on all platforms.
cflags_cc += [ "-std=c++20" ]
} else {
cflags_cc += [ "-std=c++17" ]
}
}
if (is_clang && current_os != "zos") {
@ -729,6 +740,12 @@ config("compiler") {
ldflags += [ "-Wl,--no-rosegment" ]
}
# TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
# --no-undefined-version.
if (use_lld && !is_win && !is_mac && !is_ios) {
ldflags += [ "-Wl,--undefined-version" ]
}
# LLD does call-graph-sorted binary layout by default when profile data is
# present. On Android this increases binary size due to more thinks for long
# jumps. Turn it off by default and enable selectively for targets where it's
@ -1191,6 +1208,15 @@ config("compiler_cpu_abi") {
ldflags += [ "--target=riscv64-linux-gnu" ]
}
cflags += [ "-mabi=lp64d" ]
} else if (current_cpu == "loong64") {
if (is_clang) {
cflags += [ "--target=loongarch64-linux-gnu" ]
ldflags += [ "--target=loongarch64-linux-gnu" ]
}
cflags += [
"-mabi=lp64d",
"-mcmodel=medium",
]
} else if (current_cpu == "s390x") {
cflags += [ "-m64" ]
ldflags += [ "-m64" ]
@ -1236,6 +1262,7 @@ config("compiler_codegen") {
config("compiler_deterministic") {
cflags = []
ldflags = []
swiftflags = []
# Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
# deterministic build. See https://crbug.com/314403
@ -1276,6 +1303,7 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1522,6 +1550,16 @@ config("default_warnings") {
]
}
if (!is_nacl || is_nacl_saigo) {
cflags += [
# An ABI compat warning we don't care about, https://crbug.com/1102157
# TODO(thakis): Push this to the (few) targets that need it,
# instead of having a global flag.
"-Wno-psabi",
]
}
}
if (is_clang) {
cflags += [
"-Wloop-analysis",
@ -1542,11 +1580,6 @@ config("default_warnings") {
cflags += [
"-Wenum-compare-conditional",
# An ABI compat warning we don't care about, https://crbug.com/1102157
# TODO(thakis): Push this to the (few) targets that need it,
# instead of having a global flag.
"-Wno-psabi",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1645,7 +1678,7 @@ config("chromium_code") {
if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
current_cpu != "s390" && current_cpu != "ppc64" &&
current_cpu != "mips" && current_cpu != "mips64" &&
current_cpu != "riscv64") {
current_cpu != "riscv64" && current_cpu != "loong64") {
# Non-chromium code is not guaranteed to compile cleanly with
# _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
# disabled, so only do that for Release build.
@ -1955,6 +1988,9 @@ config("no_incompatible_pointer_warnings") {
"-mllvm", "-unroll-runtime-multi-exit",
"-mllvm", "-aggressive-ext-opt",
"-mllvm", "-polly",
"-mllvm", "-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm", "-polly-invariant-load-hoisting",
"-mllvm", "-polly-vectorizer=stripmine",
"/O3",
"/clang:-O3",
"/clang:-mavx2",
@ -2007,6 +2043,9 @@ if (is_win) {
"-mllvm", "-unroll-runtime-multi-exit",
"-mllvm", "-aggressive-ext-opt",
"-mllvm", "-polly",
"-mllvm", "-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm", "-polly-invariant-load-hoisting",
"-mllvm", "-polly-vectorizer=stripmine",
"/O3",
"/clang:-O3",
"/clang:-mavx2",
@ -2056,6 +2095,9 @@ if (is_win) {
"-mllvm", "-unroll-runtime-multi-exit",
"-mllvm", "-aggressive-ext-opt",
"-mllvm", "-polly",
"-mllvm", "-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm", "-polly-invariant-load-hoisting",
"-mllvm", "-polly-vectorizer=stripmine",
"-O3",
]
@ -2154,7 +2196,7 @@ config("optimize") {
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
cflags = [ "/O3" ] + common_optimize_on_cflags + [ "/Oi" ]
}
} else if (optimize_for_size) {
# Favor size over speed.
@ -2515,7 +2557,7 @@ config("symbols") {
# Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
# https://b/243982712.
if (symbol_level == 2 && is_chromeos_device && !use_debug_fission &&
!is_nacl && current_cpu == "arm") {
!is_nacl && current_cpu == "arm") {
configs += [ "//build/config:compress_debug_sections" ]
}
@ -2536,7 +2578,7 @@ config("symbols") {
]
}
}
rustflags = [ "-g0", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
rustflags = [ "-g", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
}
# Minimal symbols.