Skip to content

Commit e6d55c6

Browse files
iinozemtsevCommit Queue
authored andcommitted
Add gen_snapshot binaries, producing Linux ARM64/x64 snapshots
Inspired by `//runtime/bin:gen_snapshot_fuchsia`, required for go/dart-cross-compile. TEST=ci, build only Change-Id: Ie521c984a8f44d25f3f78d946af9416582a572dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410402 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Ivan Inozemtsev <[email protected]>
1 parent ccb0fed commit e6d55c6

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

runtime/BUILD.gn

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ config("dart_os_fuchsia_config") {
128128
defines = [ "DART_TARGET_OS_FUCHSIA" ]
129129
}
130130

131+
# We need to build gen_snapshot targeting Linux ARM64 during a build
132+
# of the SDK. This configuration is used to unconditionally target
133+
# Linux ARM64. It should not be combined with dart_os_config and dart_arch_config.
134+
config("dart_linux_arm64_config") {
135+
defines = [
136+
"DART_TARGET_OS_LINUX",
137+
"TARGET_ARCH_ARM64",
138+
]
139+
}
140+
141+
# We need to build gen_snapshot targeting Linux ARM64 during a build
142+
# of the SDK. This configuration is used to unconditionally target
143+
# Linux ARM64. It should not be combined with dart_os_config and dart_arch_config.
144+
config("dart_linux_x64_config") {
145+
defines = [
146+
"DART_TARGET_OS_LINUX",
147+
"TARGET_ARCH_X64",
148+
]
149+
}
150+
131151
config("dart_arch_config") {
132152
defines = []
133153

runtime/bin/BUILD.gn

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ build_libdart_builtin("libdart_builtin_product_host_targeting_host") {
107107
extra_configs = [ "..:dart_product_config" ]
108108
}
109109

110+
build_libdart_builtin("libdart_builtin_product_linux_x64") {
111+
extra_configs = [
112+
"..:dart_product_config",
113+
"..:dart_linux_x64_config",
114+
]
115+
}
116+
117+
build_libdart_builtin("libdart_builtin_product_linux_arm64") {
118+
extra_configs = [
119+
"..:dart_product_config",
120+
"..:dart_linux_arm64_config",
121+
]
122+
}
123+
110124
template("build_native_assets_api") {
111125
extra_configs = []
112126
if (defined(invoker.extra_configs)) {
@@ -330,6 +344,31 @@ build_gen_snapshot("gen_snapshot_product_fuchsia") {
330344
]
331345
}
332346

347+
build_gen_snapshot("gen_snapshot_product_linux_x64") {
348+
extra_configs = [
349+
"..:dart_product_config",
350+
"..:dart_linux_x64_config",
351+
]
352+
extra_deps = [
353+
":gen_snapshot_dart_io_product_linux_x64",
354+
":libdart_builtin_product_linux_x64",
355+
"..:libdart_precompiler_product_linux_x64",
356+
"../platform:libdart_platform_precompiler_product_linux_x64",
357+
]
358+
}
359+
360+
build_gen_snapshot("gen_snapshot_product_linux_arm64") {
361+
extra_configs = [
362+
"..:dart_product_config",
363+
"..:dart_linux_arm64_config",
364+
]
365+
extra_deps = [
366+
":gen_snapshot_dart_io_product_linux_arm64",
367+
":libdart_builtin_product_linux_arm64",
368+
"..:libdart_precompiler_product_linux_arm64",
369+
"../platform:libdart_platform_precompiler_product_linux_arm64",
370+
]
371+
}
333372
build_gen_snapshot("gen_snapshot_host_targeting_host") {
334373
extra_configs = [ "..:dart_maybe_product_config" ]
335374
extra_deps = [
@@ -434,6 +473,20 @@ build_gen_snapshot_dart_io("gen_snapshot_dart_io_product_fuchsia") {
434473
]
435474
}
436475

476+
build_gen_snapshot_dart_io("gen_snapshot_dart_io_product_linux_x64") {
477+
extra_configs = [
478+
"..:dart_product_config",
479+
"..:dart_linux_x64_config",
480+
]
481+
}
482+
483+
build_gen_snapshot_dart_io("gen_snapshot_dart_io_product_linux_arm64") {
484+
extra_configs = [
485+
"..:dart_product_config",
486+
"..:dart_linux_arm64_config",
487+
]
488+
}
489+
437490
# A source set for the implementation of 'dart:io' library.
438491
template("dart_io") {
439492
extra_configs = []

runtime/configs.gni

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ _precompiler_host_targeting_host_config =
6363
_precompiler_product_host_targeting_host_config =
6464
_base_host_targeting_host_config + _precompiler_base + _product
6565

66+
_precompiler_product_linux_x64_config =
67+
[
68+
"$_dart_runtime:dart_config",
69+
"$_dart_runtime:dart_linux_x64_config",
70+
] + _product + _precompiler_base
71+
72+
_precompiler_product_linux_arm64_config =
73+
[
74+
"$_dart_runtime:dart_config",
75+
"$_dart_runtime:dart_linux_arm64_config",
76+
] + _product + _precompiler_base
77+
6678
_all_configs = [
6779
{
6880
suffix = "_jit"
@@ -148,6 +160,20 @@ _all_configs = [
148160
compiler = true
149161
is_product = false
150162
},
163+
{
164+
suffix = "_precompiler_product_linux_x64"
165+
configs = _precompiler_product_linux_x64_config
166+
snapshot = false
167+
compiler = true
168+
is_product = true
169+
},
170+
{
171+
suffix = "_precompiler_product_linux_arm64"
172+
configs = _precompiler_product_linux_arm64_config
173+
snapshot = false
174+
compiler = true
175+
is_product = true
176+
},
151177
]
152178

153179
# This template creates a target for each of the configurations listed above.

sdk/BUILD.gn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,13 @@ group("create_full_sdk") {
860860
if (dart_include_wasm_opt) {
861861
public_deps += [ ":copy_wasm_opt" ]
862862
}
863+
864+
# Do not include gen_snapshot binaries for cross-compilation into
865+
# SDK, but add them as a dependency, so that they are built.
866+
public_deps += [
867+
"../runtime/bin:gen_snapshot_product_linux_arm64",
868+
"../runtime/bin:gen_snapshot_product_linux_x64",
869+
]
863870
}
864871
}
865872

0 commit comments

Comments
 (0)