Skip to content

Commit ce4faea

Browse files
authored
Pass stack protection flag on Android (#857)
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
1 parent 7f832ae commit ce4faea

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

build/config/compiler/BUILD.gn

+8-15
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ declare_args() {
3535
# this flag may be set to allow such calls.
3636
allow_deprecated_api_calls = false
3737

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

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

10097
# Stack protection.
101-
if (use_fstack_protector) {
98+
if (is_mac) {
99+
cflags += [ "-fstack-protector-all" ]
100+
} else if (!is_ios && !is_wasm) {
102101
cflags += [
103102
"-fstack-protector",
104-
"--param=ssp-buffer-size=4",
103+
# 8 is the default, but make this explicit here so that we don't have to
104+
# go hunting for the flag name if we ever want a value that is
105+
# different from the default.
106+
"--param=ssp-buffer-size=8",
105107
]
106-
} else {
107-
if (is_mac) {
108-
cflags += [ "-fstack-protector-all" ]
109-
} else if (is_linux) {
110-
cflags += [
111-
"-fstack-protector",
112-
"--param=ssp-buffer-size=4",
113-
]
114-
}
115108
}
116109

117110
# Linker warnings.

0 commit comments

Comments
 (0)