Files
sdk/runtime/vm/version_in.cc
T
Clement Skau edde575dcd [SDK] Adds an SDK hash to kernels and the VM.
Adds a new SDK hash to kernels and the VM which is optionally checked
to verify kernels are built for the same SDK as the VM.
This helps catch incompatibilities that are currently causing
subtle bugs and (not so subtle) crashes.

The SDK hash is encoded in kernels as a new field in components.
The hash is derived from the 10 byte git short hash.

This new check can be disabled via:
  tools/gn.py ... --no-verify-sdk-hash

This CL bumps the min. (and max.) supported kernel format version,
making the VM backwards incompatible from this point back.

Bug: https://github.com/dart-lang/sdk/issues/41802
Change-Id: I3cbb2d481239ee64dafdaa0e4aac36c80281931b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150343
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-26 13:35:42 +00:00

51 lines
1.2 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/version.h"
#include "vm/cpu.h"
#include "vm/flags.h"
#include "vm/os.h"
namespace dart {
// TODO(iposva): Avoid racy initialization.
static const char* formatted_version = NULL;
const char* Version::String() {
if (formatted_version == NULL) {
const char* os = OS::Name();
const char* arch = CPU::Id();
formatted_version = OS::SCreate(NULL, "%s on \"%s_%s\"", str_, os, arch);
}
return formatted_version;
}
const char* Version::SnapshotString() {
return snapshot_hash_;
}
const char* Version::CommitString() {
return commit_;
}
int Version::CurrentAbiVersion() {
return {{ABI_VERSION}};
}
int Version::OldestSupportedAbiVersion() {
return {{OLDEST_SUPPORTED_ABI_VERSION}};
}
const char* Version::SdkHash() {
return git_short_hash_;
}
const char* Version::snapshot_hash_ = "{{SNAPSHOT_HASH}}";
const char* Version::str_ = "{{VERSION_STR}} ({{CHANNEL}}) ({{COMMIT_TIME}})";
const char* Version::commit_ = "{{VERSION_STR}}";
const char* Version::git_short_hash_ = "{{GIT_HASH}}";
} // namespace dart