update main BUILD.gns

This commit is contained in:
Alexander Frick 2023-04-28 03:32:08 -05:00
parent 52ff9f7513
commit 0dfe6cd0b2
6 changed files with 209 additions and 132 deletions

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
# Copyright 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.
@ -172,6 +172,11 @@ declare_args() {
# For use by tools/clang/scripts/analyze_includes.py
show_includes = false
# Enable Profi algorithm. Profi can infer block and edge counts.
# https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# TODO(crbug.com/1375958i:) Possibly enable this for Android too.
use_profi = is_chromeos
# If true, linker crashes will be rerun with `--reproduce` which causes
# a reproducer file to be saved.
save_reproducers_on_lld_crash = false
@ -617,8 +622,7 @@ config("compiler") {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_clang) {
if (is_chromeos_device || use_cxx17) {
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
if (use_cxx17) {
cflags_cc += [ "-std=${standard_prefix}++17" ]
} else {
cflags_cc += [ "-std=${standard_prefix}++20" ]
@ -643,9 +647,7 @@ config("compiler") {
# clause, above.
cflags_c += [ "-std=c11" ]
if (is_fuchsia || use_cxx17) {
# 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.
if (use_cxx17) {
cflags_cc += [ "-std=c++17" ]
} else {
cflags_cc += [ "-std=c++20" ]
@ -841,9 +843,8 @@ config("compiler") {
# * 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) {
if (is_clang && !is_nacl && !is_win && !is_apple) {
cflags_cc += [ "-gsimple-template-names" ]
}
@ -891,6 +892,13 @@ config("compiler") {
# we discover a reason to turn them off.
"-Coverflow-checks=on",
# By default Rust passes `-nodefaultlibs` to the linker, however this
# conflicts with our `--unwind=none` flag for Android dylibs, as the latter
# is then unused and produces a warning/error. So this removes the
# `-nodefaultlibs` from the linker invocation from Rust, which would be used
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
@ -1333,9 +1341,10 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && is_android) {
# On arm64 disable outlining for Android. See crbug.com/931297 for more
# information.
if (current_cpu == "arm64" && !is_win) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
cflags += [ "-mno-outline" ]
# This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
@ -1459,16 +1468,13 @@ config("clang_revision") {
}
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
# recompiled after a rustc roll. Nothing should ever read this cfg.
# $rustc_version is a gn arg set within //build/config/rust.gni
# so that users using a custom Rust toolchain can override it.
# Its accuracy is checked in //build/rust/std:find_stdlib, which
# most of our Rust targets depend upon.
if (rustc_revision != "") {
# Similar to the above config, this is here so that all files get recompiled
# after a rustc roll. Nothing should ever read this cfg. This will not be
# set if a custom toolchain is used.
rustflags = [
"--cfg",
"rustc_version=\"$rustc_version\"",
"cr_rustc_revision=\"$rustc_revision\"",
]
}
}
@ -1686,6 +1692,9 @@ config("default_warnings") {
# TODO(crbug.com/1352183) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/1412713) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
]
}
}
@ -2072,7 +2081,6 @@ if (is_win) {
common_optimize_on_ldflags += [
]
if (use_polly == true) {
common_optimize_on_ldflags += [
"-mllvm:-polly",
@ -2194,12 +2202,12 @@ config("optimize") {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
rustflags = [ "-Copt-level=3" ]
} 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 = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
@ -2427,6 +2435,9 @@ config("afdo") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
if (use_profi) {
cflags += [ "-fsample-profile-use-profi" ]
}
inputs = [ _clang_sample_profile ]
}
} else if (auto_profile_path != "" && is_a_target_toolchain) {

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
# Copyright 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.
@ -172,6 +172,11 @@ declare_args() {
# For use by tools/clang/scripts/analyze_includes.py
show_includes = false
# Enable Profi algorithm. Profi can infer block and edge counts.
# https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# TODO(crbug.com/1375958i:) Possibly enable this for Android too.
use_profi = is_chromeos
# If true, linker crashes will be rerun with `--reproduce` which causes
# a reproducer file to be saved.
save_reproducers_on_lld_crash = false
@ -352,6 +357,11 @@ config("compiler") {
}
}
# ADDED BY ALEX313031 FOR THORIUM
if (is_clang && is_android && !is_ubsan && !is_ubsan_security) {
cflags += [ "-fwrapv" ]
}
# Linker warnings.
if (fatal_linker_warnings && !is_apple && current_os != "aix" &&
current_os != "zos") {
@ -612,8 +622,7 @@ config("compiler") {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_clang) {
if (is_chromeos_device || use_cxx17) {
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
if (use_cxx17) {
cflags_cc += [ "-std=${standard_prefix}++17" ]
} else {
cflags_cc += [ "-std=${standard_prefix}++20" ]
@ -638,9 +647,7 @@ config("compiler") {
# clause, above.
cflags_c += [ "-std=c11" ]
if (is_fuchsia || use_cxx17) {
# 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.
if (use_cxx17) {
cflags_cc += [ "-std=c++17" ]
} else {
cflags_cc += [ "-std=c++20" ]
@ -827,9 +834,8 @@ config("compiler") {
# * 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) {
if (is_clang && !is_nacl && !is_win && !is_apple) {
cflags_cc += [ "-gsimple-template-names" ]
}
@ -877,6 +883,13 @@ config("compiler") {
# we discover a reason to turn them off.
"-Coverflow-checks=on",
# By default Rust passes `-nodefaultlibs` to the linker, however this
# conflicts with our `--unwind=none` flag for Android dylibs, as the latter
# is then unused and produces a warning/error. So this removes the
# `-nodefaultlibs` from the linker invocation from Rust, which would be used
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
@ -1301,9 +1314,10 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && is_android) {
# On arm64 disable outlining for Android. See crbug.com/931297 for more
# information.
if (current_cpu == "arm64" && !is_win) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
cflags += [ "-mno-outline" ]
# This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
@ -1427,16 +1441,13 @@ config("clang_revision") {
}
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
# recompiled after a rustc roll. Nothing should ever read this cfg.
# $rustc_version is a gn arg set within //build/config/rust.gni
# so that users using a custom Rust toolchain can override it.
# Its accuracy is checked in //build/rust/std:find_stdlib, which
# most of our Rust targets depend upon.
if (rustc_revision != "") {
# Similar to the above config, this is here so that all files get recompiled
# after a rustc roll. Nothing should ever read this cfg. This will not be
# set if a custom toolchain is used.
rustflags = [
"--cfg",
"rustc_version=\"$rustc_version\"",
"cr_rustc_revision=\"$rustc_revision\"",
]
}
}
@ -1654,6 +1665,9 @@ config("default_warnings") {
# TODO(crbug.com/1352183) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/1412713) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
]
}
}
@ -2074,11 +2088,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 += [
@ -2133,7 +2148,7 @@ config("optimize") {
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
rustflags = []
rustflags = [ "-Copt-level=3" ]
}
} else if (optimize_for_size) {
# Favor size over speed.
@ -2278,7 +2293,7 @@ config("optimize_speed") {
config("optimize_fuzzing") {
cflags = [ "-O3" ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3" ]
rustflags = [ "-Copt-level=3", ]
ldflags = common_optimize_on_ldflags
visibility = [ ":default_optimization" ]
}
@ -2356,6 +2371,9 @@ config("afdo") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
if (use_profi) {
cflags += [ "-fsample-profile-use-profi" ]
}
inputs = [ _clang_sample_profile ]
}
} else if (auto_profile_path != "" && is_a_target_toolchain) {

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
# Copyright 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.
@ -172,6 +172,11 @@ declare_args() {
# For use by tools/clang/scripts/analyze_includes.py
show_includes = false
# Enable Profi algorithm. Profi can infer block and edge counts.
# https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# TODO(crbug.com/1375958i:) Possibly enable this for Android too.
use_profi = is_chromeos
# If true, linker crashes will be rerun with `--reproduce` which causes
# a reproducer file to be saved.
save_reproducers_on_lld_crash = false
@ -617,8 +622,7 @@ config("compiler") {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_clang) {
if (is_chromeos_device || use_cxx17) {
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
if (use_cxx17) {
cflags_cc += [ "-std=${standard_prefix}++17" ]
} else {
cflags_cc += [ "-std=${standard_prefix}++20" ]
@ -643,9 +647,7 @@ config("compiler") {
# clause, above.
cflags_c += [ "-std=c11" ]
if (is_fuchsia || use_cxx17) {
# 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.
if (use_cxx17) {
cflags_cc += [ "-std=c++17" ]
} else {
cflags_cc += [ "-std=c++20" ]
@ -832,9 +834,8 @@ config("compiler") {
# * 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) {
if (is_clang && !is_nacl && !is_win && !is_apple) {
cflags_cc += [ "-gsimple-template-names" ]
}
@ -882,6 +883,13 @@ config("compiler") {
# we discover a reason to turn them off.
"-Coverflow-checks=on",
# By default Rust passes `-nodefaultlibs` to the linker, however this
# conflicts with our `--unwind=none` flag for Android dylibs, as the latter
# is then unused and produces a warning/error. So this removes the
# `-nodefaultlibs` from the linker invocation from Rust, which would be used
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
@ -1325,9 +1333,10 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && is_android) {
# On arm64 disable outlining for Android. See crbug.com/931297 for more
# information.
if (current_cpu == "arm64" && !is_win) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
cflags += [ "-mno-outline" ]
# This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
@ -1451,16 +1460,13 @@ config("clang_revision") {
}
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
# recompiled after a rustc roll. Nothing should ever read this cfg.
# $rustc_version is a gn arg set within //build/config/rust.gni
# so that users using a custom Rust toolchain can override it.
# Its accuracy is checked in //build/rust/std:find_stdlib, which
# most of our Rust targets depend upon.
if (rustc_revision != "") {
# Similar to the above config, this is here so that all files get recompiled
# after a rustc roll. Nothing should ever read this cfg. This will not be
# set if a custom toolchain is used.
rustflags = [
"--cfg",
"rustc_version=\"$rustc_version\"",
"cr_rustc_revision=\"$rustc_revision\"",
]
}
}
@ -1678,6 +1684,9 @@ config("default_warnings") {
# TODO(crbug.com/1352183) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/1412713) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
]
}
}
@ -2261,12 +2270,12 @@ config("optimize") {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
rustflags = [ "-Copt-level=3" ]
} 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 = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
@ -2494,6 +2503,9 @@ config("afdo") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
if (use_profi) {
cflags += [ "-fsample-profile-use-profi" ]
}
inputs = [ _clang_sample_profile ]
}
} else if (auto_profile_path != "" && is_a_target_toolchain) {

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
# Copyright 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.
@ -172,6 +172,11 @@ declare_args() {
# For use by tools/clang/scripts/analyze_includes.py
show_includes = false
# Enable Profi algorithm. Profi can infer block and edge counts.
# https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# TODO(crbug.com/1375958i:) Possibly enable this for Android too.
use_profi = is_chromeos
# If true, linker crashes will be rerun with `--reproduce` which causes
# a reproducer file to be saved.
save_reproducers_on_lld_crash = false
@ -617,8 +622,7 @@ config("compiler") {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_clang) {
if (is_chromeos_device || use_cxx17) {
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
if (use_cxx17) {
cflags_cc += [ "-std=${standard_prefix}++17" ]
} else {
cflags_cc += [ "-std=${standard_prefix}++20" ]
@ -643,9 +647,7 @@ config("compiler") {
# clause, above.
cflags_c += [ "-std=c11" ]
if (is_fuchsia || use_cxx17) {
# 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.
if (use_cxx17) {
cflags_cc += [ "-std=c++17" ]
} else {
cflags_cc += [ "-std=c++20" ]
@ -832,9 +834,8 @@ config("compiler") {
# * 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) {
if (is_clang && !is_nacl && !is_win && !is_apple) {
cflags_cc += [ "-gsimple-template-names" ]
}
@ -882,6 +883,13 @@ config("compiler") {
# we discover a reason to turn them off.
"-Coverflow-checks=on",
# By default Rust passes `-nodefaultlibs` to the linker, however this
# conflicts with our `--unwind=none` flag for Android dylibs, as the latter
# is then unused and produces a warning/error. So this removes the
# `-nodefaultlibs` from the linker invocation from Rust, which would be used
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
@ -1322,9 +1330,10 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && is_android) {
# On arm64 disable outlining for Android. See crbug.com/931297 for more
# information.
if (current_cpu == "arm64" && !is_win) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
cflags += [ "-mno-outline" ]
# This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
@ -1448,16 +1457,13 @@ config("clang_revision") {
}
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
# recompiled after a rustc roll. Nothing should ever read this cfg.
# $rustc_version is a gn arg set within //build/config/rust.gni
# so that users using a custom Rust toolchain can override it.
# Its accuracy is checked in //build/rust/std:find_stdlib, which
# most of our Rust targets depend upon.
if (rustc_revision != "") {
# Similar to the above config, this is here so that all files get recompiled
# after a rustc roll. Nothing should ever read this cfg. This will not be
# set if a custom toolchain is used.
rustflags = [
"--cfg",
"rustc_version=\"$rustc_version\"",
"cr_rustc_revision=\"$rustc_revision\"",
]
}
}
@ -1675,6 +1681,9 @@ config("default_warnings") {
# TODO(crbug.com/1352183) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/1412713) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
]
}
}
@ -2255,12 +2264,12 @@ config("optimize") {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
rustflags = [ "-Copt-level=3" ]
} 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 = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
@ -2488,6 +2497,9 @@ config("afdo") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
if (use_profi) {
cflags += [ "-fsample-profile-use-profi" ]
}
inputs = [ _clang_sample_profile ]
}
} else if (auto_profile_path != "" && is_a_target_toolchain) {

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
# Copyright 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.
@ -172,6 +172,11 @@ declare_args() {
# For use by tools/clang/scripts/analyze_includes.py
show_includes = false
# Enable Profi algorithm. Profi can infer block and edge counts.
# https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# TODO(crbug.com/1375958i:) Possibly enable this for Android too.
use_profi = is_chromeos
# If true, linker crashes will be rerun with `--reproduce` which causes
# a reproducer file to be saved.
save_reproducers_on_lld_crash = false
@ -617,8 +622,7 @@ config("compiler") {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_clang) {
if (is_chromeos_device || use_cxx17) {
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
if (use_cxx17) {
cflags_cc += [ "-std=${standard_prefix}++17" ]
} else {
cflags_cc += [ "-std=${standard_prefix}++20" ]
@ -643,9 +647,7 @@ config("compiler") {
# clause, above.
cflags_c += [ "-std=c11" ]
if (is_fuchsia || use_cxx17) {
# 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.
if (use_cxx17) {
cflags_cc += [ "-std=c++17" ]
} else {
cflags_cc += [ "-std=c++20" ]
@ -832,9 +834,8 @@ config("compiler") {
# * 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) {
if (is_clang && !is_nacl && !is_win && !is_apple) {
cflags_cc += [ "-gsimple-template-names" ]
}
@ -882,6 +883,13 @@ config("compiler") {
# we discover a reason to turn them off.
"-Coverflow-checks=on",
# By default Rust passes `-nodefaultlibs` to the linker, however this
# conflicts with our `--unwind=none` flag for Android dylibs, as the latter
# is then unused and produces a warning/error. So this removes the
# `-nodefaultlibs` from the linker invocation from Rust, which would be used
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
@ -1322,9 +1330,10 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && is_android) {
# On arm64 disable outlining for Android. See crbug.com/931297 for more
# information.
if (current_cpu == "arm64" && !is_win) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
cflags += [ "-mno-outline" ]
# This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
@ -1448,16 +1457,13 @@ config("clang_revision") {
}
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
# recompiled after a rustc roll. Nothing should ever read this cfg.
# $rustc_version is a gn arg set within //build/config/rust.gni
# so that users using a custom Rust toolchain can override it.
# Its accuracy is checked in //build/rust/std:find_stdlib, which
# most of our Rust targets depend upon.
if (rustc_revision != "") {
# Similar to the above config, this is here so that all files get recompiled
# after a rustc roll. Nothing should ever read this cfg. This will not be
# set if a custom toolchain is used.
rustflags = [
"--cfg",
"rustc_version=\"$rustc_version\"",
"cr_rustc_revision=\"$rustc_revision\"",
]
}
}
@ -1675,6 +1681,9 @@ config("default_warnings") {
# TODO(crbug.com/1352183) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/1412713) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
]
}
}
@ -2255,12 +2264,12 @@ config("optimize") {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
rustflags = [ "-Copt-level=3" ]
} 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 = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
@ -2488,6 +2497,9 @@ config("afdo") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
if (use_profi) {
cflags += [ "-fsample-profile-use-profi" ]
}
inputs = [ _clang_sample_profile ]
}
} else if (auto_profile_path != "" && is_a_target_toolchain) {

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved.
# Copyright 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.
@ -172,6 +172,11 @@ declare_args() {
# For use by tools/clang/scripts/analyze_includes.py
show_includes = false
# Enable Profi algorithm. Profi can infer block and edge counts.
# https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
# TODO(crbug.com/1375958i:) Possibly enable this for Android too.
use_profi = is_chromeos
# If true, linker crashes will be rerun with `--reproduce` which causes
# a reproducer file to be saved.
save_reproducers_on_lld_crash = false
@ -610,8 +615,7 @@ config("compiler") {
cflags_cc += [ "-fno-trigraphs" ]
}
} else if (is_clang) {
if (is_chromeos_device || use_cxx17) {
# TODO(crbug.com/1392471): Support C++20 in CrOS toolchain.
if (use_cxx17) {
cflags_cc += [ "-std=${standard_prefix}++17" ]
} else {
cflags_cc += [ "-std=${standard_prefix}++20" ]
@ -636,9 +640,7 @@ config("compiler") {
# clause, above.
cflags_c += [ "-std=c11" ]
if (is_fuchsia || use_cxx17) {
# 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.
if (use_cxx17) {
cflags_cc += [ "-std=c++17" ]
} else {
cflags_cc += [ "-std=c++20" ]
@ -825,9 +827,8 @@ config("compiler") {
# * 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) {
if (is_clang && !is_nacl && !is_win && !is_apple) {
cflags_cc += [ "-gsimple-template-names" ]
}
@ -875,6 +876,13 @@ config("compiler") {
# we discover a reason to turn them off.
"-Coverflow-checks=on",
# By default Rust passes `-nodefaultlibs` to the linker, however this
# conflicts with our `--unwind=none` flag for Android dylibs, as the latter
# is then unused and produces a warning/error. So this removes the
# `-nodefaultlibs` from the linker invocation from Rust, which would be used
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
@ -1317,9 +1325,10 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && is_android) {
# On arm64 disable outlining for Android. See crbug.com/931297 for more
# information.
if (current_cpu == "arm64" && !is_win) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
cflags += [ "-mno-outline" ]
# This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348
@ -1443,16 +1452,13 @@ config("clang_revision") {
}
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
# recompiled after a rustc roll. Nothing should ever read this cfg.
# $rustc_version is a gn arg set within //build/config/rust.gni
# so that users using a custom Rust toolchain can override it.
# Its accuracy is checked in //build/rust/std:find_stdlib, which
# most of our Rust targets depend upon.
if (rustc_revision != "") {
# Similar to the above config, this is here so that all files get recompiled
# after a rustc roll. Nothing should ever read this cfg. This will not be
# set if a custom toolchain is used.
rustflags = [
"--cfg",
"rustc_version=\"$rustc_version\"",
"cr_rustc_revision=\"$rustc_revision\"",
]
}
}
@ -1670,6 +1676,9 @@ config("default_warnings") {
# TODO(crbug.com/1352183) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/1412713) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
]
}
}
@ -2252,12 +2261,12 @@ config("optimize") {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ]
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
rustflags = [ "-Copt-level=3" ]
} 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 = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ]
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
@ -2485,6 +2494,9 @@ config("afdo") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
if (use_profi) {
cflags += [ "-fsample-profile-use-profi" ]
}
inputs = [ _clang_sample_profile ]
}
} else if (auto_profile_path != "" && is_a_target_toolchain) {