[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>
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 2ccf215..65aea3a 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -154,6 +154,7 @@
 };
 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 @@
 #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.");
diff --git a/utils/application_snapshot.gni b/utils/application_snapshot.gni
index 19cbb45..5679682 100644
--- a/utils/application_snapshot.gni
+++ b/utils/application_snapshot.gni
@@ -135,44 +135,51 @@
   }
 
   # 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")
+      }
     }
   }
 }