Skip to content

Commit

Permalink
[dart2bytecode] Remove the requirement for dynamic module to have 'main'
Browse files Browse the repository at this point in the history
TEST=DART_CONFIGURATION=DebugX64 out/DebugX64/dart-sdk/bin/dart pkg/dynamic_modules/test/runner/main.dart -r aot --verbose

Change-Id: I8647822982b051b4846dfe4ed7e51a19ef466cf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384311
Commit-Queue: Alexander Markov <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
  • Loading branch information
alexmarkov authored and Commit Queue committed Sep 10, 2024
1 parent a57e604 commit ad94d96
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 30 deletions.
1 change: 1 addition & 0 deletions pkg/dart2bytecode/lib/dart2bytecode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Future<int> runCompiler(ArgResults options) async {
final results = await compileToKernel(KernelCompilationArguments(
source: mainUri,
options: compilerOptions,
requireMain: false,
includePlatform: false,
environmentDefines: environmentDefines,
enableAsserts: enableAsserts));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ import 'common.dart';

@pragma('dyn-module:entry-point')
Object? entrypoint() => const A();

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ class Child extends Base {

@pragma('dyn-module:entry-point')
Object? dynamicModuleEntrypoint() => Child();

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ class Child implements Base {

@pragma('dyn-module:entry-point')
Object? dynamicModuleEntrypoint() => Child();

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
4 changes: 0 additions & 4 deletions pkg/dynamic_modules/test/data/load_twice/modules/entry1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ class A {}

@pragma('dyn-module:entry-point')
Object? dynamicModuleEntrypoint() => A();

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ import '../main.dart';

@pragma('dyn-module:entry-point')
Object? dynamicModuleEntrypoint() => const B(1);

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ import '../main.dart';

@pragma('dyn-module:entry-point')
Object? dynamicModuleEntrypoint() => const B(1);

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ import '../shared/shared.dart';
void dynamicModuleEntrypoint() {
topLevel = 'updated';
}

// TODO(sigmund): remove or reconcile. W/O a main dart2bytecode produces
// a compile-time error.
main() {}
10 changes: 8 additions & 2 deletions pkg/vm/lib/kernel_front_end.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'package:front_end/src/api_unstable/vm.dart'
StandardFileSystem,
Verbosity,
getMessageUri,
kernelForModule,
kernelForProgram,
parseExperimentalArguments,
parseExperimentalFlags,
Expand Down Expand Up @@ -449,6 +450,7 @@ class KernelCompilationArguments {
final List<Uri> additionalSources;
final Uri? nativeAssets;
final Uri? resourcesFile;
final bool requireMain;
final bool includePlatform;
final List<String> deleteToStringPackageUris;
final List<String> keepClassNamesImplementing;
Expand All @@ -470,6 +472,7 @@ class KernelCompilationArguments {
this.additionalSources = const <Uri>[],
this.nativeAssets,
this.resourcesFile,
this.requireMain = true,
this.includePlatform = false,
this.deleteToStringPackageUris = const <String>[],
this.keepClassNamesImplementing = const <String>[],
Expand Down Expand Up @@ -521,8 +524,11 @@ Future<KernelCompilationResults> compileToKernel(
compilerResult =
await loadKernel(options.fileSystem, resolveInputUri(fromDillFile));
} else {
compilerResult = await kernelForProgram(args.source!, options,
additionalSources: args.additionalSources);
compilerResult = args.requireMain
? await kernelForProgram(args.source!, options,
additionalSources: args.additionalSources)
: await kernelForModule(
[args.source!, ...args.additionalSources], options);
}
final Component? component = compilerResult?.component;

Expand Down

0 comments on commit ad94d96

Please sign in to comment.