Skip to content

Commit 9f5bf75

Browse files
zandersozijiehe-google-com
authored andcommitted
Refactors RBE support (flutter#49416)
This PR refactors the RBE build and adds support for mac-hosted builds to use RBE. In particular, configurations files are downloaded from flutter-internal CIPD instead of being included in the repo. The download from CIPD is triggered by the presence of the `use_rbe` flag as a custom var in the `.gclient` file. This PR also turns on RBE for Linux and macOS builds that do not produce artifacts. flutter/buildroot#807
1 parent a57fe48 commit 9f5bf75

File tree

7 files changed

+135
-25
lines changed

7 files changed

+135
-25
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,9 @@ app.*.symbols
130130

131131
# Prebuilt binaries.
132132
/prebuilts/
133+
134+
# GN build support for protobufs vended by Fuchsia.
133135
/build/secondary/third_party/protobuf
136+
137+
# RBE support configurations and scripts vended from CIPD
138+
/build/rbe

DEPS

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ vars = {
5454
# https://chrome-infra-packages.appspot.com/p/fuchsia/third_party/goma/client
5555
'goma_version': ' git_revision:41b3bcb64014144a844153fd5588c36411fffb56',
5656

57-
'reclient_version': 'git_revision:81e819b39d4743462857cc55430d898b9fcca1af',
57+
'reclient_version': 'git_revision:f3883c2237b0eb9cc9524cb571b5ab8378f257e4',
5858

5959
'gcloud_version': 'version:2@444.0.0.chromium.3',
6060

@@ -127,6 +127,10 @@ vars = {
127127
# specified by GOMA_DIR, or installed in the default goma install location.
128128
'use_cipd_goma': False,
129129

130+
# When this is true, the Flutter Engine's configuration files and scripts for
131+
# RBE will be downloaded from CIPD. This option is only usable by Googlers.
132+
'use_rbe': False,
133+
130134
# This is not downloaded be default because it increases the
131135
# `gclient sync` time by between 1 and 3 minutes. This option is enabled
132136
# in flutter/ci/builders/mac_impeller_cmake_example.json, and is likely to
@@ -267,7 +271,7 @@ allowed_hosts = [
267271
]
268272

269273
deps = {
270-
'src': 'https://github.com/flutter/buildroot.git' + '@' + '8c274b21f1ad4f2aec0a5e0ae8f4264393045b4b',
274+
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'a43582b52d361bc3da156a8e6eab6dd947ca339d',
271275

272276
'src/flutter/third_party/rapidjson':
273277
Var('flutter_git') + '/third_party/rapidjson' + '@' + 'ef3564c5c8824989393b87df25355baf35ff544b',
@@ -844,7 +848,7 @@ deps = {
844848
'version': Var('clang_version'),
845849
}
846850
],
847-
'condition': 'host_os == "linux" and host_cpu == "x64"',
851+
'condition': 'host_os == "linux" or host_os == "mac"',
848852
'dep_type': 'cipd',
849853
},
850854

@@ -904,15 +908,48 @@ deps = {
904908
'dep_type': 'cipd',
905909
},
906910

907-
# reclient.
911+
# RBE binaries and configs.
908912
'src/buildtools/linux-x64/reclient': {
909913
'packages': [
910914
{
911915
'package': 'infra/rbe/client/${{platform}}',
912916
'version': Var('reclient_version'),
913917
}
914918
],
915-
'condition': 'host_os == "linux" and host_cpu == "x64"',
919+
'condition': 'use_rbe and host_os == "linux" and host_cpu == "x64"',
920+
'dep_type': 'cipd',
921+
},
922+
923+
'src/buildtools/mac-arm64/reclient': {
924+
'packages': [
925+
{
926+
'package': 'infra/rbe/client/${{platform}}',
927+
'version': Var('reclient_version'),
928+
}
929+
],
930+
'condition': 'use_rbe and host_os == "mac" and host_cpu == "arm64"',
931+
'dep_type': 'cipd',
932+
},
933+
934+
'src/buildtools/mac-x64/reclient': {
935+
'packages': [
936+
{
937+
'package': 'infra/rbe/client/${{platform}}',
938+
'version': Var('reclient_version'),
939+
}
940+
],
941+
'condition': 'use_rbe and host_os == "mac" and host_cpu == "x64"',
942+
'dep_type': 'cipd',
943+
},
944+
945+
'src/flutter/build/rbe': {
946+
'packages': [
947+
{
948+
'package': 'flutter_internal/rbe/reclient_cfgs',
949+
'version': 'U42C0v8jI-_YREjd8rbDEt0evvqvLWJ_NTkaiJ_Clt8C',
950+
}
951+
],
952+
'condition': 'use_rbe',
916953
'dep_type': 'cipd',
917954
},
918955

@@ -924,7 +961,18 @@ deps = {
924961
'version': Var('gcloud_version'),
925962
}
926963
],
927-
'condition': 'host_os == "linux" and host_cpu == "x64"',
964+
'condition': 'use_rbe and host_os == "linux" and host_cpu == "x64"',
965+
'dep_type': 'cipd',
966+
},
967+
968+
'src/buildtools/mac-arm64/gcloud': {
969+
'packages': [
970+
{
971+
'package': 'infra/3pp/tools/gcloud/${{platform}}',
972+
'version': Var('gcloud_version'),
973+
}
974+
],
975+
'condition': 'use_rbe and host_os == "mac" and host_cpu == "arm64"',
928976
'dep_type': 'cipd',
929977
},
930978

