Repository navigation
Commit 3573d30
committed
iOS,macOS: Compile Swift with opt flags in opt builds
We never passed optimisation flags to `swiftc`, and the compiler's
default is `-Onone`, so all of the Darwin embedders' Swift shipped
unoptimised in profile and release, and `assert()`s triggered in
shipping binaries, as seen in flutter#190909.
This updates our optimisation gn configs to set equivalent `swiftflags`
alongside the `cflags` we already set. For iOS that means `-Osize`
(to match `-Os` for Obj-C/C++). For macOS, that means `-O` (to match
`-O2` for Obj-C/C++, Swift just has -O, no -O2, -O3). For both, we set
and `-Onone` for `:no_optimize`.
When `is_debug` is true, we default to unopt. Swift `assert()` behaves
like `FML_DCHECK` (active in unopt, compiled out in opt builds) and
we should use `precondition()` where we'd use `FML_CHECK` -- i.e. cases
we want to assert even in release builds.
The following dev-specific asserts are now compiled out from shipped engines:
* `DisplayLinkManager.shared` main-thread check
* `KeyboardInsetManager` vsync client internal-state check
* `FlutterRunLoop.mainRunLoop` the guard check already triggers
* `TraceScope.deinit` ensure `end()` was called
This also moves the main-thread check in
`FlutterRunLoop.ensureMainLoopInitialized` to a `precondition`. Binding
the main run loop to the wrong thread silently leaves everything later
scheduled on it running on the wrong thread so we should continue to
blow up in all modes.
This change chops 130272 bytes (0.79%) off `Flutter.framework` on
`ios_release`.
Issue: flutter#191616
Related: flutter#190909
No new tests, since this is a compile config change: the build *is* the
test, along with not breaking the existing tests.1 parent 64e1cfe commit 3573d30
2 files changed
Lines changed: 5 additions & 1 deletion
File tree
- engine/src
- build/config/compiler
- flutter/shell/platform/darwin/macos/framework/Source
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
| 1019 | + | |
1019 | 1020 | | |
1020 | 1021 | | |
1021 | 1022 | | |
| |||
1027 | 1028 | | |
1028 | 1029 | | |
1029 | 1030 | | |
| 1031 | + | |
1030 | 1032 | | |
1031 | 1033 | | |
| 1034 | + | |
1032 | 1035 | | |
1033 | 1036 | | |
1034 | 1037 | | |
| |||
1070 | 1073 | | |
1071 | 1074 | | |
1072 | 1075 | | |
| 1076 | + | |
1073 | 1077 | | |
1074 | 1078 | | |
1075 | 1079 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
0 commit comments