From 52f1a4ef549eabe30a49dc68388be8c81e3e3e6a Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 8 Jun 2026 14:27:51 -0700 Subject: [PATCH] [build] Too many deps! - Break false dependency of non-VM platforms on VM platform - Break false dependency of bootstrap gen_kernel on VM platform - Extend precompile_tools to gen_kernel steps - Rename intermediate kernel files so JIT versus AOT is visible in ninjatracing TEST=ci Change-Id: I07011abe8303597af61d2b8c73e788b661482cc0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510060 Reviewed-by: Alexander Aprelev Commit-Queue: Ryan Macnak --- BUILD.gn | 14 +-- build/rbe/rewrapper_dart.py | 51 ++++----- runtime/vm/BUILD.gn | 8 -- sdk/BUILD.gn | 10 +- sdk_args.gni | 1 + utils/BUILD.gn | 49 ++++++++- utils/aot_snapshot.gni | 161 ++++++++++++++++++--------- utils/application_snapshot.gni | 194 +++++++++++++++++++++------------ utils/compile_platform.gni | 139 ++++++++++------------- utils/compiler/BUILD.gn | 6 +- utils/dart2wasm/BUILD.gn | 6 +- utils/dartpad/compile_wasm.gni | 2 +- utils/ddc/BUILD.gn | 2 +- utils/gen_kernel/BUILD.gn | 37 ------- utils/kernel-service/BUILD.gn | 7 +- 15 files changed, 387 insertions(+), 300 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 0aea36110a9..07d85a250dd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -144,10 +144,10 @@ group("dart2js") { group("dart2wasm_platform") { deps = [ ":runtime_precompiled", - "utils/dart2wasm:compile_dart2wasm_js_compatibility_platform", - "utils/dart2wasm:compile_dart2wasm_platform", - "utils/dart2wasm:compile_dart2wasm_standalone_platform", + "utils/dart2wasm:dart2wasm_js_compatibility_platform", + "utils/dart2wasm:dart2wasm_platform", "utils/dart2wasm:dart2wasm_snapshot", + "utils/dart2wasm:dart2wasm_standalone_platform", ] if (defined(is_product)) { if (is_product) { @@ -202,8 +202,8 @@ group("analysis_server") { group("tools") { deps = [ - "utils:compile_platform.exe", - "utils:gen_kernel.exe", + "utils:bootstrap_compile_platform.exe", + "utils:bootstrap_gen_kernel.exe", ] } @@ -269,8 +269,8 @@ group("dartfuzz") { deps = [ "runtime/bin:dartaotruntime", "runtime/bin:dartvm", - "utils/compiler:compile_dart2js_platform", - "utils/dart2wasm:compile_dart2wasm_platform", + "utils/compiler:dart2js_platform", + "utils/dart2wasm:dart2wasm_platform", "utils/kernel-service", ] } diff --git a/build/rbe/rewrapper_dart.py b/build/rbe/rewrapper_dart.py index 18b37ee84b8..93af4052863 100644 --- a/build/rbe/rewrapper_dart.py +++ b/build/rbe/rewrapper_dart.py @@ -301,19 +301,19 @@ trace to find the place to insert the appropriate support. elif arg == '../../pkg/compiler/lib/src/dart2js.dart': self.entry_points.add(self.rebase(arg)) return self.parse_dart2js() - elif arg == 'obj/utils/compiler/dart2js.dart.dill': + elif arg == 'obj/utils/compiler/dart2js.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_dart2js() elif arg == '../../pkg/dev_compiler/bin/dartdevc.dart': self.entry_points.add(self.rebase(arg)) return self.parse_dartdevc() - elif arg == 'obj/utils/ddc/dartdevc.dart.dill': + elif arg == 'obj/utils/ddc/dartdevc.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_dartdevc() - elif arg == 'obj/utils/dartanalyzer/dartanalyzer.dart.dill': + elif arg == 'obj/utils/dartanalyzer/dartanalyzer.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_dartanalyzer() - elif arg == 'obj/utils/analysis_server/analysis_server.dart.dill': + elif arg == 'obj/utils/analysis_server/analysis_server.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_analysis_server() elif arg == '../../pkg/front_end/tool/compile_platform.dart': @@ -331,28 +331,31 @@ trace to find the place to insert the appropriate support. elif arg == '../../pkg/vm/bin/gen_kernel.dart': self.entry_points.add(self.rebase(arg)) return self.parse_gen_kernel() - elif arg == 'obj/utils/kernel-service/frontend_server.dart.dill': + elif arg == 'obj/utils/kernel-service/frontend_server.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_frontend_server() - elif arg == 'obj/utils/dtd/generate_dtd_snapshot.dart.dill': + elif arg == 'obj/utils/dtd/generate_dtd_snapshot.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_generate_dtd_snapshot() - elif arg == 'obj/utils/dds/generate_dds_snapshot.dart.dill': + elif arg == 'obj/utils/dds/generate_dds_snapshot.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_generate_dds_snapshot() - elif arg == 'obj/utils/bazel/kernel_worker.dart.dill': + elif arg == 'obj/utils/bazel/kernel_worker.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_kernel_worker() - elif arg == 'obj/utils/dart_runtime_service_vm/generate_dart_runtime_service_vm_snapshot.dart.dill': + elif arg == 'obj/utils/dart_runtime_service_vm/generate_dart_runtime_service_vm_snapshot.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_generate_dart_runtime_service_vm_snapshot() - elif arg == 'obj/utils/dartdev/generate_dartdev_snapshot.dart.dill': + elif arg == 'obj/utils/dartdev/generate_dartdev_snapshot.jit.dill': self.extra_paths.add(self.rebase(arg)) return self.parse_generate_dartdev_snapshot() - elif arg == 'gen/utils/gen_kernel/bootstrap_gen_kernel.dill': + elif arg == 'obj/utils/bootstrap_gen_kernel.dill': self.extra_paths.add(self.rebase(arg)) - return self.parse_bootstrap_gen_kernel() - elif arg == 'obj/utils/kernel-service/kernel-service_snapshot.dart.dill': + return self.parse_gen_kernel() + elif arg == 'obj/utils/bootstrap_compile_platform.dill': + self.extra_paths.add(self.rebase(arg)) + return self.parse_compile_platform() + elif arg == 'obj/utils/kernel-service/kernel-service_snapshot.jit.dill': self.extra_paths.add(self.rebase(arg)) self.extra_paths.add( self.rebase( @@ -644,29 +647,13 @@ trace to find the place to insert the appropriate support. self.outputs.append(self.rebase(self.optarg)) elif self.get_option(['--platform']): self.extra_paths.add(self.rebase(self.optarg)) + elif self.get_option(['--dynamic-interface']): + self.extra_paths.add(self.rebase(self.optarg)) elif self.get_option([ '--packages', '-D', '--filesystem-root', '--filesystem-scheme' ]): pass - elif arg in ['--no-aot', '--no-embed-sources']: - pass - elif not arg.startswith('-'): - self.entry_points.add(self.rebase(arg)) - else: - self.unsupported('gen_kernel', arg) - - def parse_bootstrap_gen_kernel(self): - while self.has_next_arg: - arg = self.next_arg() - if self.get_option(['-o', '--output']): - self.outputs.append(self.rebase(self.optarg)) - elif self.get_option(['--platform']): - self.extra_paths.add(self.rebase(self.optarg)) - elif self.get_option(['--dynamic-interface']): - self.extra_paths.add(self.rebase(self.optarg)) - elif self.get_option(['--packages', '-D']): - pass elif arg in [ '--aot', '--no-aot', @@ -681,7 +668,7 @@ trace to find the place to insert the appropriate support. elif not arg.startswith('-'): self.entry_points.add(self.rebase(arg)) else: - self.unsupported('bootstrap_gen_kernel', arg) + self.unsupported('gen_kernel', arg) def parse_kernel_service_snapshot(self): while self.has_next_arg: diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn index eca06429bcc..168d6ecc9c7 100644 --- a/runtime/vm/BUILD.gn +++ b/runtime/vm/BUILD.gn @@ -163,10 +163,6 @@ template("gen_vm_platform") { } compile_platform(target_name) { output_postfix = invoker.output_postfix - if (defined(invoker.add_implicit_vm_platform_dependency)) { - add_implicit_vm_platform_dependency = - invoker.add_implicit_vm_platform_dependency - } single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("../../", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///sdk/lib/libraries.json" @@ -185,18 +181,15 @@ template("gen_vm_platform") { if (defined(invoker.exclude_source) && invoker.exclude_source) { args += [ "--exclude-source" ] } - outline = "vm_outline" + output_postfix + ".dill" } } gen_vm_platform("vm_platform") { - add_implicit_vm_platform_dependency = false exclude_source = false output_postfix = "" } gen_vm_platform("vm_platform_product") { - add_implicit_vm_platform_dependency = false exclude_source = false output_postfix = "_product" @@ -206,7 +199,6 @@ gen_vm_platform("vm_platform_product") { } gen_vm_platform("vm_platform_stripped") { - add_implicit_vm_platform_dependency = false exclude_source = true output_postfix = "_stripped" } diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index aff195df527..aeb98fa93b1 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -643,8 +643,8 @@ copy("copy_dart2js_dill_files") { visibility = [ ":*" ] deps = [ ":copy_libraries", - "../utils/compiler:compile_dart2js_platform", - "../utils/compiler:compile_dart2js_server_platform", + "../utils/compiler:dart2js_platform", + "../utils/compiler:dart2js_server_platform", ] sources = [ "$root_out_dir/dart2js_platform.dill", @@ -659,9 +659,9 @@ copy("copy_dart2wasm_platform") { deps = [ ":copy_libraries", "../:dart2wasm_platform", - "../utils/dart2wasm:compile_dart2wasm_js_compatibility_platform", - "../utils/dart2wasm:compile_dart2wasm_platform", - "../utils/dart2wasm:compile_dart2wasm_standalone_platform", + "../utils/dart2wasm:dart2wasm_js_compatibility_platform", + "../utils/dart2wasm:dart2wasm_platform", + "../utils/dart2wasm:dart2wasm_standalone_platform", ] sources = [ "$root_out_dir/dart2wasm_js_compatibility_outline.dill", diff --git a/sdk_args.gni b/sdk_args.gni index 84e8983fb29..7ded6a96799 100644 --- a/sdk_args.gni +++ b/sdk_args.gni @@ -21,6 +21,7 @@ declare_args() { # compile_platform.dart script instead of running it from source. This # can significantly improve iteration time when iteration on changes in # core libraries. + # TODO(63495): Make this the default. precompile_tools = false # When set to `true`, the Dart Runtime Service based implementation of the diff --git a/utils/BUILD.gn b/utils/BUILD.gn index ee7d80b0a32..fec098d5d5a 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -7,6 +7,35 @@ import("../sdk_args.gni") _dart_root = get_path_info("..", "abspath") +template("kernel_compile_using_prebuilt_sdk") { + prebuilt_dart_action(target_name) { + forward_variables_from(invoker, + [ + "deps", + "pool", + "testonly", + "visibility", + ]) + inputs = [ + invoker.entry_point, + invoker.package_config, + ] + + outputs = [ invoker.output ] + + depfile = invoker.output + ".d" + + vm_args = [ + "--snapshot-kind=kernel", + "--snapshot=" + rebase_path(invoker.output, root_build_dir), + "--depfile=" + rebase_path(depfile, root_build_dir), + "--packages=" + rebase_path(invoker.package_config, root_build_dir), + ] + script = invoker.entry_point + args = [] + } +} + template("aot_compile_using_prebuilt_sdk") { prebuilt_dart_action(target_name) { forward_variables_from(invoker, @@ -39,15 +68,27 @@ template("aot_compile_using_prebuilt_sdk") { } } -aot_compile_using_prebuilt_sdk("compile_platform.exe") { +kernel_compile_using_prebuilt_sdk("bootstrap_compile_platform.dill") { entry_point = "$_dart_root/pkg/front_end/tool/compile_platform.dart" - output = "$root_out_dir/compile_platform.exe" + output = "$target_out_dir/bootstrap_compile_platform.dill" package_config = "$_dart_root/.dart_tool/package_config.json" } -aot_compile_using_prebuilt_sdk("gen_kernel.exe") { +aot_compile_using_prebuilt_sdk("bootstrap_compile_platform.exe") { + entry_point = "$_dart_root/pkg/front_end/tool/compile_platform.dart" + output = "$root_out_dir/bootstrap_compile_platform.exe" + package_config = "$_dart_root/.dart_tool/package_config.json" +} + +kernel_compile_using_prebuilt_sdk("bootstrap_gen_kernel.dill") { entry_point = "$_dart_root/pkg/vm/bin/gen_kernel.dart" - output = "$root_out_dir/gen_kernel.exe" + output = "$target_out_dir/bootstrap_gen_kernel.dill" + package_config = "$_dart_root/.dart_tool/package_config.json" +} + +aot_compile_using_prebuilt_sdk("bootstrap_gen_kernel.exe") { + entry_point = "$_dart_root/pkg/vm/bin/gen_kernel.dart" + output = "$root_out_dir/bootstrap_gen_kernel.exe" package_config = "$_dart_root/.dart_tool/package_config.json" } diff --git a/utils/aot_snapshot.gni b/utils/aot_snapshot.gni index da742f0be50..4640d7ac688 100644 --- a/utils/aot_snapshot.gni +++ b/utils/aot_snapshot.gni @@ -44,69 +44,130 @@ template("aot_snapshot") { output = invoker.output } - dill = "$target_out_dir/$name.dart.dill" + dill = "$target_out_dir/$name.aot.dill" unsigned_snapshot = "$target_out_dir/$name.dart.snapshot.unsigned" signed_snapshot = output # Build the kernel file using the prebuilt VM to speed up the debug and # simulator builds. kernel_label = target_name + "_dill" - prebuilt_dart_action(kernel_label) { - mnemonic = "GEN_KERNEL" - if (defined(invoker.pool)) { - pool = invoker.pool - } - deps = extra_deps + [ - "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", - "$_dart_root/runtime/vm:vm_platform", - "$_dart_root/utils/gen_kernel:bootstrap_gen_kernel", - ] - gen_kernel_kernel = - get_label_info("$_dart_root/utils/gen_kernel:bootstrap_gen_kernel", - "target_gen_dir") + "/bootstrap_gen_kernel.dill" - platform_dill = "$root_out_dir/vm_platform.dill" + if (precompile_tools) { + action(kernel_label) { + mnemonic = "GEN_KERNEL" + if (defined(invoker.pool)) { + pool = invoker.pool + } else { + pool = "$_dart_root/build/dart:dart_action_pool($default_toolchain)" + } - inputs = extra_inputs + [ - gen_kernel_kernel, - platform_dill, - main_dart, - package_config, + gen_kernel_tool = + "$_dart_root/utils:bootstrap_gen_kernel.exe($host_toolchain)" + gen_kernel_exe = get_label_info(gen_kernel_tool, "root_out_dir") + + "/bootstrap_gen_kernel.exe" + + deps = extra_deps + [ + "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", + "$_dart_root/runtime/vm:vm_platform", + gen_kernel_tool, ] - output = dill - outputs = [ output ] + platform_dill = "$root_out_dir/vm_platform.dill" - depfile = "$output.d" + inputs = extra_inputs + [ + gen_kernel_exe, + platform_dill, + main_dart, + package_config, + ] + output = dill + outputs = [ output ] - vm_args = [ - # Ensure gen_kernel.dart will use this SDK hash when consuming/producing - # kernel. - "-Dsdk_hash=$sdk_hash", - ] + depfile = "$output.d" - script = gen_kernel_kernel + script = "$_dart_root/build/gn_run_binary.py" - args = [ - "--packages=" + rebase_path(package_config, root_build_dir), - "--platform=" + rebase_path(platform_dill, root_build_dir), - "--aot", - "--output=" + rebase_path(output, root_build_dir), - "--depfile=" + rebase_path(depfile, root_build_dir), + args = [ + rebase_path(gen_kernel_exe, root_build_dir), + "--packages=" + rebase_path(package_config, root_build_dir), + "--platform=" + rebase_path(platform_dill, root_build_dir), + "--aot", + "--output=" + rebase_path(output, root_build_dir), + "--depfile=" + rebase_path(depfile, root_build_dir), - # Ensure the compiled application (e.g. kernel-service, frontend-server, - # ...) will use this SDK hash when consuming/producing kernel. - # - # (Instead of ensuring every user of the "application_snapshot" / - # "kernel_snapshot" passes this if needed, we always pass it) - "-Dsdk_hash=$sdk_hash", - "-Ddart.vm.product=$product_mode", - "-Ddart.vm.asan=$is_asan", - "-Ddart.vm.msan=$is_msan", - "-Ddart.vm.tsan=$is_tsan", - ] - args += gen_kernel_args - args += [ rebase_path(main_dart, root_build_dir) ] - if (defined(invoker.args)) { - args += invoker.args + # Ensure the compiled application (e.g. kernel-service, frontend-server, + # ...) will use this SDK hash when consuming/producing kernel. + # + # (Instead of ensuring every user of the "application_snapshot" / + # "kernel_snapshot" passes this if needed, we always pass it) + "-Dsdk_hash=$sdk_hash", + "-Ddart.vm.product=$product_mode", + "-Ddart.vm.asan=$is_asan", + "-Ddart.vm.msan=$is_msan", + "-Ddart.vm.tsan=$is_tsan", + ] + args += gen_kernel_args + args += [ rebase_path(main_dart, root_build_dir) ] + if (defined(invoker.args)) { + args += invoker.args + } + } + } else { + prebuilt_dart_action(kernel_label) { + mnemonic = "GEN_KERNEL" + if (defined(invoker.pool)) { + pool = invoker.pool + } + deps = extra_deps + [ + "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", + "$_dart_root/runtime/vm:vm_platform", + "$_dart_root/utils:bootstrap_gen_kernel.dill", + ] + gen_kernel_kernel = + get_label_info("$_dart_root/utils:bootstrap_gen_kernel.dill", + "target_out_dir") + "/bootstrap_gen_kernel.dill" + platform_dill = "$root_out_dir/vm_platform.dill" + + inputs = extra_inputs + [ + gen_kernel_kernel, + platform_dill, + main_dart, + package_config, + ] + output = dill + outputs = [ output ] + + depfile = "$output.d" + + vm_args = [ + # Ensure gen_kernel.dart will use this SDK hash when consuming/producing + # kernel. + "-Dsdk_hash=$sdk_hash", + ] + + script = gen_kernel_kernel + + args = [ + "--packages=" + rebase_path(package_config, root_build_dir), + "--platform=" + rebase_path(platform_dill, root_build_dir), + "--aot", + "--output=" + rebase_path(output, root_build_dir), + "--depfile=" + rebase_path(depfile, root_build_dir), + + # Ensure the compiled application (e.g. kernel-service, frontend-server, + # ...) will use this SDK hash when consuming/producing kernel. + # + # (Instead of ensuring every user of the "application_snapshot" / + # "kernel_snapshot" passes this if needed, we always pass it) + "-Dsdk_hash=$sdk_hash", + "-Ddart.vm.product=$product_mode", + "-Ddart.vm.asan=$is_asan", + "-Ddart.vm.msan=$is_msan", + "-Ddart.vm.tsan=$is_tsan", + ] + args += gen_kernel_args + args += [ rebase_path(main_dart, root_build_dir) ] + if (defined(invoker.args)) { + args += invoker.args + } } } diff --git a/utils/application_snapshot.gni b/utils/application_snapshot.gni index bdad9c8290a..7a74c81d3cb 100644 --- a/utils/application_snapshot.gni +++ b/utils/application_snapshot.gni @@ -117,89 +117,151 @@ template("application_snapshot") { gen_kernel_args += invoker.gen_kernel_args } - # Build the kernel file using the prebuilt VM to speed up the debug and - # simulator builds. - prebuilt_dart_action(target_name + "_dill") { - mnemonic = "GEN_KERNEL" - if (defined(invoker.pool)) { - pool = invoker.pool - } - deps = extra_deps + [ - "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", - "$_dart_root/runtime/vm:vm_platform", - "$_dart_root/utils/gen_kernel:bootstrap_gen_kernel", - ] - gen_kernel_kernel = - get_label_info("$_dart_root/utils/gen_kernel:bootstrap_gen_kernel", - "target_gen_dir") + "/bootstrap_gen_kernel.dill" - platform_dill = "$root_out_dir/vm_platform.dill" + if (precompile_tools) { + action(target_name + "_dill") { + mnemonic = "GEN_KERNEL" + if (defined(invoker.pool)) { + pool = invoker.pool + } else { + pool = "$_dart_root/build/dart:dart_action_pool($default_toolchain)" + } - inputs = extra_inputs + [ - gen_kernel_kernel, - platform_dill, - main_dart, - package_config, + gen_kernel_tool = "$_dart_root/utils:bootstrap_gen_kernel.exe" + gen_kernel_exe = get_label_info(gen_kernel_tool, "root_out_dir") + + "/bootstrap_gen_kernel.exe" + + deps = extra_deps + [ + "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", + "$_dart_root/runtime/vm:vm_platform", + gen_kernel_tool, ] - output = "$target_out_dir/$name.dart.dill" - outputs = [ output ] + platform_dill = "$root_out_dir/vm_platform.dill" - depfile = "$output.d" + inputs = extra_inputs + [ + gen_kernel_exe, + platform_dill, + main_dart, + package_config, + ] + output = "$target_out_dir/$name.jit.dill" + outputs = [ output ] - vm_args = [ - # Ensure gen_kernel.dart will use this SDK hash when consuming/producing - # kernel. - "-Dsdk_hash=$sdk_hash", - ] + depfile = "$output.d" - script = gen_kernel_kernel - is_product_flag = dart_runtime_mode == "release" + script = "$_dart_root/build/gn_run_binary.py" + is_product_flag = dart_runtime_mode == "release" - args = [ - "--packages=" + rebase_path(package_config, root_build_dir), - "--platform=" + rebase_path(platform_dill, root_build_dir), - "--no-aot", - "--no-embed-sources", - "--no-link-platform", - "--output=" + rebase_path(output, root_build_dir), - "--depfile=" + rebase_path(depfile, root_build_dir), + args = [ + rebase_path(gen_kernel_exe, root_build_dir), + "--packages=" + rebase_path(package_config, root_build_dir), + "--platform=" + rebase_path(platform_dill, root_build_dir), + "--no-aot", + "--no-embed-sources", + "--no-link-platform", + "--output=" + rebase_path(output, root_build_dir), + "--depfile=" + rebase_path(depfile, root_build_dir), - # Ensure the compiled application (e.g. kernel-service, frontend-server, - # ...) will use this SDK hash when consuming/producing kernel. - # - # (Instead of ensuring every user of the "application_snapshot" / - # "kernel_snapshot" passes this if needed, we always pass it) - "-Dsdk_hash=$sdk_hash", - "-Ddart.vm.product=$is_product_flag", - "-Ddart.vm.asan=$is_asan", - "-Ddart.vm.msan=$is_msan", - "-Ddart.vm.tsan=$is_tsan", - ] - args += gen_kernel_args - args += [ rebase_path(main_dart, root_build_dir) ] + # Ensure the compiled application (e.g. kernel-service, frontend-server, + # ...) will use this SDK hash when consuming/producing kernel. + # + # (Instead of ensuring every user of the "application_snapshot" / + # "kernel_snapshot" passes this if needed, we always pass it) + "-Dsdk_hash=$sdk_hash", + "-Ddart.vm.product=$is_product_flag", + "-Ddart.vm.asan=$is_asan", + "-Ddart.vm.msan=$is_msan", + "-Ddart.vm.tsan=$is_tsan", + ] + args += gen_kernel_args + args += [ rebase_path(main_dart, root_build_dir) ] + } + } else { + prebuilt_dart_action(target_name + "_dill") { + mnemonic = "GEN_KERNEL" + if (defined(invoker.pool)) { + pool = invoker.pool + } + deps = extra_deps + [ + "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", + "$_dart_root/runtime/vm:vm_platform", + "$_dart_root/utils:bootstrap_gen_kernel.dill", + ] + gen_kernel_kernel = + get_label_info("$_dart_root/utils:bootstrap_gen_kernel.dill", + "target_out_dir") + "/bootstrap_gen_kernel.dill" + platform_dill = "$root_out_dir/vm_platform.dill" + + inputs = extra_inputs + [ + gen_kernel_kernel, + platform_dill, + main_dart, + package_config, + ] + output = "$target_out_dir/$name.jit.dill" + outputs = [ output ] + + depfile = "$output.d" + + vm_args = [ + # Ensure gen_kernel.dart will use this SDK hash when consuming/producing + # kernel. + "-Dsdk_hash=$sdk_hash", + ] + + script = gen_kernel_kernel + is_product_flag = dart_runtime_mode == "release" + + args = [ + "--packages=" + rebase_path(package_config, root_build_dir), + "--platform=" + rebase_path(platform_dill, root_build_dir), + "--no-aot", + "--no-embed-sources", + "--no-link-platform", + "--output=" + rebase_path(output, root_build_dir), + "--depfile=" + rebase_path(depfile, root_build_dir), + + # Ensure the compiled application (e.g. kernel-service, frontend-server, + # ...) will use this SDK hash when consuming/producing kernel. + # + # (Instead of ensuring every user of the "application_snapshot" / + # "kernel_snapshot" passes this if needed, we always pass it) + "-Dsdk_hash=$sdk_hash", + "-Ddart.vm.product=$is_product_flag", + "-Ddart.vm.asan=$is_asan", + "-Ddart.vm.msan=$is_msan", + "-Ddart.vm.tsan=$is_tsan", + ] + args += gen_kernel_args + args += [ rebase_path(main_dart, root_build_dir) ] + } } # Create a snapshot from kernel built above. if (dart_snapshot_kind == "kernel") { copy(target_name) { deps = extra_deps + [ ":${target_name}_dill" ] - sources = [ "$target_out_dir/$name.dart.dill" ] + sources = [ "$target_out_dir/$name.jit.dill" ] outputs = [ output ] - assert(snapshot_vm_args != "", "Ignoring unused argument") - assert(training_args != "", "Ignoring unused argument") - assert(training_inputs != "", "Ignoring unused argument") - assert(training_deps != "", "Ignoring unused argument") + not_needed([ + "snapshot_vm_args", + "training_args", + "training_inputs", + "training_deps", + ]) } - } else { + } else if (dart_snapshot_kind == "app-jit") { dart_action(target_name) { mnemonic = "APP_JIT" if (defined(invoker.pool)) { pool = invoker.pool } deps = extra_deps + [ ":${target_name}_dill" ] + training_deps - depfile = "$output.d" - script = "$target_out_dir/$name.dart.dill" + # No depfile needed when running from a kernel file. The set of inputs is + # known at GN time. + + script = "$target_out_dir/$name.jit.dill" inputs = extra_inputs + training_inputs @@ -212,16 +274,12 @@ template("application_snapshot") { vm_args = [ "--deterministic", "--packages=" + rebase_path(package_config, root_build_dir), + "--snapshot-kind=app-jit", "--snapshot=" + rebase_path(output, root_build_dir), - "--snapshot-depfile=" + rebase_path(depfile, root_build_dir), ] + 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") - } + args = training_args } + } else { + assert(false, "Unknown snapshot_kind: $dart_snapshot_kind") } } diff --git a/utils/compile_platform.gni b/utils/compile_platform.gni index 4bdd9a8b6f9..853ed5ebef8 100644 --- a/utils/compile_platform.gni +++ b/utils/compile_platform.gni @@ -23,32 +23,71 @@ template("compile_platform") { assert(!defined(invoker.script), "Remove 'script' from $target_name") assert(!defined(invoker.depfile), "Remove 'depfile' from $target_name") - # In order to automatically compute dependencies, we need to add a dependency - # on vm_outline.dill. This is used to include the source code of Fasta itself - # in the dependency file. Without this, a change to Fasta wouldn't cause the - # platform dill files to be rebuilt. However, when building - # vm_outline.dill, we shouldn't list it as a dependency as this would - # lead to cyclic dependencies. - add_implicit_vm_platform_dependency = true - if (defined(invoker.add_implicit_vm_platform_dependency)) { - add_implicit_vm_platform_dependency = - invoker.add_implicit_vm_platform_dependency - } - - outline = "vm_outline.dill" - if (defined(invoker.outline)) { - outline = invoker.outline - } - if (precompile_tools) { action(target_name) { + mnemonic = "COMPILE_PLATFORM" + + if (defined(invoker.pool)) { + pool = invoker.pool + } else { + pool = "$_dart_root/build/dart:dart_action_pool($default_toolchain)" + } + + outputs = invoker.outputs + depfile = outputs[0] + ".d" + + compile_platform_tool = + "$_dart_root/utils:bootstrap_compile_platform.exe($host_toolchain)" + compile_platform_exe = + get_label_info(compile_platform_tool, "root_out_dir") + + "/bootstrap_compile_platform.exe" + + deps = [ compile_platform_tool ] + if (defined(invoker.deps)) { + deps += invoker.deps + } + + inputs = [ compile_platform_exe ] + if (defined(invoker.inputs)) { + inputs += invoker.inputs + } + + script = "$_dart_root/build/gn_run_binary.py" + args = [ rebase_path(compile_platform_exe, root_build_dir) ] + args += invoker.args + if (defined(invoker.single_root_scheme)) { + args += [ "--single-root-scheme=" + invoker.single_root_scheme ] + } + if (defined(invoker.single_root_base)) { + args += [ "--single-root-base=" + invoker.single_root_base ] + } + if (defined(invoker.single_root_scheme)) { + args += [ invoker.libraries_specification_uri ] + } else { + args += + [ rebase_path(invoker.libraries_specification_uri, root_build_dir) ] + } + args += [ "unused-vm-platform.dill" ] + args += rebase_path(outputs, root_build_dir) + } + } else { + prebuilt_dart_action(target_name) { + mnemonic = "COMPILE_PLATFORM" + if (defined(invoker.pool)) { pool = invoker.pool } - outputs = invoker.outputs + compile_platform_tool = + "$_dart_root/utils:bootstrap_compile_platform.dill($host_toolchain)" - compile_platform_tool = "//utils:compile_platform.exe($host_toolchain)" + script = get_label_info(compile_platform_tool, "target_out_dir") + + "/bootstrap_compile_platform.dill" + + outputs = invoker.outputs + depfile = outputs[0] + ".d" + + vm_args = [ "-Dsdk_hash=$sdk_hash" ] deps = [ compile_platform_tool ] if (defined(invoker.deps)) { @@ -60,19 +99,7 @@ template("compile_platform") { inputs += invoker.inputs } - if (add_implicit_vm_platform_dependency) { - inputs += [ "$root_out_dir/$outline" ] - deps += [ "$_dart_root/runtime/vm:vm_platform" ] - } - - depfile = outputs[0] + ".d" - - script = "$_dart_root/build/gn_run_binary.py" - args = - [ rebase_path(get_label_info(compile_platform_tool, "root_out_dir") + - "/compile_platform.exe", - root_build_dir) ] - args += invoker.args + args = invoker.args if (defined(invoker.single_root_scheme)) { args += [ "--single-root-scheme=" + invoker.single_root_scheme ] } @@ -85,53 +112,7 @@ template("compile_platform") { args += [ rebase_path(invoker.libraries_specification_uri, root_build_dir) ] } - args += [ rebase_path("$root_out_dir/$outline", root_build_dir) ] - args += rebase_path(outputs, root_build_dir) - } - } else { - prebuilt_dart_action(target_name) { - if (defined(invoker.pool)) { - pool = invoker.pool - } - script = "$_dart_root/pkg/front_end/tool/compile_platform.dart" - - packages = "$_dart_root/.dart_tool/package_config.json" - - outputs = invoker.outputs - - vm_args = [ "-Dsdk_hash=$sdk_hash" ] - - inputs = [] - deps = [] - args = [] - if (defined(invoker.deps)) { - deps += invoker.deps - } - - if (defined(invoker.inputs)) { - inputs += invoker.inputs - } - - if (add_implicit_vm_platform_dependency) { - inputs += [ "$root_out_dir/$outline" ] - deps += [ "$_dart_root/runtime/vm:vm_platform" ] - } - depfile = outputs[0] + ".d" - - args += invoker.args - if (defined(invoker.single_root_scheme)) { - args += [ "--single-root-scheme=" + invoker.single_root_scheme ] - } - if (defined(invoker.single_root_base)) { - args += [ "--single-root-base=" + invoker.single_root_base ] - } - if (defined(invoker.single_root_scheme)) { - args += [ invoker.libraries_specification_uri ] - } else { - args += - [ rebase_path(invoker.libraries_specification_uri, root_build_dir) ] - } - args += [ rebase_path("$root_out_dir/$outline", root_build_dir) ] + args += [ "unused-vm-platform.dill" ] args += rebase_path(outputs, root_build_dir) } } diff --git a/utils/compiler/BUILD.gn b/utils/compiler/BUILD.gn index 84cdc39a95e..27b7ce02f1e 100644 --- a/utils/compiler/BUILD.gn +++ b/utils/compiler/BUILD.gn @@ -54,7 +54,7 @@ sdk_root = "../../sdk" application_snapshot("dart2js") { deps = [ ":dart2js_create_snapshot_entry" ] - training_deps = [ ":compile_dart2js_platform" ] + training_deps = [ ":dart2js_platform" ] training_inputs = [ "$root_out_dir/dart2js_platform.dill", "$root_out_dir/dart2js_outline.dill", @@ -106,7 +106,7 @@ aot_snapshot("dart2js_sdk_aot_product") { force_product_mode = !dart_debug } -compile_platform("compile_dart2js_platform") { +compile_platform("dart2js_platform") { single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" @@ -122,7 +122,7 @@ compile_platform("compile_dart2js_platform") { "dart:core", ] } -compile_platform("compile_dart2js_server_platform") { +compile_platform("dart2js_server_platform") { single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" diff --git a/utils/dart2wasm/BUILD.gn b/utils/dart2wasm/BUILD.gn index d0086442462..c848f4cbc39 100644 --- a/utils/dart2wasm/BUILD.gn +++ b/utils/dart2wasm/BUILD.gn @@ -41,7 +41,7 @@ aot_snapshot("dart2wasm_product_snapshot") { force_product_mode = true } -compile_platform("compile_dart2wasm_platform") { +compile_platform("dart2wasm_platform") { single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" @@ -57,7 +57,7 @@ compile_platform("compile_dart2wasm_platform") { ] } -compile_platform("compile_dart2wasm_js_compatibility_platform") { +compile_platform("dart2wasm_js_compatibility_platform") { single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" @@ -74,7 +74,7 @@ compile_platform("compile_dart2wasm_js_compatibility_platform") { ] } -compile_platform("compile_dart2wasm_standalone_platform") { +compile_platform("dart2wasm_standalone_platform") { single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("$sdk_root/", root_build_dir) libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json" diff --git a/utils/dartpad/compile_wasm.gni b/utils/dartpad/compile_wasm.gni index 52ed5eadd84..e9a7d183992 100644 --- a/utils/dartpad/compile_wasm.gni +++ b/utils/dartpad/compile_wasm.gni @@ -82,7 +82,7 @@ template("compile_dart2wasm") { } deps = [ - "../dart2wasm:compile_dart2wasm_platform", + "../dart2wasm:dart2wasm_platform", "../dart2wasm:dart2wasm_snapshot", ] if (product_mode) { diff --git a/utils/ddc/BUILD.gn b/utils/ddc/BUILD.gn index b5b8ab2e25e..b8df0347534 100644 --- a/utils/ddc/BUILD.gn +++ b/utils/ddc/BUILD.gn @@ -63,7 +63,7 @@ template("dart2js_compile") { prebuilt_dart_action(target_name) { mnemonic = "DART2JS" - deps = invoker.deps + [ "../compiler:compile_dart2js_platform" ] + deps = invoker.deps + [ "../compiler:dart2js_platform" ] inputs = [ "$root_out_dir/dart2js_platform.dill", diff --git a/utils/gen_kernel/BUILD.gn b/utils/gen_kernel/BUILD.gn index 7068091e9da..572a7e54dc2 100644 --- a/utils/gen_kernel/BUILD.gn +++ b/utils/gen_kernel/BUILD.gn @@ -2,44 +2,7 @@ # 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. -import("../../build/dart/dart_action.gni") import("../../runtime/runtime_args.gni") -import("../../sdk_args.gni") - -_dart_root = get_path_info("../..", "abspath") - -prebuilt_dart_action("bootstrap_gen_kernel") { - deps = [ - "$_dart_root/runtime/vm:kernel_platform_files($host_toolchain)", - "$_dart_root/runtime/vm:vm_platform", - ] - gen_kernel_script = "$_dart_root/pkg/vm/bin/gen_kernel.dart" - platform_dill = "$root_out_dir/vm_platform.dill" - package_config = rebase_path("$_dart_root/.dart_tool/package_config.json") - - inputs = [ - gen_kernel_script, - platform_dill, - package_config, - ] - output = "$target_gen_dir/bootstrap_gen_kernel.dill" - outputs = [ output ] - - depfile = "$output.d" - vm_args = [ - "--snapshot-kind=kernel", - "--snapshot=" + rebase_path(output, root_build_dir), - "--depfile=" + rebase_path(depfile, root_build_dir), - - # Ensure gen_kernel.dart will use this SDK hash when consuming/producing kernel. - "-Dsdk_hash=$sdk_hash", - - "--packages=" + rebase_path(package_config, root_build_dir), - ] - script = gen_kernel_script - args = [] -} - import("../aot_snapshot.gni") aot_snapshot("gen_kernel") { diff --git a/utils/kernel-service/BUILD.gn b/utils/kernel-service/BUILD.gn index 7eb3b585329..4139de85ead 100644 --- a/utils/kernel-service/BUILD.gn +++ b/utils/kernel-service/BUILD.gn @@ -92,9 +92,12 @@ template("kernel_service_dill") { action("kernel_service" + target_name + "_dill") { if (defined(invoker.pool)) { pool = invoker.pool + } else { + pool = "$_dart_root/build/dart:dart_action_pool($default_toolchain)" } - gen_kernel_tool = "//utils:gen_kernel.exe($host_toolchain)" + gen_kernel_tool = + "$_dart_root/utils:bootstrap_gen_kernel.exe($host_toolchain)" kernel_service_script = "../../$_kernel_service_script" deps = [ @@ -113,7 +116,7 @@ template("kernel_service_dill") { script = "$_dart_root/build/gn_run_binary.py" args = [ rebase_path(get_label_info(gen_kernel_tool, "root_out_dir") + - "/gen_kernel.exe", + "/bootstrap_gen_kernel.exe", root_build_dir) ] args += invoker.extra_args args += [