From fd5140d49142ec0e68dfbcb98e1053c09dc857b8 Mon Sep 17 00:00:00 2001 From: Clement Skau Date: Wed, 5 Aug 2020 11:46:28 +0000 Subject: [PATCH] [SDK] Fix VM/kernel version mix in build. Several people have experienced build issues traced back to target `//utils/dartanalyzer:generate_summary_strong`. The issue is triggered by the sdk_hash changing with an old kernel-service snapshot in the out/ folder. `generate_summary_strong` uses but does not explicitly depend on the kernel-service, causing the outdated dependency. This then causes 'Unexpected Kernel SDK Version' when the new dart binary tried to load the old kernel-service snapshot. Tested: 1. Clean build of create_sdk at HEAD. 2. Empty `git commit --amend` to modify commit and thus sdk hash. 3. Rebuild of create_sdk (which failed before). Cq-Include-Trybots: dart/try:analyzer-analysis-server-linux-try,analyzer-linux-release-try,analyzer-mac-release-try,analyzer-nnbd-linux-release-try,analyzer-win-release-try,benchmark-linux-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,dart-sdk-win-try,flutter-analyze-try,front-end-linux-release-x64-try,pkg-linux-release-try,vm-kernel-linux-release-x64-try Change-Id: Iba07e9d0c5daa7a93870fb501d9bb57682c88a5d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156913 Reviewed-by: Vyacheslav Egorov Commit-Queue: Clement Skau --- build/dart/dart_action.gni | 15 +++++++++++++++ utils/application_snapshot.gni | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/build/dart/dart_action.gni b/build/dart/dart_action.gni index 2058f0334c3..c357aad4d99 100644 --- a/build/dart/dart_action.gni +++ b/build/dart/dart_action.gni @@ -288,6 +288,10 @@ template("_built_tool_action") { # script: # The un-rebased path to the Dart script. # +# dfe (optional): +# Sets the DFE file used by Dart. If not set the VM will attempt to load it +# from a snapshot, or fall back on its built-in kernel. +# # vm_args (optional): # Arguments to pass to the Dart VM. # @@ -323,6 +327,17 @@ template("dart_action") { "visibility", "vm_args", ]) + + # Dart has an implicit dependency on the kernel service so unless DFE is + # passed, we need to add this dep. + if (defined(invoker.dfe)) { + vm_args += [ "--dfe=" + rebase_path(invoker.dfe) ] + } else { + if (!defined(invoker.deps)) { + deps = [] + } + deps += [ "$_dart_root/utils/kernel-service:kernel-service" ] + } } } else { prebuilt_dart_action(target_name) { diff --git a/utils/application_snapshot.gni b/utils/application_snapshot.gni index 7d981bd728a..81ec5eed094 100644 --- a/utils/application_snapshot.gni +++ b/utils/application_snapshot.gni @@ -134,6 +134,7 @@ template("_application_snapshot") { args += [ rebase_path(main_dart) ] } + # Create a snapshot from kernel built above. dart_action(target_name) { deps = extra_deps + [ ":${target_name}_dill" ] depfile = "$output.d" @@ -144,6 +145,10 @@ template("_application_snapshot") { outputs = [ output ] + # Explicitly set DFE so Dart doesn't implicitly depend on the kernel service + # snapshot (creating a circular dep. for kernel-service_snapshot). + dfe = "$_dart_root/pkg/vm/bin/kernel_service.dart" + abs_depfile = rebase_path(depfile) abs_output = rebase_path(output, root_build_dir)