diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 1198d344e4..1e0e6a3891 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -19,6 +19,12 @@ import 'base/platform.dart'; import 'build_info.dart'; import 'convert.dart'; +/// Opt-in changes to the dart compilers. +const List kDartCompilerExperiments = [ + // improve AOT code size. + '--compact-async', +]; + /// The target model describes the set of core libraries that are available within /// the SDK. class TargetModel { @@ -183,11 +189,13 @@ List buildModeOptions(BuildMode mode, List dartDefines) { '-Ddart.vm.profile=true', if (!dartDefines.any((String define) => define.startsWith('dart.vm.product'))) '-Ddart.vm.product=false', + ...kDartCompilerExperiments, ]; case BuildMode.release: return [ '-Ddart.vm.profile=false', '-Ddart.vm.product=true', + ...kDartCompilerExperiments, ]; } throw Exception('Unknown BuildMode: $mode'); diff --git a/packages/flutter_tools/test/general.shard/compile_batch_test.dart b/packages/flutter_tools/test/general.shard/compile_batch_test.dart index 3c9d3f4b07..0156c49f79 100644 --- a/packages/flutter_tools/test/general.shard/compile_batch_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_batch_test.dart @@ -197,6 +197,7 @@ void main() { '--no-print-incremental-dependencies', '-Ddart.vm.profile=true', '-Ddart.vm.product=false', + '--compact-async', '--no-link-platform', '--aot', '--tfa', @@ -244,6 +245,7 @@ void main() { '--no-print-incremental-dependencies', '-Ddart.vm.profile=false', '-Ddart.vm.product=true', + '--compact-async', '--no-link-platform', '--aot', '--tfa', diff --git a/packages/flutter_tools/test/general.shard/compile_test.dart b/packages/flutter_tools/test/general.shard/compile_test.dart index 28442b625b..66c83be757 100644 --- a/packages/flutter_tools/test/general.shard/compile_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_test.dart @@ -105,11 +105,13 @@ void main() { testWithoutContext('buildModeOptions removes matching profile define in profile mode', () { expect(buildModeOptions(BuildMode.profile, ['dart.vm.profile=true']), [ '-Ddart.vm.product=false', + '--compact-async' ]); }); testWithoutContext('buildModeOptions removes both matching profile and release define in profile mode', () { expect(buildModeOptions(BuildMode.profile, ['dart.vm.profile=false', 'dart.vm.product=true']), [ + '--compact-async' ]); }); }