Update BUILD.gn

This commit is contained in:
Alexander David Frick 2022-01-13 06:58:34 -06:00 committed by GitHub
parent 6562817c11
commit 84e2d003a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -702,7 +702,7 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# FIXME(inglorion): maybe tune these?
if (target_cpu == "arm" || target_cpu == "arm64") {
import_instr_limit = 20
import_instr_limit = 30
} else {
import_instr_limit = 30
}
@ -1538,6 +1538,40 @@ config("default_warnings") {
}
}
# prevent_unsafe_narrowing ----------------------------------------------------
#
# Warnings that prevent narrowing or comparisons of integer types that are
# likely to cause out-of-bound read/writes or Undefined Behaviour. In
# particular, size_t is used for memory sizes, allocation, indexing, and
# offsets. Using other integer types along with size_t produces risk of
# memory-safety bugs and thus security exploits.
#
# In order to prevent these bugs, allocation sizes were historically limited to
# sizes that can be represented within 31 bits of information, allowing `int` to
# be safely misused instead of `size_t` (https://crbug.com/169327). In order to
# support increasing the allocation limit we require strictly adherence to
# using the correct types, avoiding lossy conversions, and preventing overflow.
# To do so, enable this config and fix errors by converting types to be
# `size_t`, which is both large enough and unsigned, when dealing with memory
# sizes, allocations, indices, or offsets.In cases where type conversion is not
# possible or is superfluous, use base::strict_cast<> or base::checked_cast<>
# to convert to size_t as needed.
# See also: https://docs.google.com/document/d/14yKUwDaorqqNfgdGqHY_nck2nn02XBQcB5N0ue4fax8
#
# To enable in a GN target, use:
# configs += [ "//build/config/compiler:prevent_unsafe_narrowing" ]
config("prevent_unsafe_narrowing") {
if (is_clang) {
cflags = [
"-Wshorten-64-to-32",
"-Wimplicit-int-conversion",
"-Wsign-compare",
"-Wsign-conversion",
]
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)