Update BUILD.gn

This commit is contained in:
Alexander David Frick 2022-08-29 19:30:42 -05:00 committed by GitHub
parent 5339272f64
commit 35a3eca6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -773,6 +773,24 @@ config("compiler") {
(is_win || use_custom_libcxx)) {
cflags += [ "-fcomplete-member-pointers" ]
}
# 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.
# Currently, the ML inliner is only enabled when targeting Android due to:
# a) Android is where size matters the most.
# b) MLGO presently has the limitation of only being able to embed one model
# at a time; It is unclear if the embedded model is beneficial for
# non-Android targets.
# MLGO is only officially supported on linux.
if (use_ml_inliner && is_a_target_toolchain) {
assert(
is_android && host_os == "linux",
"MLGO is currently only supported for targeting Android on a linux host")
if (use_thin_lto) {
ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
}
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
@ -1519,9 +1537,6 @@ config("default_warnings") {
# TODO(thakis): https://crbug.com/617318
# Currently goma can not handle case sensitiveness for windows well.
cflags += [ "-Wno-nonportable-include-path" ]
# Warns in ATL headers; see https://crbug.com/1208419.
cflags += [ "-Wno-null-pointer-subtraction" ]
}
cflags += [
@ -2052,6 +2067,13 @@ config("optimize") {
# Favor size over speed.
if (is_clang) {
cflags = [ "-O3" ] + common_optimize_on_cflags
if (use_ml_inliner && is_a_target_toolchain) {
cflags += [
"-mllvm",
"-enable-ml-inliner=release",
]
}
} else {
cflags = [ "-O3" ] + common_optimize_on_cflags
}