ci/builders/linux_android_emulator.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"kvm=1",
88
"cores=8"
99
],
10+
"gclient_variables": {
11+
"use_rbe": true
12+
},
1013
"gn": [
1114
"--android",
1215
"--android-cpu=x64",
@@ -69,6 +72,9 @@
6972
"kvm=1",
7073
"cores=8"
7174
],
75+
"gclient_variables": {
76+
"use_rbe": true
77+
},
7278
"gn": [
7379
"--android",
7480
"--android-cpu=x86",

ci/builders/linux_unopt.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"os=Linux",
77
"cores=32"
88
],
9+
"gclient_variables": {
10+
"use_rbe": true
11+
},
912
"gn": [
1013
"--runtime-mode",
1114
"debug",
@@ -84,6 +87,9 @@
8487
"os=Linux"
8588
],
8689
"dependencies": [],
90+
"gclient_variables": {
91+
"use_rbe": true
92+
},
8793
"gn": [
8894
"--android",
8995
"--embedder-for-target",
@@ -112,6 +118,9 @@
112118
"version": "last_updated:2023-02-03T15:32:01-0800"
113119
}
114120
],
121+
"gclient_variables": {
122+
"use_rbe": true
123+
},
115124
"gn": [
116125
"--android",
117126
"--unoptimized",

ci/builders/mac_unopt.json

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616
"mac_model=Macmini8,1"
1717
],
1818
"gclient_variables": {
19-
"download_android_deps": false
19+
"download_android_deps": false,
20+
"use_rbe": true
2021
},
2122
"gn": [
2223
"--runtime-mode",
2324
"debug",
2425
"--unoptimized",
2526
"--no-lto",
2627
"--prebuilt-dart-sdk",
27-
"--enable-impeller-3d"
28+
"--enable-impeller-3d",
29+
"--rbe",
30+
"--no-goma",
31+
"--xcode-symlinks"
2832
],
2933
"name": "host_debug_unopt",
3034
"ninja": {
@@ -75,14 +79,18 @@
7579
"cpu=x86"
7680
],
7781
"gclient_variables": {
78-
"download_android_deps": false
82+
"download_android_deps": false,
83+
"use_rbe": true
7984
},
8085
"gn": [
8186
"--ios",
8287
"--runtime-mode",
8388
"debug",
8489
"--simulator",
85-
"--no-lto"
90+
"--no-lto",
91+
"--rbe",
92+
"--no-goma",
93+
"--xcode-symlinks"
8694
],
8795
"name": "ios_debug_sim",
8896
"ninja": {
@@ -132,7 +140,8 @@
132140
"cpu=arm64"
133141
],
134142
"gclient_variables": {
135-
"download_android_deps": false
143+
"download_android_deps": false,
144+
"use_rbe": true
136145
},
137146
"gn": [
138147
"--runtime-mode",
@@ -142,7 +151,10 @@
142151
"--prebuilt-dart-sdk",
143152
"--force-mac-arm64",
144153
"--mac-cpu",
145-
"arm64"
154+
"arm64",
155+
"--rbe",
156+
"--no-goma",
157+
"--xcode-symlinks"
146158
],
147159
"name": "host_debug_unopt_arm64",
148160
"ninja": {
@@ -181,7 +193,8 @@
181193
"cpu=arm64"
182194
],
183195
"gclient_variables": {
184-
"download_android_deps": false
196+
"download_android_deps": false,
197+
"use_rbe": true
185198
},
186199
"gn": [
187200
"--ios",
@@ -191,7 +204,10 @@
191204
"--no-lto",
192205
"--force-mac-arm64",
193206
"--simulator-cpu",
194-
"arm64"
207+
"arm64",
208+
"--rbe",
209+
"--no-goma",
210+
"--xcode-symlinks"
195211
],
196212
"name": "ios_debug_sim_arm64",
197213
"ninja": {
@@ -251,7 +267,8 @@
251267
"cpu=arm64"
252268
],
253269
"gclient_variables": {
254-
"download_android_deps": false
270+
"download_android_deps": false,
271+
"use_rbe": true
255272
},
256273
"gn": [
257274
"--ios",
@@ -262,7 +279,10 @@
262279
"--force-mac-arm64",
263280
"--simulator-cpu",
264281
"arm64",
265-
"--darwin-extension-safe"
282+
"--darwin-extension-safe",
283+
"--rbe",
284+
"--no-goma",
285+
"--xcode-symlinks"
266286
],
267287
"name": "ios_debug_sim_arm64_extension_safe",
268288
"ninja": {

ci/builders/standalone/linux_benchmarks.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"os=Linux"
55
],
66
"gclient_variables": {
7-
"download_android_deps": false
7+
"download_android_deps": false,
8+
"use_rbe": true
89
},
910
"gn": [
1011
"--runtime-mode",

tools/gn

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ def buildtools_dir():
205205
host_cpu = get_host_cpu()
206206
if host_os == 'win':
207207
host_os = 'windows'
208-
if host_os == 'mac' and host_cpu == 'arm64':
209-
host_cpu = 'x64'
210208
return '%s-%s' % (host_os, host_cpu)
211209

212210

@@ -217,9 +215,10 @@ def setup_rbe(args):
217215
if not args.rbe:
218216
return rbe_gn_args
219217

220-
if get_host_os() not in ['linux']:
218+
if get_host_os() not in ['linux', 'mac']:
221219
print(
222-
'The --rbe flag has no effect. RBE is currently only supported on Linux.'
220+
'The --rbe flag has no effect. RBE is currently only supported on '
221+
'macOS and Linux.'
223222
)
224223
return rbe_gn_args
225224

@@ -239,7 +238,9 @@ def setup_rbe(args):
239238
)
240239
bootstrap_path = os.path.join(cipd_reclient_dir, 'bootstrap')
241240
reproxy_path = os.path.join(cipd_reclient_dir, 'reproxy')
242-
rbe_cfg_path = os.path.join(SRC_ROOT, 'build', 'rbe.cfg')
241+
rbe_cfg_path = os.path.join(
242+
SRC_ROOT, 'flutter', 'build', 'rbe', 'reclient.cfg'
243+
)
243244
bootstrap_cmd = [
244245
bootstrap_path,
245246
'--re_proxy=' + reproxy_path,
@@ -260,8 +261,20 @@ def setup_rbe(args):
260261
rbe_gn_args['rbe_dial_timeout'] = args.rbe_dial_timeout
261262
if args.rbe_platform:
262263
rbe_gn_args['rbe_platform'] = args.rbe_platform
263-
if args.rbe_dir:
264-
rbe_gn_args['rbe_dir'] = args.rbe_dir
264+
265+
rbe_gn_args['rbe_dir'] = os.path.join(
266+
SRC_ROOT, 'buildtools', buildtools_dir(), 'reclient'
267+
)
268+
269+
rbe_gn_args['rbe_cfg'] = os.path.join(
270+
SRC_ROOT, 'flutter', 'build', 'rbe',
271+
'rewrapper-' + buildtools_dir() + '.cfg'
272+
)
273+
274+
if sys.platform == 'darwin':
275+
if (not running_on_luci or args.xcode_symlinks or
276+
os.getenv('FLUTTER_GOMA_CREATE_XCODE_SYMLINKS', '0') == '1'):
277+
rbe_gn_args['create_xcode_symlinks'] = True
265278

266279
return rbe_gn_args
267280

@@ -285,8 +298,16 @@ def setup_goma(args):
285298
# care of starting and stopping the compiler proxy.
286299
running_on_luci = os.environ.get('LUCI_CONTEXT') is not None
287300

301+
# The GOMA client has no arm64 binary, so run the x64 binary through
302+
# Rosetta.
303+
buildtools_platform = buildtools_dir()
304+
if buildtools_platform == 'mac-arm64':
305+
buildtools_platform = 'mac-x64'
306+
288307
# Prefer the goma fetched by gclient if it exists.
289-
cipd_goma_dir = os.path.join(SRC_ROOT, 'buildtools', buildtools_dir(), 'goma')
308+
cipd_goma_dir = os.path.join(
309+
SRC_ROOT, 'buildtools', buildtools_platform, 'goma'
310+
)
290311

291312
# Next, if GOMA_DIR is set, use that install.
292313
goma_dir = os.environ.get('GOMA_DIR')

0 commit comments

Comments
 (0)