Update BUILD.gn

This commit is contained in:
Alexander David Frick 2022-10-14 22:10:51 -05:00 committed by GitHub
parent a7fc464fef
commit bb56717eb0
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. # the needed gcov profiling data.
auto_profile_path = "" 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 # Path to an AFDO profile to use while building with clang, if any. Empty
# implies none. # implies none.
clang_sample_profile_path = "" clang_sample_profile_path = ""
@ -600,6 +597,15 @@ config("compiler") {
if (is_clang) { if (is_clang) {
cflags_cc += [ "-fno-trigraphs" ] 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 { } else {
cflags_cc += [ "-std=${standard_prefix}++17" ] cflags_cc += [ "-std=${standard_prefix}++17" ]
} }
@ -613,7 +619,12 @@ config("compiler") {
# turned off we need the !is_nacl clause and the (is_nacl && is_clang) # turned off we need the !is_nacl clause and the (is_nacl && is_clang)
# clause, above. # clause, above.
cflags_c += [ "-std=c11" ] 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") { if (is_clang && current_os != "zos") {
@ -736,6 +747,12 @@ config("compiler") {
ldflags += [ "-Wl,--no-rosegment" ] 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 # 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 # 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 # jumps. Turn it off by default and enable selectively for targets where it's
@ -1196,6 +1213,15 @@ config("compiler_cpu_abi") {
ldflags += [ "--target=riscv64-linux-gnu" ] ldflags += [ "--target=riscv64-linux-gnu" ]
} }
cflags += [ "-mabi=lp64d" ] 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") { } else if (current_cpu == "s390x") {
cflags += [ "-m64" ] cflags += [ "-m64" ]
ldflags += [ "-m64" ] ldflags += [ "-m64" ]
@ -1241,6 +1267,7 @@ config("compiler_codegen") {
config("compiler_deterministic") { config("compiler_deterministic") {
cflags = [] cflags = []
ldflags = [] ldflags = []
swiftflags = []
# Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
# deterministic build. See https://crbug.com/314403 # deterministic build. See https://crbug.com/314403
@ -1281,6 +1308,7 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir= # -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=. # and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ] cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
} }
if (!is_win) { if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167) # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1527,6 +1555,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) { if (is_clang) {
cflags += [ cflags += [
"-Wloop-analysis", "-Wloop-analysis",
@ -1547,11 +1585,6 @@ config("default_warnings") {
cflags += [ cflags += [
"-Wenum-compare-conditional", "-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. # Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize", "-Wno-ignored-pragma-optimize",
@ -1650,7 +1683,7 @@ config("chromium_code") {
if (!is_debug && !using_sanitizer && current_cpu != "s390x" && if (!is_debug && !using_sanitizer && current_cpu != "s390x" &&
current_cpu != "s390" && current_cpu != "ppc64" && current_cpu != "s390" && current_cpu != "ppc64" &&
current_cpu != "mips" && current_cpu != "mips64" && 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 # Non-chromium code is not guaranteed to compile cleanly with
# _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
# disabled, so only do that for Release build. # disabled, so only do that for Release build.
@ -1960,6 +1993,9 @@ config("no_incompatible_pointer_warnings") {
"-mllvm", "-unroll-runtime-multi-exit", "-mllvm", "-unroll-runtime-multi-exit",
"-mllvm", "-aggressive-ext-opt", "-mllvm", "-aggressive-ext-opt",
"-mllvm", "-polly", "-mllvm", "-polly",
"-mllvm", "-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm", "-polly-invariant-load-hoisting",
"-mllvm", "-polly-vectorizer=stripmine",
"/O3", "/O3",
"/clang:-O3", "/clang:-O3",
"/clang:-msse3", "/clang:-msse3",
@ -2011,6 +2047,9 @@ if (is_win) {
"-mllvm", "-unroll-runtime-multi-exit", "-mllvm", "-unroll-runtime-multi-exit",
"-mllvm", "-aggressive-ext-opt", "-mllvm", "-aggressive-ext-opt",
"-mllvm", "-polly", "-mllvm", "-polly",
"-mllvm", "-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm", "-polly-invariant-load-hoisting",
"-mllvm", "-polly-vectorizer=stripmine",
"/O3", "/O3",
"/clang:-O3", "/clang:-O3",
"/clang:-msse3", "/clang:-msse3",
@ -2059,6 +2098,9 @@ if (is_win) {
"-mllvm", "-unroll-runtime-multi-exit", "-mllvm", "-unroll-runtime-multi-exit",
"-mllvm", "-aggressive-ext-opt", "-mllvm", "-aggressive-ext-opt",
"-mllvm", "-polly", "-mllvm", "-polly",
"-mllvm", "-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm", "-polly-invariant-load-hoisting",
"-mllvm", "-polly-vectorizer=stripmine",
"-O3", "-O3",
] ]
@ -2157,7 +2199,7 @@ config("optimize") {
} else { } else {
# PGO requires all translation units to be compiled with /O2. The actual # PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data. # 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) { } else if (optimize_for_size) {
# Favor size over speed. # Favor size over speed.
@ -2518,7 +2560,7 @@ config("symbols") {
# Compress debug on 32-bit ARM to stay under 4GB for ChromeOS # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
# https://b/243982712. # https://b/243982712.
if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && 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" ] configs += [ "//build/config:compress_debug_sections" ]
} }