Skip to content

Commit 6a27310

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
Reland "[build] Speed up debug and simulator builds by running steps on the prebuilt VM."
Change-Id: I7878f369ccbf05551aa7c0f6546544f8adb801c5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117660 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 4f1b0fd commit 6a27310

File tree

4 files changed

+75
-41
lines changed

4 files changed

+75
-41
lines changed

utils/application_snapshot.gni

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,62 @@ template("_application_snapshot") {
7474
if (defined(invoker.output)) {
7575
output = invoker.output
7676
}
77+
78+
# Build the kernel file using the prebuilt VM to speed up the debug and
79+
# simulator builds.
80+
prebuilt_dart_action(target_name + "_dill") {
81+
deps =
82+
extra_deps + [
83+
"$_dart_root/runtime/vm:kernel_platform_files($dart_host_toolchain)",
84+
"$_dart_root/runtime/vm:vm_platform",
85+
]
86+
gen_kernel_script = "$_dart_root/pkg/vm/bin/gen_kernel.dart"
87+
platform_dill = "$root_out_dir/vm_platform_strong.dill"
88+
89+
inputs = extra_inputs + [
90+
gen_kernel_script,
91+
platform_dill,
92+
main_dart,
93+
dot_packages,
94+
]
95+
output = "$target_gen_dir/$name.dart.dill"
96+
outputs = [
97+
output,
98+
]
99+
100+
depfile = "$output.d"
101+
abs_depfile = rebase_path(depfile)
102+
rebased_output = rebase_path(output, root_build_dir)
103+
vm_args = [
104+
"--depfile=$abs_depfile",
105+
"--depfile_output_filename=$rebased_output",
106+
]
107+
108+
script = gen_kernel_script
109+
110+
args = [
111+
"--packages=" + rebase_path(dot_packages),
112+
"--platform=" + rebase_path(platform_dill),
113+
"--no-aot",
114+
"--no-embed-sources",
115+
"--no-link-platform",
116+
"--output=" + rebase_path(output),
117+
]
118+
if (dart_platform_bytecode) {
119+
args += [
120+
"--gen-bytecode",
121+
"--drop-ast",
122+
"--bytecode-options=source-positions",
123+
]
124+
}
125+
args += [ rebase_path(main_dart) ]
126+
}
127+
77128
dart_action(target_name) {
78-
deps = extra_deps
129+
deps = extra_deps + [ ":${target_name}_dill" ]
79130
depfile = "$output.d"
80131

81-
script = main_dart
132+
script = "$target_gen_dir/$name.dart.dill"
82133

83134
inputs = extra_inputs
84135

@@ -90,16 +141,14 @@ template("_application_snapshot") {
90141
abs_output = rebase_path(output, root_build_dir)
91142

92143
vm_args = [
93-
"--deterministic",
94-
"--packages=$dot_packages",
95-
"--snapshot=$abs_output",
96-
"--snapshot-depfile=$abs_depfile",
97-
] + snapshot_vm_args
144+
"--deterministic",
145+
"--packages=$dot_packages",
146+
"--snapshot=$abs_output",
147+
"--snapshot-depfile=$abs_depfile",
148+
] + snapshot_vm_args
98149

99150
if (dart_snapshot_kind == "kernel") {
100-
vm_args += [
101-
"--snapshot-kind=kernel",
102-
]
151+
vm_args += [ "--snapshot-kind=kernel" ]
103152
assert(training_args != "", "Ignoring unused argument")
104153
args = []
105154
} else if (dart_snapshot_kind == "app-jit") {
@@ -141,9 +190,7 @@ template("application_snapshot") {
141190
if (!defined(invoker.deps)) {
142191
deps = []
143192
}
144-
deps += [
145-
"$_dart_root/utils/kernel-service:kernel-service"
146-
]
193+
deps += [ "$_dart_root/utils/kernel-service:kernel-service" ]
147194
}
148195
}
149196

utils/compiler/BUILD.gn

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# BSD-style license that can be found in the LICENSE file.
44

55
import("../../utils/compile_platform.gni")
6-
import("../create_timestamp.gni")
76
import("../application_snapshot.gni")
7+
import("../create_timestamp.gni")
88

99
create_timestamp_file("dart2js_files_stamp") {
1010
path = rebase_path("../../pkg/compiler/lib")
@@ -21,18 +21,13 @@ create_timestamp_file("dartdoc_files_stamp") {
2121
output = "$target_gen_dir/dartdoc_files.stamp"
2222
}
2323

24-
dart_action("dart2js_create_snapshot_entry") {
24+
prebuilt_dart_action("dart2js_create_snapshot_entry") {
2525
deps = [
2626
":dart2js_files_stamp",
2727
":dartdoc_files_stamp",
2828
":runtime_lib_files_stamp",
2929
]
3030

31-
# dart_action() needs kernel service snapshot to run in Dart 2 mode.
32-
# This can't be added as a dependency to dart_action() itself as it will
33-
# create a circular dependency.
34-
deps += [ "../../utils/kernel-service:kernel-service" ]
35-
3631
output_dir = rebase_path(target_gen_dir)
3732

3833
script = "create_snapshot_entry.dart"

utils/dartdevc/BUILD.gn

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ application_snapshot("dartdevc") {
3030
":dartdevc_kernel_sdk_outline",
3131
]
3232

33-
inputs = [ sdk_dill ]
33+
inputs = [
34+
sdk_dill,
35+
]
3436
}
3537

3638
sdk_lib_files = exec_script("../../tools/list_dart_files.py",
@@ -62,16 +64,11 @@ template("dart2js_compile") {
6264
abs_main = rebase_path(main)
6365
abs_output = rebase_path(out)
6466

65-
dart_action(target_name) {
67+
prebuilt_dart_action(target_name) {
6668
deps = [
6769
"../compiler:compile_dart2js_platform",
6870
]
6971

70-
# dart_action() needs kernel service snapshot to run in Dart 2 mode.
71-
# This can't be added as a dependency to dart_action() itself as it will
72-
# create a circular dependency.
73-
deps += [ "../../utils/kernel-service:kernel-service" ]
74-
7572
inputs = sdk_lib_files + compiler_files + dev_compiler_files + [
7673
"$root_out_dir/dart2js_platform.dill",
7774
"$root_out_dir/dart2js_outline.dill",
@@ -89,6 +86,7 @@ template("dart2js_compile") {
8986
"-m",
9087
"-o$abs_output",
9188
"--no-source-maps",
89+
"--platform-binaries=" + rebase_path("$root_out_dir"),
9290
]
9391
}
9492
}
@@ -211,8 +209,8 @@ prebuilt_dart_action("dartdevc_sdk") {
211209
group("dartdevc_test") {
212210
deps = [
213211
":dartdevc",
214-
":dartdevc_sdk",
215212
":dartdevc_kernel_sdk",
213+
":dartdevc_sdk",
216214
":dartdevc_test_pkg",
217215
"../../sdk:create_sdk",
218216
]
@@ -223,8 +221,8 @@ group("dartdevc_test") {
223221
# building the Dart VM and create_sdk.
224222
group("dartdevc_test_local") {
225223
deps = [
226-
":dartdevc_sdk",
227224
":dartdevc_kernel_sdk",
225+
":dartdevc_sdk",
228226
":dartdevc_test_pkg",
229227
]
230228
}
@@ -244,10 +242,10 @@ create_timestamp_file("dartdevc_sdk_patch_stamp") {
244242
prebuilt_dart_action("dartdevc_test_pkg") {
245243
deps = [
246244
":dartdevc_files_stamp",
247-
":dartdevc_sdk",
248245
":dartdevc_kernel_sdk",
249-
":dartdevc_kernel_sdk_outline",
250246
":dartdevc_kernel_sdk_libraries_json",
247+
":dartdevc_kernel_sdk_outline",
248+
":dartdevc_sdk",
251249
"../../pkg:pkg_files_stamp",
252250
]
253251

@@ -319,9 +317,9 @@ prebuilt_dart_action("dartdevc_test_pkg") {
319317

320318
prebuilt_dart_action("dartdevc_kernel_sdk_outline") {
321319
deps = [
322-
"../../pkg:pkg_files_stamp",
323320
":dartdevc_files_stamp",
324321
":dartdevc_sdk_patch_stamp",
322+
"../../pkg:pkg_files_stamp",
325323
]
326324

327325
inputs = [
@@ -349,7 +347,7 @@ prebuilt_dart_action("dartdevc_kernel_sdk_outline") {
349347
"--output",
350348
rebase_path(sdk_dill),
351349
"--source",
352-
"dart:core"
350+
"dart:core",
353351
]
354352
}
355353

@@ -365,9 +363,9 @@ copy("dartdevc_kernel_sdk_libraries_json") {
365363
# Compiles the DDC SDK's kernel summary and JS code.
366364
prebuilt_dart_action("dartdevc_kernel_sdk") {
367365
deps = [
368-
"../../pkg:pkg_files_stamp",
369366
":dartdevc_files_stamp",
370367
":dartdevc_sdk_patch_stamp",
368+
"../../pkg:pkg_files_stamp",
371369
]
372370

373371
inputs = [

utils/kernel-service/BUILD.gn

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import("../application_snapshot.gni")
1010
group("kernel-service") {
1111
if (create_kernel_service_snapshot) {
1212
deps = [
13-
# TODO(rmacnak): Link this into 'dart'.
1413
":copy_kernel-service_snapshot",
1514
]
1615
} else {
@@ -20,13 +19,8 @@ group("kernel-service") {
2019
}
2120
}
2221

23-
# TODO: Switch this to use kernel based app-jit snapshot
24-
# when we are ready to switch to the kernel based core snapshots.
2522
kernel_application_snapshot("kernel-service_snapshot") {
26-
main_dart = "$root_gen_dir/kernel_service.dill"
27-
deps = [
28-
":kernel_service_dill",
29-
]
23+
main_dart = "../../pkg/vm/bin/kernel_service.dart"
3024
training_args = [
3125
"--train",
3226

0 commit comments

Comments
 (0)