Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 77ec923

Browse files
authored
Add a GN flag to set the Dart VM's optimization level (#43743)
And set the level to `-Oz` for iOS and Android.
1 parent f2958f9 commit 77ec923

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/gn

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ def to_gn_args(args):
399399
gn_args['dart_debug'] = True
400400
gn_args['dart_debug_optimization_level'] = '0'
401401

402+
if args.dart_optimization_level:
403+
gn_args['dart_default_optimization_level'] = args.dart_optimization_level
404+
elif gn_args['target_os'] in ['android', 'ios']:
405+
gn_args['dart_default_optimization_level'] = 'z'
406+
402407
gn_args['flutter_use_fontconfig'] = args.enable_fontconfig
403408
gn_args['dart_component_kind'
404409
] = 'static_library' # Always link Dart in statically.
@@ -784,6 +789,12 @@ def parse_args(args):
784789
'VM making it easier to step through VM code in the debugger.'
785790
)
786791

792+
parser.add_argument(
793+
'--dart-optimization-level',
794+
type=str,
795+
help='The default optimization level for the Dart VM runtime.',
796+
)
797+
787798
parser.add_argument(
788799
'--target-os',
789800
type=str,

0 commit comments

Comments
 (0)