[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 <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
This commit is contained in:
Clement Skau 2020-08-05 11:46:28 +00:00 committed by commit-bot@chromium.org
parent 47cf36ec71
commit fd5140d491
2 changed files with 20 additions and 0 deletions

View file

@ -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) {

View file

@ -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)