Skip to content

Commit

Permalink
Pass stack protection flag on Android (#857)
Browse files Browse the repository at this point in the history
For b/338202330.

This increases binary size of libflutter.so in android_release_arm64 by
~55KB (+0.5%) uncompressed, and by ~30KB (+0.6%) gzip'd.

Tested in flutter/engine#52774
  • Loading branch information
zanderso authored May 14, 2024
1 parent 7f832ae commit ce4faea
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ declare_args() {
# this flag may be set to allow such calls.
allow_deprecated_api_calls = false

# Whether -fstack-protector --param=ssp-buffer-size=4 should be passed
# unconditionally.
# TODO(zanderso): Remove when no longer needed in the investigation of
# https://github.com/flutter/flutter/issues/87952.
# This flag is deprecated and will be removed. The value will be ignored.
use_fstack_protector = false

# Prefer size over speed when compiling to wasm
Expand Down Expand Up @@ -98,20 +95,16 @@ config("compiler") {
cflags_objcc += common_flags

# Stack protection.
if (use_fstack_protector) {
if (is_mac) {
cflags += [ "-fstack-protector-all" ]
} else if (!is_ios && !is_wasm) {
cflags += [
"-fstack-protector",
"--param=ssp-buffer-size=4",
# 8 is the default, but make this explicit here so that we don't have to
# go hunting for the flag name if we ever want a value that is
# different from the default.
"--param=ssp-buffer-size=8",
]
} else {
if (is_mac) {
cflags += [ "-fstack-protector-all" ]
} else if (is_linux) {
cflags += [
"-fstack-protector",
"--param=ssp-buffer-size=4",
]
}
}

# Linker warnings.
Expand Down

0 comments on commit ce4faea

Please sign in to comment.