From cd5d399e2bc50c8235ce2d85df7eb210e4b9bd07 Mon Sep 17 00:00:00 2001 From: Derek Xu Date: Tue, 19 Dec 2023 21:17:15 +0000 Subject: [PATCH] Reland "[ DDS ] Fix DDS AOT snapshot build rules" This is a reland of commit 0a393f1b697671a4bb42ba0ec9b1c4dda91b013b The problem was that the checks for whether or not dartaotruntime existed were always returning false on Windows because the ".exe" suffix wasn't being taken into account. Patchset 2 addresses this. Original change's description: > [ DDS ] Fix DDS AOT snapshot build rules > > dds_aot.dart.snapshot was not being generated for runtime build targets, > and dds.dart.snapshot was being built regardless of whether or not we > were building for an IA32 target. > > This change also adds a check for IA32 in 'dart run' so the "Could not > find dds_aot.dart.snapshot. Have you built the full Dart SDK?" message > isn't printed when we fall back to using dds.dart.snapshot. > > This change also reverts 2cc08595a644cd6761730629af7ad86669655a2a, which > failed to fix the issue it was attempting to fix. > > TEST=pkg/vm_service tests > > Change-Id: Ic990082c25b0d022093ad66600332dfb2878709f > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341760 > Reviewed-by: Siva Annamalai > Commit-Queue: Ben Konyi TEST=pkg-win-release-try, pkg-win-release-arm64-try, and pkg/vm_service tests Change-Id: Ieab41edcb6bffca3be6bf628e357871f28949323 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342640 Reviewed-by: Siva Annamalai Commit-Queue: Derek Xu --- BUILD.gn | 1 - pkg/dartdev/lib/src/commands/run.dart | 13 +++++++++---- pkg/dartdev/lib/src/sdk.dart | 15 +++++++++++---- sdk/lib/_internal/vm/bin/vmservice_io.dart | 6 ++++-- utils/dartdev/BUILD.gn | 7 +++++++ 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 16905da1aff..23d54037b2a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -50,7 +50,6 @@ group("runtime") { "runtime/vm:kernel_platform_files($host_toolchain)", "samples/ffi/http:fake_http", "utils/dartdev:dartdev", - "utils/dds:dds", "utils/kernel-service:kernel-service", ] diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index 940d2bb4d64..52b830de991 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -397,10 +397,15 @@ class _DebuggingSession { ? sdk.ddsAotSnapshot : absolute(sdkDir, 'dds_aot.dart.snapshot'); String execName = sdk.dartAotRuntime; - if (!Sdk.checkArtifactExists(snapshotName)) { - // An AOT snapshot of dds is not available, we could - // be running on the ia32 platform so check for a regular - // kernel file being present. + // Check to see if the AOT snapshot and dartaotruntime are available. + // If not, fall back to running from the AppJIT snapshot. + // + // This can happen if: + // - The SDK is built for IA32 which doesn't support AOT compilation + // - We only have artifacts available from the 'runtime' build + // configuration, which the VM SDK build bots frequently run from + if (!Sdk.checkArtifactExists(snapshotName, logError: false) || + !Sdk.checkArtifactExists(sdk.dartAotRuntime, logError: false)) { snapshotName = fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot'); if (!Sdk.checkArtifactExists(snapshotName)) { diff --git a/pkg/dartdev/lib/src/sdk.dart b/pkg/dartdev/lib/src/sdk.dart index 962dbdf6d59..105c9a58d7d 100644 --- a/pkg/dartdev/lib/src/sdk.dart +++ b/pkg/dartdev/lib/src/sdk.dart @@ -29,7 +29,11 @@ class Sdk { // if the SDK isn't completely built. String get dart => Platform.resolvedExecutable; - String get dartAotRuntime => path.join(sdkPath, 'bin', 'dartaotruntime'); + String get dartAotRuntime => path.join( + sdkPath, + 'bin', + 'dartaotruntime${Platform.isWindows ? '.exe' : ''}', + ); String get analysisServerSnapshot => path.absolute( sdkPath, @@ -80,10 +84,13 @@ class Sdk { 'devtools', ); - static bool checkArtifactExists(String path) { + static bool checkArtifactExists(String path, {bool logError = true}) { if (!File(path).existsSync()) { - log.stderr('Could not find $path. Have you built the full ' - 'Dart SDK?'); + if (logError) { + log.stderr( + 'Could not find $path. Have you built the full Dart SDK?', + ); + } return false; } return true; diff --git a/sdk/lib/_internal/vm/bin/vmservice_io.dart b/sdk/lib/_internal/vm/bin/vmservice_io.dart index bdd4db05871..3a31302c0e6 100644 --- a/sdk/lib/_internal/vm/bin/vmservice_io.dart +++ b/sdk/lib/_internal/vm/bin/vmservice_io.dart @@ -83,7 +83,9 @@ class _DebuggingSession { final dartAotPath = [ dartDir, - fullSdk ? 'dartaotruntime' : 'dart_precompiled_runtime_product', + fullSdk + ? 'dartaotruntime${Platform.isWindows ? '.exe' : ''}' + : 'dart_precompiled_runtime_product${Platform.isWindows ? '.exe' : ''}', ].join('/'); String snapshotName = [ dartDir, @@ -91,7 +93,7 @@ class _DebuggingSession { 'dds_aot.dart.snapshot', ].join('/'); String execName = dartAotPath; - if (!File(snapshotName).existsSync()) { + if (!File(snapshotName).existsSync() || !File(dartAotPath).existsSync()) { snapshotName = [ dartDir, fullSdk ? 'snapshots' : 'gen', diff --git a/utils/dartdev/BUILD.gn b/utils/dartdev/BUILD.gn index 9e9dd6e73d4..b33ec489da9 100644 --- a/utils/dartdev/BUILD.gn +++ b/utils/dartdev/BUILD.gn @@ -22,7 +22,14 @@ copy("copy_dartdev_snapshot") { application_snapshot("generate_dartdev_snapshot") { main_dart = "../../pkg/dartdev/bin/dartdev.dart" training_args = [ "--help" ] + deps = [ "../dds:dds" ] + + # DDS should be run from AOT snapshot on all architectures except IA32/X86. + if (dart_target_arch != "ia32" && dart_target_arch != "x86") { + deps += [ "../dds:dds_aot" ] + } + vm_args = [ "--sound-null-safety" ] output = "$root_gen_dir/dartdev.dart.snapshot" }