[build] Don't invoke the JIT runtime when using kernel for SDK snapshots.

If this is a cross-word-size configuration, the JIT cannot run.

TEST=local
Bug: https://github.com/dart-lang/sdk/issues/48792
Change-Id: I7aca0c2da4e352c121f531bdf3eb6402aead1569
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244743
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Ryan Macnak 2022-05-17 21:36:56 +00:00 committed by Commit Bot
parent d4c4408f10
commit fa1848ac54
2 changed files with 51 additions and 36 deletions

View file

@ -154,6 +154,7 @@ class DartInitializationState {
};
static DartInitializationState init_state_;
#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
static void CheckOffsets() {
#if !defined(IS_SIMARM_HOST64)
// These offsets are embedded in precompiled instructions. We need the
@ -243,9 +244,16 @@ static void CheckOffsets() {
#undef CHECK_PAYLOAD_SIZEOF
#endif // !defined(IS_SIMARM_HOST64)
}
#endif // defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
char* Dart::DartInit(const Dart_InitializeParams* params) {
#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
CheckOffsets();
#elif defined(ARCH_IS_64_BIT) != defined(TARGET_ARCH_IS_64_BIT)
return Utils::StrDup(
"JIT cannot simulate target architecture with different word size than "
"host");
#endif
if (!Flags::Initialized()) {
return Utils::StrDup("VM initialization failed-VM Flags not initialized.");

View file

@ -135,44 +135,51 @@ template("_application_snapshot") {
}
# Create a snapshot from kernel built above.
dart_action(target_name) {
if (defined(invoker.pool)) {
pool = invoker.pool
}
deps = extra_deps + [ ":${target_name}_dill" ]
depfile = "$output.d"
if (dart_snapshot_kind == "kernel") {
copy(target_name) {
deps = extra_deps + [ ":${target_name}_dill" ]
sources = [ "$target_gen_dir/$name.dart.dill" ]
outputs = [ output ]
script = "$target_gen_dir/$name.dart.dill"
inputs = extra_inputs
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 = "NEVER_LOADED"
abs_depfile = rebase_path(depfile)
abs_output = rebase_path(output)
rel_output = rebase_path(output, root_build_dir)
vm_args = [
"--deterministic",
"--packages=$dot_packages",
"--snapshot=$abs_output",
"--snapshot-depfile=$abs_depfile",
"--depfile-output-filename=$rel_output",
] + snapshot_vm_args
if (dart_snapshot_kind == "kernel") {
vm_args += [ "--snapshot-kind=kernel" ]
assert(snapshot_vm_args != "", "Ignoring unused argument")
assert(training_args != "", "Ignoring unused argument")
args = []
} else if (dart_snapshot_kind == "app-jit") {
vm_args += [ "--snapshot-kind=app-jit" ]
args = training_args
} else {
assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind")
}
} else {
dart_action(target_name) {
if (defined(invoker.pool)) {
pool = invoker.pool
}
deps = extra_deps + [ ":${target_name}_dill" ]
depfile = "$output.d"
script = "$target_gen_dir/$name.dart.dill"
inputs = extra_inputs
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 = "NEVER_LOADED"
abs_depfile = rebase_path(depfile)
abs_output = rebase_path(output)
rel_output = rebase_path(output, root_build_dir)
vm_args = [
"--deterministic",
"--packages=$dot_packages",
"--snapshot=$abs_output",
"--snapshot-depfile=$abs_depfile",
"--depfile-output-filename=$rel_output",
] + snapshot_vm_args
if (dart_snapshot_kind == "app-jit") {
vm_args += [ "--snapshot-kind=app-jit" ]
args = training_args
} else {
assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind")
}
}
}
}