Update BUILD.gn
This commit is contained in:
parent
0209e9555a
commit
00b623fca8
1 changed files with 89 additions and 83 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2022 The Chromium Authors and Alex313031. All rights reserved.
|
||||
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
@ -106,7 +106,8 @@ declare_args() {
|
|||
chromeos_afdo_platform = "atom"
|
||||
|
||||
# Emit debug information for profiling wile building with clang.
|
||||
clang_emit_debug_info_for_profiling = false
|
||||
# Only enable this for ChromeOS official builds for AFDO.
|
||||
clang_emit_debug_info_for_profiling = is_chromeos_device && is_official_build
|
||||
|
||||
# Turn this on to have the compiler output extra timing information.
|
||||
compiler_timing = false
|
||||
|
@ -163,6 +164,10 @@ declare_args() {
|
|||
# Enable -H, which prints the include tree during compilation.
|
||||
# For use by tools/clang/scripts/analyze_includes.py
|
||||
show_includes = false
|
||||
|
||||
# If true, linker crashes will be rerun with `--reproduce` which causes
|
||||
# a reproducer file to be saved.
|
||||
save_reproducers_on_lld_crash = false
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
|
@ -526,6 +531,12 @@ config("compiler") {
|
|||
|
||||
if (is_clang && !is_nacl && current_os != "zos") {
|
||||
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
|
||||
if (save_reproducers_on_lld_crash && use_lld) {
|
||||
ldflags += [
|
||||
"-fcrash-diagnostics=all",
|
||||
"-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
|
||||
]
|
||||
}
|
||||
|
||||
# TODO(hans): Remove this once Clang generates better optimized debug info
|
||||
# by default. https://crbug.com/765793
|
||||
|
@ -540,14 +551,6 @@ config("compiler") {
|
|||
ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (default_toolchain != "//build/toolchain/cros:target") {
|
||||
# TODO(crbug.com/1361629): Fix the compiler so this is not needed.
|
||||
cflags += [
|
||||
"-mllvm",
|
||||
"-simplifycfg-hoist-common-skip-limit=0",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
# Rust compiler setup (for either clang or rustc).
|
||||
|
@ -590,21 +593,25 @@ 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) {
|
||||
} else if (is_clang) {
|
||||
if (is_chromeos_device) {
|
||||
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
|
||||
cflags_cc += [ "-std=${standard_prefix}++17" ]
|
||||
} else {
|
||||
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" ]
|
||||
}
|
||||
} else if (is_win) {
|
||||
cflags_c += [ "/std:c11" ]
|
||||
if (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17) {
|
||||
cflags_cc += [ "/std:c++17" ]
|
||||
} else {
|
||||
cflags_cc += [ "/std:c++20" ]
|
||||
}
|
||||
} else if (!is_nacl) {
|
||||
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
|
||||
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
|
||||
|
@ -612,11 +619,13 @@ config("compiler") {
|
|||
# turned off we need the !is_nacl clause and the (is_nacl && is_clang)
|
||||
# clause, above.
|
||||
cflags_c += [ "-std=c11" ]
|
||||
if (is_apple) {
|
||||
# TODO(crbug.com/1284275): Switch to C++20 on all platforms.
|
||||
cflags_cc += [ "-std=c++20" ]
|
||||
} else {
|
||||
|
||||
if (is_fuchsia) {
|
||||
# TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that
|
||||
# will not compile in C++20 mode. Switch to C++20 when this is resolved.
|
||||
cflags_cc += [ "-std=c++17" ]
|
||||
} else {
|
||||
cflags_cc += [ "-std=c++20" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,10 +684,14 @@ config("compiler") {
|
|||
# of "all" which means number of hardware threads) is faster.
|
||||
ldflags += [ "-Wl,--thinlto-jobs=all" ]
|
||||
if (is_apple) {
|
||||
_object_path_suffix = ""
|
||||
if (is_ios) {
|
||||
_object_path_suffix = ",persist"
|
||||
}
|
||||
ldflags += [
|
||||
"-Wl,-cache_path_lto," +
|
||||
rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
|
||||
"-Wcrl,object_path_lto",
|
||||
"-Wcrl,object_path_lto" + _object_path_suffix,
|
||||
]
|
||||
} else {
|
||||
ldflags +=
|
||||
|
@ -782,6 +795,17 @@ config("compiler") {
|
|||
cflags += [ "-fcomplete-member-pointers" ]
|
||||
}
|
||||
|
||||
# Use DWARF simple template names, with the following exceptions:
|
||||
#
|
||||
# * Windows is not supported as it doesn't use DWARF.
|
||||
# * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode
|
||||
# lldb doesn't have the needed changes yet.
|
||||
# * Fuchsia isn't supported as zxdb doesn't support simple template names yet.
|
||||
# TODO(crbug.com/1379070): Remove if the upstream default ever changes.
|
||||
if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) {
|
||||
cflags_cc += [ "-gsimple-template-names" ]
|
||||
}
|
||||
|
||||
# MLGO specific flags. These flags enable an ML-based inliner trained on
|
||||
# Chrome on Android (arm32) with ThinLTO enabled, optimizing for size.
|
||||
# The "release" ML model is embedded into clang as part of its build.
|
||||
|
@ -836,6 +860,9 @@ config("compiler") {
|
|||
# For deterministic builds, keep the local machine's current working
|
||||
# directory from appearing in build outputs.
|
||||
"-Zremap-cwd-prefix=.",
|
||||
|
||||
# Full RUSTC optimizations.
|
||||
"-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul",
|
||||
]
|
||||
if (rust_abi_target != "") {
|
||||
rustflags += [ "--target=$rust_abi_target" ]
|
||||
|
@ -852,7 +879,7 @@ config("compiler") {
|
|||
rustflags += [ "-Cembed-bitcode=no" ]
|
||||
}
|
||||
if (is_official_build) {
|
||||
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -864,6 +891,7 @@ config("thinlto_optimize_default") {
|
|||
|
||||
if (is_win) {
|
||||
ldflags = [ "/opt:lldlto=" + lto_opt_level ]
|
||||
ldflags += [ "-mllvm:-enable-pre=false", ]
|
||||
} else {
|
||||
ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
|
||||
}
|
||||
|
@ -888,6 +916,7 @@ config("thinlto_optimize_max") {
|
|||
|
||||
if (is_win) {
|
||||
ldflags = [ "/opt:lldlto=" + lto_opt_level ]
|
||||
ldflags += [ "-mllvm:-enable-pre=false", ]
|
||||
} else {
|
||||
ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
|
||||
}
|
||||
|
@ -924,7 +953,7 @@ config("compiler_cpu_abi") {
|
|||
ldflags += [ "-m64", "-Wl,-O3", "-Wl,-mllvm,-march=haswell", "-mvaes", "-Wl,-mllvm,-fp-contract=fast", "-Wl,-mllvm,-import-instr-limit=30", "-Wl,-mllvm,-import-hot-multiplier=15", "-Wl,-mllvm,-import-cold-multiplier=4", ]
|
||||
} else if (current_cpu == "x86") {
|
||||
cflags += [ "-m32" ]
|
||||
ldflags += [ "-m32" ]
|
||||
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
|
||||
if (!is_nacl) {
|
||||
cflags += [
|
||||
"-mfpmath=sse",
|
||||
|
@ -959,8 +988,7 @@ config("compiler_cpu_abi") {
|
|||
ldflags += [ "--target=aarch64-linux-gnu", "-Wl,-O3", "-Wno-unused-command-line-argument", ]
|
||||
}
|
||||
if (is_android) {
|
||||
# Outline atomics crash on Exynos 9810. http://crbug.com/1272795
|
||||
cflags += [ "-mno-outline-atomics", "-O3", ]
|
||||
cflags += [ "-O3", ]
|
||||
ldflags += [ "-Wl,-O3", ]
|
||||
}
|
||||
} else if (current_cpu == "mipsel" && !is_nacl) {
|
||||
|
@ -1587,7 +1615,6 @@ config("default_warnings") {
|
|||
|
||||
if (!is_nacl) {
|
||||
cflags += [
|
||||
|
||||
# TODO(crbug.com/1343975) Evaluate and possibly enable.
|
||||
"-Wno-deprecated-builtins",
|
||||
|
||||
|
@ -1973,41 +2000,14 @@ config("no_incompatible_pointer_warnings") {
|
|||
# Shared settings for both "optimize" and "optimize_max" configs.
|
||||
# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
|
||||
|
||||
common_optimize_on_cflags = [ "-O3", ]
|
||||
common_optimize_on_ldflags = [ "-Wl,-O3", ]
|
||||
|
||||
if (is_win) {
|
||||
|
||||
common_optimize_on_cflags = []
|
||||
common_optimize_on_ldflags = []
|
||||
|
||||
common_optimize_on_cflags += [
|
||||
"-mllvm", "-extra-vectorizer-passes",
|
||||
"-mllvm", "-enable-cond-stores-vec",
|
||||
"-mllvm", "-slp-vectorize-hor-store",
|
||||
"-mllvm", "-enable-loopinterchange",
|
||||
"-mllvm", "-enable-loop-distribute",
|
||||
"-mllvm", "-enable-unroll-and-jam",
|
||||
"-mllvm", "-enable-loop-flatten",
|
||||
"-mllvm", "-interleave-small-loop-scalar-reduction",
|
||||
"-mllvm", "-unroll-runtime-multi-exit",
|
||||
"-mllvm", "-aggressive-ext-opt",
|
||||
"/O3",
|
||||
"/clang:-O3",
|
||||
"/clang:-mavx2",
|
||||
"/clang:-maes",
|
||||
"-Xclang", "-O3",
|
||||
]
|
||||
|
||||
common_optimize_on_ldflags += [
|
||||
"-mllvm:-extra-vectorizer-passes",
|
||||
"-mllvm:-enable-cond-stores-vec",
|
||||
"-mllvm:-slp-vectorize-hor-store",
|
||||
"-mllvm:-enable-loopinterchange",
|
||||
"-mllvm:-enable-loop-distribute",
|
||||
"-mllvm:-enable-unroll-and-jam",
|
||||
"-mllvm:-enable-loop-flatten",
|
||||
"-mllvm:-interleave-small-loop-scalar-reduction",
|
||||
"-mllvm:-unroll-runtime-multi-exit",
|
||||
"-mllvm:-aggressive-ext-opt",
|
||||
]
|
||||
|
||||
if (is_win) {
|
||||
common_optimize_on_cflags += [
|
||||
"/Ob2", # Both explicit and auto inlining.
|
||||
"/Oy-", # Disable omitting frame pointers, must be after /O2.
|
||||
|
@ -2024,8 +2024,6 @@ if (is_win) {
|
|||
"/Gw",
|
||||
]
|
||||
}
|
||||
common_optimize_on_cflags = []
|
||||
common_optimize_on_ldflags = []
|
||||
|
||||
common_optimize_on_cflags += [
|
||||
"-mllvm", "-extra-vectorizer-passes",
|
||||
|
@ -2038,10 +2036,14 @@ if (is_win) {
|
|||
"-mllvm", "-interleave-small-loop-scalar-reduction",
|
||||
"-mllvm", "-unroll-runtime-multi-exit",
|
||||
"-mllvm", "-aggressive-ext-opt",
|
||||
"-mllvm", "-enable-interleaved-mem-accesses",
|
||||
"/O3",
|
||||
"/clang:-O3",
|
||||
"/clang:-mavx",
|
||||
"/clang:-mavx2",
|
||||
"/clang:-maes",
|
||||
"/clang:-mvaes",
|
||||
"/clang:-mpclmul",
|
||||
"-Xclang", "-O3",
|
||||
]
|
||||
|
||||
|
@ -2056,11 +2058,11 @@ if (is_win) {
|
|||
"-mllvm:-interleave-small-loop-scalar-reduction",
|
||||
"-mllvm:-unroll-runtime-multi-exit",
|
||||
"-mllvm:-aggressive-ext-opt",
|
||||
"-mllvm:-enable-interleaved-mem-accesses",
|
||||
]
|
||||
|
||||
# /OPT:ICF is not desirable in Debug builds, since code-folding can result in
|
||||
# misleading symbols in stack traces.
|
||||
|
||||
if (!is_debug && !is_component_build) {
|
||||
common_optimize_on_ldflags += [ "/OPT:ICF" ] # Redundant COMDAT folding.
|
||||
}
|
||||
|
@ -2086,6 +2088,7 @@ if (is_win) {
|
|||
"-mllvm", "-interleave-small-loop-scalar-reduction",
|
||||
"-mllvm", "-unroll-runtime-multi-exit",
|
||||
"-mllvm", "-aggressive-ext-opt",
|
||||
"-mllvm", "-enable-interleaved-mem-accesses",
|
||||
"-O3",
|
||||
]
|
||||
|
||||
|
@ -2100,6 +2103,8 @@ if (is_win) {
|
|||
"-Wl,-mllvm,-interleave-small-loop-scalar-reduction",
|
||||
"-Wl,-mllvm,-unroll-runtime-multi-exit",
|
||||
"-Wl,-mllvm,-aggressive-ext-opt",
|
||||
"-Wl,-mllvm,-enable-interleaved-mem-accesses",
|
||||
"-Wl,-O3",
|
||||
]
|
||||
|
||||
if (is_android) {
|
||||
|
@ -2131,11 +2136,12 @@ if (is_win) {
|
|||
# can be removed at link time with --gc-sections.
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-funique-section-names",
|
||||
]
|
||||
if ((!is_nacl || is_nacl_saigo) && is_clang) {
|
||||
# We don't care about unique section names, this makes object files a bit
|
||||
# smaller.
|
||||
common_optimize_on_cflags += [ "-fno-unique-section-names" ]
|
||||
# common_optimize_on_cflags += [ "-fno-unique-section-names" ]
|
||||
}
|
||||
|
||||
common_optimize_on_ldflags += [
|
||||
|
@ -2180,11 +2186,11 @@ config("optimize") {
|
|||
if (chrome_pgo_phase != 2) {
|
||||
# Favor size over speed, /O1 must be before the common flags.
|
||||
# /O1 implies /Os and /GF.
|
||||
cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
|
||||
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
|
||||
} else {
|
||||
# PGO requires all translation units to be compiled with /O2. The actual
|
||||
# optimization level will be decided based on the profiling data.
|
||||
cflags = [ "/O3" ] + common_optimize_on_cflags + [ "/Oi" ]
|
||||
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
|
||||
}
|
||||
} else if (optimize_for_size) {
|
||||
# Favor size over speed.
|
||||
|
@ -2212,9 +2218,9 @@ config("optimize") {
|
|||
cflags = [ "-O3" ] + common_optimize_on_cflags
|
||||
}
|
||||
if (optimize_for_size) {
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
} else {
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
}
|
||||
ldflags = common_optimize_on_ldflags
|
||||
}
|
||||
|
@ -2276,13 +2282,13 @@ config("optimize_max") {
|
|||
if (is_win) {
|
||||
# Favor speed over size, /O2 must be before the common flags.
|
||||
# /O2 implies /Ot, /Oi, and /GF.
|
||||
cflags = [ "-Xclang", "-O3", ] + common_optimize_on_cflags
|
||||
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
|
||||
} else if (optimize_for_fuzzing) {
|
||||
cflags = [ "-O3" ] + common_optimize_on_cflags
|
||||
} else {
|
||||
cflags = [ "-O3" ] + common_optimize_on_cflags
|
||||
}
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2309,19 +2315,19 @@ config("optimize_speed") {
|
|||
if (is_win) {
|
||||
# Favor speed over size, /O2 must be before the common flags.
|
||||
# /O2 implies /Ot, /Oi, and /GF.
|
||||
cflags = [ "-Xclang", "-O3", ] + common_optimize_on_cflags
|
||||
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
|
||||
} else if (optimize_for_fuzzing) {
|
||||
cflags = [ "-O3" ] + common_optimize_on_cflags
|
||||
} else {
|
||||
cflags = [ "-O3" ] + common_optimize_on_cflags
|
||||
}
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
}
|
||||
}
|
||||
|
||||
config("optimize_fuzzing") {
|
||||
cflags = [ "-O3" ] + common_optimize_on_cflags
|
||||
rustflags = [ "-Copt-level=3" ]
|
||||
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
ldflags = common_optimize_on_ldflags
|
||||
visibility = [ ":default_optimization" ]
|
||||
}
|
||||
|
@ -2467,7 +2473,8 @@ config("symbols") {
|
|||
cflags += [ "-fno-standalone-debug" ]
|
||||
}
|
||||
|
||||
if (!is_nacl) {
|
||||
# On aix -gdwarf causes linker failures due to thread_local variables.
|
||||
if (!is_nacl && current_os != "aix") {
|
||||
if (use_dwarf5) {
|
||||
cflags += [ "-gdwarf-5" ]
|
||||
} else if (!is_apple) {
|
||||
|
@ -2495,9 +2502,6 @@ config("symbols") {
|
|||
# It is skipped in tsan and asan because enabling it causes some
|
||||
# formatting changes in the output which would require fixing bunches
|
||||
# of expectation regexps.
|
||||
#
|
||||
# It is skipped when generating bitcode is enabled as -gdwars-aranges
|
||||
# is incompatible with -fembed-bitcode/-fembed-bitcode-marker.
|
||||
cflags += [ "-gdwarf-aranges" ]
|
||||
}
|
||||
|
||||
|
@ -2542,6 +2546,7 @@ config("symbols") {
|
|||
}
|
||||
|
||||
configs = []
|
||||
|
||||
# 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 &&
|
||||
|
@ -2566,7 +2571,7 @@ config("symbols") {
|
|||
]
|
||||
}
|
||||
}
|
||||
rustflags = [ "-g0", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags = [ "-g", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
}
|
||||
|
||||
# Minimal symbols.
|
||||
|
@ -2600,7 +2605,8 @@ config("minimal_symbols") {
|
|||
# at least 10.11.
|
||||
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
|
||||
cflags += [ "-gdwarf-4" ]
|
||||
} else if (!use_dwarf5 && !is_nacl) {
|
||||
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
|
||||
# On aix -gdwarf causes linker failures due to thread_local variables.
|
||||
# Recent clang versions default to DWARF5 on Linux, and Android is about
|
||||
# to switch. TODO: Adopt that in controlled way.
|
||||
cflags += [ "-gdwarf-4" ]
|
||||
|
@ -2638,7 +2644,7 @@ config("minimal_symbols") {
|
|||
|
||||
asmflags = cflags
|
||||
}
|
||||
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2", ]
|
||||
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
|
||||
}
|
||||
|
||||
# This configuration contains function names only. That is, the compiler is
|
||||
|
|
Loading…
Reference in a new issue