Support cross-compiling GN for other targets

This change extends the recipe used by builders with support for
cross-compiling GN to different platforms beyond the host one, and
sets up cross compilation for Linux as an example.

Change-Id: I0d9aa1a104b14842c875d1a8d9082b6949e47e14
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/3760
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Petr Hosek <phosek@google.com>
diff --git a/infra/README.recipes.md b/infra/README.recipes.md
index 128ecb7..869f775 100644
--- a/infra/README.recipes.md
+++ b/infra/README.recipes.md
@@ -4,11 +4,13 @@
 
 **[Recipe Modules](#Recipe-Modules)**
   * [macos_sdk](#recipe_modules-macos_sdk) &mdash; The `macos_sdk` module provides safe functions to access a semi-hermetic XCode installation.
+  * [target](#recipe_modules-target)
   * [windows_sdk](#recipe_modules-windows_sdk)
 
 **[Recipes](#Recipes)**
   * [gn](#recipes-gn) &mdash; Recipe for building GN.
   * [macos_sdk:examples/full](#recipes-macos_sdk_examples_full)
+  * [target:examples/full](#recipes-target_examples_full)
   * [windows_sdk:examples/full](#recipes-windows_sdk_examples_full)
 ## Recipe Modules
 
@@ -58,6 +60,13 @@
 
 Raises:
     StepFailure or InfraFailure.
+### *recipe_modules* / [target](/infra/recipe_modules/target)
+
+[DEPS](/infra/recipe_modules/target/__init__.py#5): [recipe\_engine/platform][recipe_engine/recipe_modules/platform]
+
+#### **class [TargetApi](/infra/recipe_modules/target/api.py#82)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
+
+&emsp; **@property**<br>&mdash; **def [host](/infra/recipe_modules/target/api.py#87)(self):**
 ### *recipe_modules* / [windows\_sdk](/infra/recipe_modules/windows_sdk)
 
 [DEPS](/infra/recipe_modules/windows_sdk/__init__.py#5): [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/step][recipe_engine/recipe_modules/step]
@@ -78,16 +87,21 @@
 
 ### *recipes* / [gn](/infra/recipes/gn.py)
 
-[DEPS](/infra/recipes/gn.py#8): [macos\_sdk](#recipe_modules-macos_sdk), [windows\_sdk](#recipe_modules-windows_sdk), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
+[DEPS](/infra/recipes/gn.py#8): [macos\_sdk](#recipe_modules-macos_sdk), [target](#recipe_modules-target), [windows\_sdk](#recipe_modules-windows_sdk), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
 
 Recipe for building GN.
 
-&mdash; **def [RunSteps](/infra/recipes/gn.py#29)(api, repository):**
+&mdash; **def [RunSteps](/infra/recipes/gn.py#30)(api, repository):**
 ### *recipes* / [macos\_sdk:examples/full](/infra/recipe_modules/macos_sdk/examples/full.py)
 
 [DEPS](/infra/recipe_modules/macos_sdk/examples/full.py#5): [macos\_sdk](#recipe_modules-macos_sdk), [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
 
 &mdash; **def [RunSteps](/infra/recipe_modules/macos_sdk/examples/full.py#13)(api):**
+### *recipes* / [target:examples/full](/infra/recipe_modules/target/examples/full.py)
+
+[DEPS](/infra/recipe_modules/target/examples/full.py#5): [target](#recipe_modules-target), [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
+
+&mdash; **def [RunSteps](/infra/recipe_modules/target/examples/full.py#13)(api):**
 ### *recipes* / [windows\_sdk:examples/full](/infra/recipe_modules/windows_sdk/examples/full.py)
 
 [DEPS](/infra/recipe_modules/windows_sdk/examples/full.py#5): [windows\_sdk](#recipe_modules-windows_sdk), [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
diff --git a/infra/recipe_modules/target/__init__.py b/infra/recipe_modules/target/__init__.py
new file mode 100644
index 0000000..1239fd2
--- /dev/null
+++ b/infra/recipe_modules/target/__init__.py
@@ -0,0 +1,7 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+DEPS = [
+    'recipe_engine/platform',
+]
diff --git a/infra/recipe_modules/target/api.py b/infra/recipe_modules/target/api.py
new file mode 100644
index 0000000..f128707
--- /dev/null
+++ b/infra/recipe_modules/target/api.py
@@ -0,0 +1,98 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from recipe_engine import recipe_api
+
+
+PLATFORM_TO_TRIPLE = {
+  'fuchsia-amd64': 'x86_64-fuchsia',
+  'fuchsia-arm64': 'aarch64-fuchsia',
+  'linux-amd64': 'x86_64-linux-gnu',
+  'linux-arm64': 'aarch64-linux-gnu',
+  'mac-amd64': 'x86_64-apple-darwin',
+  'mac-arm64': 'aarch64-apple-darwin',
+}
+PLATFORMS = PLATFORM_TO_TRIPLE.keys()
+
+
+class Target(object):
+
+  def __init__(self, api, os, arch):
+    self.m = api
+    self._os = os
+    self._arch = arch
+
+  @property
+  def is_win(self):
+    """Returns True iff the target platform is Windows."""
+    return self.os == 'windows'
+
+  @property
+  def is_mac(self):
+    """Returns True iff the target platform is macOS."""
+    return self.os == 'mac'
+
+  @property
+  def is_linux(self):
+    """Returns True iff the target platform is Linux."""
+    return self.os == 'linux'
+
+  @property
+  def is_host(self):
+    """Returns True iff the target platform is host."""
+    return self == self.m.host
+
+  @property
+  def os(self):
+    """Returns the target os name which will be in:
+      * windows
+      * mac
+      * linux
+    """
+    return self._os
+
+  @property
+  def arch(self):
+    """Returns the current CPU architecture."""
+    return self._arch
+
+  @property
+  def platform(self):
+    """Returns the target platform in the <os>-<arch> format."""
+    return '%s-%s' % (self.os, self.arch)
+
+  @property
+  def triple(self):
+    """Returns the target triple."""
+    return PLATFORM_TO_TRIPLE[self.platform]
+
+  def __str__(self):
+    return self.platform
+
+  def __eq__(self, other):
+    if isinstance(other, Target):
+      return self._os == other._os and self._arch == other._arch
+    return False
+
+  def __ne__(self, other):
+    return not self.__eq__(other)
+
+
+class TargetApi(recipe_api.RecipeApi):
+
+  def __call__(self, platform):
+    return Target(self, *platform.split('-', 2))
+
+  @property
+  def host(self):
+    return Target(self, self.m.platform.name.replace('win', 'windows'), {
+        'intel': {
+            32: '386',
+            64: 'amd64',
+        },
+        'arm': {
+            32: 'armv6',
+            64: 'arm64',
+        },
+    }[self.m.platform.arch][self.m.platform.bits])
diff --git a/infra/recipe_modules/target/examples/full.expected/linux.json b/infra/recipe_modules/target/examples/full.expected/linux.json
new file mode 100644
index 0000000..947f5d2
--- /dev/null
+++ b/infra/recipe_modules/target/examples/full.expected/linux.json
@@ -0,0 +1,22 @@
+[
+  {
+    "cmd": [],
+    "name": "platform things",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@name@fuchsia@@@",
+      "@@@STEP_LOG_END@name@@@",
+      "@@@STEP_LOG_LINE@arch@arm64@@@",
+      "@@@STEP_LOG_END@arch@@@",
+      "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@",
+      "@@@STEP_LOG_END@platform@@@",
+      "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@",
+      "@@@STEP_LOG_END@triple@@@",
+      "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@",
+      "@@@STEP_LOG_END@string@@@"
+    ]
+  },
+  {
+    "jsonResult": null,
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/infra/recipe_modules/target/examples/full.expected/mac.json b/infra/recipe_modules/target/examples/full.expected/mac.json
new file mode 100644
index 0000000..947f5d2
--- /dev/null
+++ b/infra/recipe_modules/target/examples/full.expected/mac.json
@@ -0,0 +1,22 @@
+[
+  {
+    "cmd": [],
+    "name": "platform things",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@name@fuchsia@@@",
+      "@@@STEP_LOG_END@name@@@",
+      "@@@STEP_LOG_LINE@arch@arm64@@@",
+      "@@@STEP_LOG_END@arch@@@",
+      "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@",
+      "@@@STEP_LOG_END@platform@@@",
+      "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@",
+      "@@@STEP_LOG_END@triple@@@",
+      "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@",
+      "@@@STEP_LOG_END@string@@@"
+    ]
+  },
+  {
+    "jsonResult": null,
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/infra/recipe_modules/target/examples/full.expected/win.json b/infra/recipe_modules/target/examples/full.expected/win.json
new file mode 100644
index 0000000..947f5d2
--- /dev/null
+++ b/infra/recipe_modules/target/examples/full.expected/win.json
@@ -0,0 +1,22 @@
+[
+  {
+    "cmd": [],
+    "name": "platform things",
+    "~followup_annotations": [
+      "@@@STEP_LOG_LINE@name@fuchsia@@@",
+      "@@@STEP_LOG_END@name@@@",
+      "@@@STEP_LOG_LINE@arch@arm64@@@",
+      "@@@STEP_LOG_END@arch@@@",
+      "@@@STEP_LOG_LINE@platform@fuchsia-arm64@@@",
+      "@@@STEP_LOG_END@platform@@@",
+      "@@@STEP_LOG_LINE@triple@aarch64-fuchsia@@@",
+      "@@@STEP_LOG_END@triple@@@",
+      "@@@STEP_LOG_LINE@string@fuchsia-arm64@@@",
+      "@@@STEP_LOG_END@string@@@"
+    ]
+  },
+  {
+    "jsonResult": null,
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/infra/recipe_modules/target/examples/full.py b/infra/recipe_modules/target/examples/full.py
new file mode 100644
index 0000000..c47c86a
--- /dev/null
+++ b/infra/recipe_modules/target/examples/full.py
@@ -0,0 +1,31 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+DEPS = [
+    'target',
+    'recipe_engine/platform',
+    'recipe_engine/properties',
+    'recipe_engine/step',
+]
+
+
+def RunSteps(api):
+  target = api.target('fuchsia-arm64')
+  assert not target.is_win
+  assert not target.is_linux
+  assert not target.is_mac
+  assert api.target.host.is_host
+  assert target != api.target.host
+  assert target != 'foo'
+  step_result = api.step('platform things', cmd=None)
+  step_result.presentation.logs['name'] = [target.os]
+  step_result.presentation.logs['arch'] = [target.arch]
+  step_result.presentation.logs['platform'] = [target.platform]
+  step_result.presentation.logs['triple'] = [target.triple]
+  step_result.presentation.logs['string'] = [str(target)]
+
+
+def GenTests(api):
+  for platform in ('linux', 'mac', 'win'):
+    yield api.test(platform) + api.platform.name(platform)
diff --git a/infra/recipes/gn.expected/ci_linux.json b/infra/recipes/gn.expected/ci_linux.json
index 620f455..4a301f2 100644
--- a/infra/recipes/gn.expected/ci_linux.json
+++ b/infra/recipes/gn.expected/ci_linux.json
@@ -45,12 +45,26 @@
   },
   {
     "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "cipd",
       "ensure",
       "-root",
       "[START_DIR]/cipd",
       "-ensure-file",
-      "infra/ninja/${platform} version:1.8.2\nfuchsia/clang/${platform} git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a\n@Subdir sysroot\nfuchsia/sysroot/${platform} git_revision:a28dfa20af063e5ca00634024c85732e20220419",
+      "infra/ninja/${platform} version:1.8.2\nfuchsia/third_party/clang/${platform} integration\n@Subdir sysroot\nfuchsia/third_party/sysroot/linux git_revision:c912d089c3d46d8982fdef76a50514cca79b6132",
       "-json-output",
       "/path/to/tmp/json"
     ],
@@ -61,8 +75,8 @@
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:b92\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/clang/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-integration-----\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/clang/resolved-platform\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }, @@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:1.8.2---\", @@@",
@@ -71,8 +85,8 @@
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
       "@@@STEP_LOG_LINE@json.output@    \"sysroot\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:a28\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/sysroot/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:c91\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/sysroot/linux\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }@@@",
       "@@@STEP_LOG_LINE@json.output@    ]@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
@@ -86,7 +100,7 @@
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -102,11 +116,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.generate",
+    "name": "debug.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -121,11 +135,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.ninja",
+    "name": "debug.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -134,9 +148,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "debug.test",
+    "name": "debug.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -145,7 +159,7 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -162,11 +176,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.generate",
+    "name": "release.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -181,11 +195,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.ninja",
+    "name": "release.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -194,9 +208,16 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "release.test",
+    "name": "release.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-amd64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -204,7 +225,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/${platform}\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -212,12 +233,92 @@
       "-json-output",
       "/path/to/tmp/json"
     ],
-    "name": "build gn/gn/${platform}",
+    "name": "release.linux-amd64.upload.build gn/gn/linux-amd64",
     "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/linux-amd64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-arm64",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "[START_DIR]/gn/build/gen.py",
+      "--use-lto",
+      "--use-icf"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "env": {
+      "AR": "[START_DIR]/cipd/bin/llvm-ar",
+      "CC": "[START_DIR]/cipd/bin/clang",
+      "CFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
+      "CXX": "[START_DIR]/cipd/bin/clang++",
+      "LDFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
+    },
+    "name": "release.linux-arm64.generate",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd/ninja",
+      "-C",
+      "[START_DIR]/gn/out"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "env": {
+      "AR": "[START_DIR]/cipd/bin/llvm-ar",
+      "CC": "[START_DIR]/cipd/bin/clang",
+      "CFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
+      "CXX": "[START_DIR]/cipd/bin/clang++",
+      "LDFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
+    },
+    "name": "release.linux-arm64.build",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-arm64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "pkg-build",
+      "-pkg-def",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "-out",
+      "[CLEANUP]/gn.cipd",
+      "-hash-algo",
+      "sha256",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "release.linux-arm64.upload.build gn/gn/linux-arm64",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/linux-arm64\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@}@@@",
       "@@@STEP_LOG_END@json.output@@@"
diff --git a/infra/recipes/gn.expected/ci_mac.json b/infra/recipes/gn.expected/ci_mac.json
index 6ff9fe9..707406d 100644
--- a/infra/recipes/gn.expected/ci_mac.json
+++ b/infra/recipes/gn.expected/ci_mac.json
@@ -45,12 +45,26 @@
   },
   {
     "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "cipd",
       "ensure",
       "-root",
       "[START_DIR]/cipd",
       "-ensure-file",
-      "infra/ninja/${platform} version:1.8.2\nfuchsia/clang/${platform} git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a",
+      "infra/ninja/${platform} version:1.8.2\nfuchsia/third_party/clang/${platform} integration",
       "-json-output",
       "/path/to/tmp/json"
     ],
@@ -61,8 +75,8 @@
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:b92\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/clang/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-integration-----\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/clang/resolved-platform\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }, @@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:1.8.2---\", @@@",
@@ -126,30 +140,31 @@
     "name": "select XCode"
   },
   {
-    "cmd": [
-      "xcrun",
-      "--show-sdk-path"
-    ],
-    "name": "xcrun",
-    "stdout": "/path/to/tmp/",
-    "~followup_annotations": [
-      "@@@STEP_LOG_LINE@raw_io.output[sdk-path]@/some/xcode/path@@@",
-      "@@@STEP_LOG_END@raw_io.output[sdk-path]@@@"
-    ]
-  },
-  {
     "cmd": [],
     "name": "debug"
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.mac-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
   },
   {
     "cmd": [
+      "xcrun",
+      "--show-sdk-path"
+    ],
+    "name": "debug.mac-amd64.xcrun",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@raw_io.output[sdk-path]@/some/xcode/path@@@",
+      "@@@STEP_LOG_END@raw_io.output[sdk-path]@@@"
+    ]
+  },
+  {
+    "cmd": [
       "python",
       "-u",
       "[START_DIR]/gn/build/gen.py",
@@ -159,11 +174,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "debug.build.generate",
+    "name": "debug.mac-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -178,11 +193,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "debug.build.ninja",
+    "name": "debug.mac-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -191,9 +206,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "debug.test",
+    "name": "debug.mac-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -202,13 +217,26 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.mac-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
   },
   {
     "cmd": [
+      "xcrun",
+      "--show-sdk-path"
+    ],
+    "name": "release.mac-amd64.xcrun",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@raw_io.output[sdk-path]@/some/xcode/path@@@",
+      "@@@STEP_LOG_END@raw_io.output[sdk-path]@@@"
+    ]
+  },
+  {
+    "cmd": [
       "python",
       "-u",
       "[START_DIR]/gn/build/gen.py",
@@ -219,11 +247,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "release.build.generate",
+    "name": "release.mac-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -238,11 +266,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "release.build.ninja",
+    "name": "release.mac-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -251,9 +279,41 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "release.test",
+    "name": "release.mac-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.mac-amd64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "pkg-build",
+      "-pkg-def",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/mac-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "-out",
+      "[CLEANUP]/gn.cipd",
+      "-hash-algo",
+      "sha256",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "release.mac-amd64.upload.build gn/gn/mac-amd64",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/mac-amd64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
     ]
   },
   {
@@ -266,30 +326,6 @@
     "name": "reset XCode"
   },
   {
-    "cmd": [
-      "cipd",
-      "pkg-build",
-      "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/${platform}\", \"root\": \"[START_DIR]/gn/out\"}",
-      "-out",
-      "[CLEANUP]/gn.cipd",
-      "-hash-algo",
-      "sha256",
-      "-json-output",
-      "/path/to/tmp/json"
-    ],
-    "name": "build gn/gn/${platform}",
-    "~followup_annotations": [
-      "@@@STEP_LOG_LINE@json.output@{@@@",
-      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
-      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/resolved-platform\"@@@",
-      "@@@STEP_LOG_LINE@json.output@  }@@@",
-      "@@@STEP_LOG_LINE@json.output@}@@@",
-      "@@@STEP_LOG_END@json.output@@@"
-    ]
-  },
-  {
     "jsonResult": null,
     "name": "$result"
   }
diff --git a/infra/recipes/gn.expected/ci_win.json b/infra/recipes/gn.expected/ci_win.json
index 305acae..88e8edb 100644
--- a/infra/recipes/gn.expected/ci_win.json
+++ b/infra/recipes/gn.expected/ci_win.json
@@ -45,6 +45,20 @@
   },
   {
     "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]\\gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "cipd.bat",
       "ensure",
       "-root",
@@ -135,7 +149,7 @@
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.windows-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -156,7 +170,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "debug.build.generate",
+    "name": "debug.windows-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -176,7 +190,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "debug.build.ninja",
+    "name": "debug.windows-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -193,9 +207,9 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "debug.test",
+    "name": "debug.windows-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -204,7 +218,7 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.windows-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -226,7 +240,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "release.build.generate",
+    "name": "release.windows-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -246,7 +260,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "release.build.ninja",
+    "name": "release.windows-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -263,9 +277,49 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "release.test",
+    "name": "release.windows-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.windows-amd64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd.bat",
+      "pkg-build",
+      "-pkg-def",
+      "{\"data\": [{\"file\": \"gn.exe\"}, {\"version_file\": \".versions/gn.exe.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/windows-amd64\", \"root\": \"[START_DIR]\\\\gn\\\\out\"}",
+      "-out",
+      "[CLEANUP]\\gn.cipd",
+      "-hash-algo",
+      "sha256",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "env": {
+      "VSINSTALLDIR": "[CACHE]\\windows_sdk"
+    },
+    "env_prefixes": {
+      "PATH": [
+        "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
+      ]
+    },
+    "name": "release.windows-amd64.upload.build gn/gn/windows-amd64",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/windows-amd64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
     ]
   },
   {
@@ -279,30 +333,6 @@
     "name": "taskkill mspdbsrv"
   },
   {
-    "cmd": [
-      "cipd.bat",
-      "pkg-build",
-      "-pkg-def",
-      "{\"data\": [{\"file\": \"gn.exe\"}, {\"version_file\": \".versions/gn.exe.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/${platform}\", \"root\": \"[START_DIR]\\\\gn\\\\out\"}",
-      "-out",
-      "[CLEANUP]\\gn.cipd",
-      "-hash-algo",
-      "sha256",
-      "-json-output",
-      "/path/to/tmp/json"
-    ],
-    "name": "build gn/gn/${platform}",
-    "~followup_annotations": [
-      "@@@STEP_LOG_LINE@json.output@{@@@",
-      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
-      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/resolved-platform\"@@@",
-      "@@@STEP_LOG_LINE@json.output@  }@@@",
-      "@@@STEP_LOG_LINE@json.output@}@@@",
-      "@@@STEP_LOG_END@json.output@@@"
-    ]
-  },
-  {
     "jsonResult": null,
     "name": "$result"
   }
diff --git a/infra/recipes/gn.expected/cipd_exists.json b/infra/recipes/gn.expected/cipd_exists.json
index 337f548..3bc2163 100644
--- a/infra/recipes/gn.expected/cipd_exists.json
+++ b/infra/recipes/gn.expected/cipd_exists.json
@@ -45,12 +45,26 @@
   },
   {
     "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "cipd",
       "ensure",
       "-root",
       "[START_DIR]/cipd",
       "-ensure-file",
-      "infra/ninja/${platform} version:1.8.2\nfuchsia/clang/${platform} git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a\n@Subdir sysroot\nfuchsia/sysroot/${platform} git_revision:a28dfa20af063e5ca00634024c85732e20220419",
+      "infra/ninja/${platform} version:1.8.2\nfuchsia/third_party/clang/${platform} integration\n@Subdir sysroot\nfuchsia/third_party/sysroot/linux git_revision:c912d089c3d46d8982fdef76a50514cca79b6132",
       "-json-output",
       "/path/to/tmp/json"
     ],
@@ -61,8 +75,8 @@
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:b92\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/clang/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-integration-----\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/clang/resolved-platform\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }, @@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:1.8.2---\", @@@",
@@ -71,8 +85,8 @@
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
       "@@@STEP_LOG_LINE@json.output@    \"sysroot\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:a28\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/sysroot/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:c91\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/sysroot/linux\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }@@@",
       "@@@STEP_LOG_LINE@json.output@    ]@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
@@ -86,7 +100,7 @@
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -102,11 +116,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.generate",
+    "name": "debug.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -121,11 +135,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.ninja",
+    "name": "debug.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -134,9 +148,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "debug.test",
+    "name": "debug.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -145,7 +159,7 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -162,11 +176,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.generate",
+    "name": "release.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -181,11 +195,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.ninja",
+    "name": "release.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -194,9 +208,16 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "release.test",
+    "name": "release.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-amd64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -204,7 +225,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/${platform}\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -212,12 +233,13 @@
       "-json-output",
       "/path/to/tmp/json"
     ],
-    "name": "build gn/gn/${platform}",
+    "name": "release.linux-amd64.upload.build gn/gn/linux-amd64",
     "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/linux-amd64\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@}@@@",
       "@@@STEP_LOG_END@json.output@@@"
@@ -225,26 +247,17 @@
   },
   {
     "cmd": [
-      "git",
-      "rev-parse",
-      "HEAD"
-    ],
-    "cwd": "[START_DIR]/gn",
-    "name": "rev-parse",
-    "stdout": "/path/to/tmp/"
-  },
-  {
-    "cmd": [
       "cipd",
       "search",
-      "gn/gn/${platform}",
+      "gn/gn/linux-amd64",
       "-tag",
       "git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
       "-json-output",
       "/path/to/tmp/json"
     ],
-    "name": "cipd search gn/gn/${platform} git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+    "name": "release.linux-amd64.upload.cipd search gn/gn/linux-amd64 git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
     "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
       "@@@STEP_LOG_LINE@json.output@  \"result\": [@@@",
       "@@@STEP_LOG_LINE@json.output@    {@@@",
@@ -258,7 +271,10 @@
   },
   {
     "cmd": [],
-    "name": "Package is up-to-date"
+    "name": "release.linux-amd64.upload.Package is up-to-date",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
   },
   {
     "jsonResult": null,
diff --git a/infra/recipes/gn.expected/cipd_register.json b/infra/recipes/gn.expected/cipd_register.json
index ce6a221..2e09f95 100644
--- a/infra/recipes/gn.expected/cipd_register.json
+++ b/infra/recipes/gn.expected/cipd_register.json
@@ -45,12 +45,26 @@
   },
   {
     "cmd": [
+      "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
       "cipd",
       "ensure",
       "-root",
       "[START_DIR]/cipd",
       "-ensure-file",
-      "infra/ninja/${platform} version:1.8.2\nfuchsia/clang/${platform} git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a\n@Subdir sysroot\nfuchsia/sysroot/${platform} git_revision:a28dfa20af063e5ca00634024c85732e20220419",
+      "infra/ninja/${platform} version:1.8.2\nfuchsia/third_party/clang/${platform} integration\n@Subdir sysroot\nfuchsia/third_party/sysroot/linux git_revision:c912d089c3d46d8982fdef76a50514cca79b6132",
       "-json-output",
       "/path/to/tmp/json"
     ],
@@ -61,8 +75,8 @@
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:b92\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/clang/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-integration-----\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/clang/resolved-platform\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }, @@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:1.8.2---\", @@@",
@@ -71,8 +85,8 @@
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
       "@@@STEP_LOG_LINE@json.output@    \"sysroot\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:a28\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/sysroot/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:c91\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/sysroot/linux\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }@@@",
       "@@@STEP_LOG_LINE@json.output@    ]@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
@@ -86,7 +100,7 @@
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -102,11 +116,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.generate",
+    "name": "debug.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -121,11 +135,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.ninja",
+    "name": "debug.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -134,9 +148,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "debug.test",
+    "name": "debug.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -145,7 +159,7 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -162,11 +176,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.generate",
+    "name": "release.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -181,11 +195,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.ninja",
+    "name": "release.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -194,9 +208,16 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "release.test",
+    "name": "release.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-amd64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -204,7 +225,7 @@
       "cipd",
       "pkg-build",
       "-pkg-def",
-      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/${platform}\", \"root\": \"[START_DIR]/gn/out\"}",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-amd64\", \"root\": \"[START_DIR]/gn/out\"}",
       "-out",
       "[CLEANUP]/gn.cipd",
       "-hash-algo",
@@ -212,12 +233,13 @@
       "-json-output",
       "/path/to/tmp/json"
     ],
-    "name": "build gn/gn/${platform}",
+    "name": "release.linux-amd64.upload.build gn/gn/linux-amd64",
     "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/linux-amd64\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@}@@@",
       "@@@STEP_LOG_END@json.output@@@"
@@ -225,26 +247,17 @@
   },
   {
     "cmd": [
-      "git",
-      "rev-parse",
-      "HEAD"
-    ],
-    "cwd": "[START_DIR]/gn",
-    "name": "rev-parse",
-    "stdout": "/path/to/tmp/"
-  },
-  {
-    "cmd": [
       "cipd",
       "search",
-      "gn/gn/${platform}",
+      "gn/gn/linux-amd64",
       "-tag",
       "git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
       "-json-output",
       "/path/to/tmp/json"
     ],
-    "name": "cipd search gn/gn/${platform} git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+    "name": "release.linux-amd64.upload.cipd search gn/gn/linux-amd64 git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
     "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
       "@@@STEP_LOG_LINE@json.output@  \"result\": []@@@",
       "@@@STEP_LOG_LINE@json.output@}@@@",
@@ -265,18 +278,129 @@
       "-json-output",
       "/path/to/tmp/json"
     ],
-    "name": "register gn/gn/${platform}",
+    "name": "release.linux-amd64.upload.register gn/gn/linux-amd64",
     "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
-      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/linux-amd64\"@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
       "@@@STEP_LOG_LINE@json.output@}@@@",
       "@@@STEP_LOG_END@json.output@@@"
     ]
   },
   {
+    "cmd": [],
+    "name": "release.linux-arm64",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "[START_DIR]/gn/build/gen.py",
+      "--use-lto",
+      "--use-icf"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "env": {
+      "AR": "[START_DIR]/cipd/bin/llvm-ar",
+      "CC": "[START_DIR]/cipd/bin/clang",
+      "CFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
+      "CXX": "[START_DIR]/cipd/bin/clang++",
+      "LDFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
+    },
+    "name": "release.linux-arm64.generate",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd/ninja",
+      "-C",
+      "[START_DIR]/gn/out"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "env": {
+      "AR": "[START_DIR]/cipd/bin/llvm-ar",
+      "CC": "[START_DIR]/cipd/bin/clang",
+      "CFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
+      "CXX": "[START_DIR]/cipd/bin/clang++",
+      "LDFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
+    },
+    "name": "release.linux-arm64.build",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-arm64.upload",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "pkg-build",
+      "-pkg-def",
+      "{\"data\": [{\"file\": \"gn\"}, {\"version_file\": \".versions/gn.cipd_version\"}], \"install_mode\": \"copy\", \"package\": \"gn/gn/linux-arm64\", \"root\": \"[START_DIR]/gn/out\"}",
+      "-out",
+      "[CLEANUP]/gn.cipd",
+      "-hash-algo",
+      "sha256",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "release.linux-arm64.upload.build gn/gn/linux-arm64",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+      "@@@STEP_LOG_LINE@json.output@    \"package\": \"gn/gn/linux-arm64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "search",
+      "gn/gn/linux-arm64",
+      "-tag",
+      "git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "name": "release.linux-arm64.upload.cipd search gn/gn/linux-arm64 git_revision:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@    {@@@",
+      "@@@STEP_LOG_LINE@json.output@      \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+      "@@@STEP_LOG_LINE@json.output@      \"package\": \"gn/gn/linux-arm64\"@@@",
+      "@@@STEP_LOG_LINE@json.output@    }@@@",
+      "@@@STEP_LOG_LINE@json.output@  ]@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-arm64.upload.Package is up-to-date",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
+  },
+  {
     "jsonResult": null,
     "name": "$result"
   }
diff --git a/infra/recipes/gn.expected/cq_linux.json b/infra/recipes/gn.expected/cq_linux.json
index 329ac6e..c51eb29 100644
--- a/infra/recipes/gn.expected/cq_linux.json
+++ b/infra/recipes/gn.expected/cq_linux.json
@@ -46,6 +46,20 @@
   {
     "cmd": [
       "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "fetch",
       "https://gn.googlesource.com/gn",
       "refs/changes/56/123456/7"
@@ -77,7 +91,7 @@
       "-root",
       "[START_DIR]/cipd",
       "-ensure-file",
-      "infra/ninja/${platform} version:1.8.2\nfuchsia/clang/${platform} git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a\n@Subdir sysroot\nfuchsia/sysroot/${platform} git_revision:a28dfa20af063e5ca00634024c85732e20220419",
+      "infra/ninja/${platform} version:1.8.2\nfuchsia/third_party/clang/${platform} integration\n@Subdir sysroot\nfuchsia/third_party/sysroot/linux git_revision:c912d089c3d46d8982fdef76a50514cca79b6132",
       "-json-output",
       "/path/to/tmp/json"
     ],
@@ -88,8 +102,8 @@
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:b92\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/clang/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-integration-----\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/clang/resolved-platform\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }, @@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:1.8.2---\", @@@",
@@ -98,8 +112,8 @@
       "@@@STEP_LOG_LINE@json.output@    ], @@@",
       "@@@STEP_LOG_LINE@json.output@    \"sysroot\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:a28\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/sysroot/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:c91\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/sysroot/linux\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }@@@",
       "@@@STEP_LOG_LINE@json.output@    ]@@@",
       "@@@STEP_LOG_LINE@json.output@  }@@@",
@@ -113,7 +127,7 @@
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -129,11 +143,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.generate",
+    "name": "debug.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -148,11 +162,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "debug.build.ninja",
+    "name": "debug.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -161,9 +175,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "debug.test",
+    "name": "debug.linux-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -172,7 +186,7 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.linux-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -189,11 +203,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.generate",
+    "name": "release.linux-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -208,11 +222,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=[START_DIR]/cipd/sysroot",
+      "CFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=[START_DIR]/cipd/sysroot"
+      "LDFLAGS": "--target=x86_64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
     },
-    "name": "release.build.ninja",
+    "name": "release.linux-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -221,12 +235,59 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "release.test",
+    "name": "release.linux-amd64.test",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "release.linux-arm64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
   },
   {
+    "cmd": [
+      "python",
+      "-u",
+      "[START_DIR]/gn/build/gen.py",
+      "--use-lto",
+      "--use-icf"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "env": {
+      "AR": "[START_DIR]/cipd/bin/llvm-ar",
+      "CC": "[START_DIR]/cipd/bin/clang",
+      "CFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
+      "CXX": "[START_DIR]/cipd/bin/clang++",
+      "LDFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
+    },
+    "name": "release.linux-arm64.generate",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd/ninja",
+      "-C",
+      "[START_DIR]/gn/out"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "env": {
+      "AR": "[START_DIR]/cipd/bin/llvm-ar",
+      "CC": "[START_DIR]/cipd/bin/clang",
+      "CFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot",
+      "CXX": "[START_DIR]/cipd/bin/clang++",
+      "LDFLAGS": "--target=aarch64-linux-gnu --sysroot=[START_DIR]/cipd/sysroot -static-libstdc++"
+    },
+    "name": "release.linux-arm64.build",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
     "jsonResult": null,
     "name": "$result"
   }
diff --git a/infra/recipes/gn.expected/cq_mac.json b/infra/recipes/gn.expected/cq_mac.json
index b84aab8..3ae005b 100644
--- a/infra/recipes/gn.expected/cq_mac.json
+++ b/infra/recipes/gn.expected/cq_mac.json
@@ -46,6 +46,20 @@
   {
     "cmd": [
       "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]/gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "fetch",
       "https://gn.googlesource.com/gn",
       "refs/changes/56/123456/7"
@@ -77,7 +91,7 @@
       "-root",
       "[START_DIR]/cipd",
       "-ensure-file",
-      "infra/ninja/${platform} version:1.8.2\nfuchsia/clang/${platform} git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a",
+      "infra/ninja/${platform} version:1.8.2\nfuchsia/third_party/clang/${platform} integration",
       "-json-output",
       "/path/to/tmp/json"
     ],
@@ -88,8 +102,8 @@
       "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
       "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
-      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-git_revision:b92\", @@@",
-      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/clang/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-integration-----\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"fuchsia/third_party/clang/resolved-platform\"@@@",
       "@@@STEP_LOG_LINE@json.output@      }, @@@",
       "@@@STEP_LOG_LINE@json.output@      {@@@",
       "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:1.8.2---\", @@@",
@@ -153,30 +167,31 @@
     "name": "select XCode"
   },
   {
-    "cmd": [
-      "xcrun",
-      "--show-sdk-path"
-    ],
-    "name": "xcrun",
-    "stdout": "/path/to/tmp/",
-    "~followup_annotations": [
-      "@@@STEP_LOG_LINE@raw_io.output[sdk-path]@/some/xcode/path@@@",
-      "@@@STEP_LOG_END@raw_io.output[sdk-path]@@@"
-    ]
-  },
-  {
     "cmd": [],
     "name": "debug"
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.mac-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
   },
   {
     "cmd": [
+      "xcrun",
+      "--show-sdk-path"
+    ],
+    "name": "debug.mac-amd64.xcrun",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@raw_io.output[sdk-path]@/some/xcode/path@@@",
+      "@@@STEP_LOG_END@raw_io.output[sdk-path]@@@"
+    ]
+  },
+  {
+    "cmd": [
       "python",
       "-u",
       "[START_DIR]/gn/build/gen.py",
@@ -186,11 +201,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "debug.build.generate",
+    "name": "debug.mac-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -205,11 +220,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "debug.build.ninja",
+    "name": "debug.mac-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -218,9 +233,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "debug.test",
+    "name": "debug.mac-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -229,13 +244,26 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.mac-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
   },
   {
     "cmd": [
+      "xcrun",
+      "--show-sdk-path"
+    ],
+    "name": "release.mac-amd64.xcrun",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@raw_io.output[sdk-path]@/some/xcode/path@@@",
+      "@@@STEP_LOG_END@raw_io.output[sdk-path]@@@"
+    ]
+  },
+  {
+    "cmd": [
       "python",
       "-u",
       "[START_DIR]/gn/build/gen.py",
@@ -246,11 +274,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "release.build.generate",
+    "name": "release.mac-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -265,11 +293,11 @@
     "env": {
       "AR": "[START_DIR]/cipd/bin/llvm-ar",
       "CC": "[START_DIR]/cipd/bin/clang",
-      "CFLAGS": "--sysroot=/some/xcode/path",
+      "CFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path",
       "CXX": "[START_DIR]/cipd/bin/clang++",
-      "LDFLAGS": "--sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
+      "LDFLAGS": "--target=x86_64-apple-darwin --sysroot=/some/xcode/path -nostdlib++ [START_DIR]/cipd/lib/libc++.a"
     },
-    "name": "release.build.ninja",
+    "name": "release.mac-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -278,9 +306,9 @@
     "cmd": [
       "[START_DIR]/gn/out/gn_unittests"
     ],
-    "name": "release.test",
+    "name": "release.mac-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
diff --git a/infra/recipes/gn.expected/cq_win.json b/infra/recipes/gn.expected/cq_win.json
index b27d53f..8e352de 100644
--- a/infra/recipes/gn.expected/cq_win.json
+++ b/infra/recipes/gn.expected/cq_win.json
@@ -46,6 +46,20 @@
   {
     "cmd": [
       "git",
+      "rev-parse",
+      "HEAD"
+    ],
+    "cwd": "[START_DIR]\\gn",
+    "infra_step": true,
+    "name": "git.rev-parse",
+    "stdout": "/path/to/tmp/",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
       "fetch",
       "https://gn.googlesource.com/gn",
       "refs/changes/56/123456/7"
@@ -162,7 +176,7 @@
   },
   {
     "cmd": [],
-    "name": "debug.build",
+    "name": "debug.windows-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -183,7 +197,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "debug.build.generate",
+    "name": "debug.windows-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -203,7 +217,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "debug.build.ninja",
+    "name": "debug.windows-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -220,9 +234,9 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "debug.test",
+    "name": "debug.windows-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
@@ -231,7 +245,7 @@
   },
   {
     "cmd": [],
-    "name": "release.build",
+    "name": "release.windows-amd64",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@"
     ]
@@ -253,7 +267,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "release.build.generate",
+    "name": "release.windows-amd64.generate",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -273,7 +287,7 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "release.build.ninja",
+    "name": "release.windows-amd64.build",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@2@@@"
     ]
@@ -290,9 +304,9 @@
         "[CACHE]\\windows_sdk\\win_sdk\\bin\\x64"
       ]
     },
-    "name": "release.test",
+    "name": "release.windows-amd64.test",
     "~followup_annotations": [
-      "@@@STEP_NEST_LEVEL@1@@@"
+      "@@@STEP_NEST_LEVEL@2@@@"
     ]
   },
   {
diff --git a/infra/recipes/gn.py b/infra/recipes/gn.py
index f219b81..8110dfa 100644
--- a/infra/recipes/gn.py
+++ b/infra/recipes/gn.py
@@ -17,6 +17,7 @@
     'recipe_engine/python',
     'recipe_engine/raw_io',
     'recipe_engine/step',
+    'target',
     'macos_sdk',
     'windows_sdk',
 ]
@@ -40,6 +41,9 @@
       # Fetch tags so `git describe` works.
       api.step('fetch', ['git', 'fetch', '--tags', repository, ref])
       api.step('checkout', ['git', 'checkout', 'FETCH_HEAD'])
+      revision = api.step(
+          'rev-parse', ['git', 'rev-parse', 'HEAD'],
+          stdout=api.raw_io.output()).stdout.strip()
       for change in build_input.gerrit_changes:
         api.step('fetch %s/%s' % (change.change, change.patchset), [
             'git', 'fetch', repository,
@@ -54,11 +58,10 @@
     pkgs = api.cipd.EnsureFile()
     pkgs.add_package('infra/ninja/${platform}', 'version:1.8.2')
     if api.platform.is_linux or api.platform.is_mac:
-      pkgs.add_package('fuchsia/clang/${platform}',
-                       'git_revision:b920a7f65b13237dc4d5b2b836b29a954fff440a')
+      pkgs.add_package('fuchsia/third_party/clang/${platform}', 'integration')
     if api.platform.is_linux:
-      pkgs.add_package('fuchsia/sysroot/${platform}',
-                       'git_revision:a28dfa20af063e5ca00634024c85732e20220419',
+      pkgs.add_package('fuchsia/third_party/sysroot/linux',
+                       'git_revision:c912d089c3d46d8982fdef76a50514cca79b6132',
                        'sysroot')
     api.cipd.ensure(cipd_dir, pkgs)
 
@@ -66,93 +69,106 @@
   configs = [
       {
           'name': 'debug',
-          'args': ['-d']
+          'args': ['-d'],
+          'targets': [api.target.host],
       },
       {
           'name': 'release',
-          'args': ['--use-lto', '--use-icf']
+          'args': ['--use-lto', '--use-icf'],
+          'targets': [api.target('linux-amd64'),
+                      api.target('linux-arm64')]
+                     if api.platform.is_linux else [api.target.host],
       },
   ]
 
   with api.macos_sdk(), api.windows_sdk():
-    if api.platform.is_linux:
-      sysroot = '--sysroot=%s' % cipd_dir.join('sysroot')
-      env = {
-          'CC': cipd_dir.join('bin', 'clang'),
-          'CXX': cipd_dir.join('bin', 'clang++'),
-          'AR': cipd_dir.join('bin', 'llvm-ar'),
-          'CFLAGS': sysroot,
-          'LDFLAGS': sysroot,
-      }
-    elif api.platform.is_mac:
-      sysroot = '--sysroot=%s' % api.step(
-          'xcrun', ['xcrun', '--show-sdk-path'],
-          stdout=api.raw_io.output(name='sdk-path', add_output_log=True),
-          step_test_data=
-          lambda: api.raw_io.test_api.stream_output('/some/xcode/path')
-      ).stdout.strip()
-      stdlib = '-nostdlib++ %s' % cipd_dir.join('lib', 'libc++.a')
-      env = {
-          'CC': cipd_dir.join('bin', 'clang'),
-          'CXX': cipd_dir.join('bin', 'clang++'),
-          'AR': cipd_dir.join('bin', 'llvm-ar'),
-          'CFLAGS': sysroot,
-          'LDFLAGS': '%s %s' % (sysroot, stdlib),
-      }
-    else:
-      env = {}
-
     for config in configs:
       with api.step.nest(config['name']):
-        with api.step.nest('build'), api.context(env=env, cwd=src_dir):
-          api.python(
-              'generate', src_dir.join('build', 'gen.py'), args=config['args'])
+        for target in config['targets']:
+          with api.step.nest(target.platform):
+            if target.is_linux:
+              triple = '--target=%s' % target.triple
+              sysroot = '--sysroot=%s' % cipd_dir.join('sysroot')
+              env = {
+                  'CC': cipd_dir.join('bin', 'clang'),
+                  'CXX': cipd_dir.join('bin', 'clang++'),
+                  'AR': cipd_dir.join('bin', 'llvm-ar'),
+                  'CFLAGS': '%s %s' % (triple, sysroot),
+                  'LDFLAGS': '%s %s -static-libstdc++' % (triple, sysroot),
+              }
+            elif target.is_mac:
+              triple = '--target=%s' % target.triple
+              sysroot = '--sysroot=%s' % api.step(
+                  'xcrun', ['xcrun', '--show-sdk-path'],
+                  stdout=api.raw_io.output(
+                      name='sdk-path', add_output_log=True),
+                  step_test_data=lambda: api.raw_io.test_api.stream_output(
+                      '/some/xcode/path')).stdout.strip()
+              stdlib = cipd_dir.join('lib', 'libc++.a')
+              env = {
+                  'CC': cipd_dir.join('bin', 'clang'),
+                  'CXX': cipd_dir.join('bin', 'clang++'),
+                  'AR': cipd_dir.join('bin', 'llvm-ar'),
+                  'CFLAGS': '%s %s' % (triple, sysroot),
+                  'LDFLAGS': '%s %s -nostdlib++ %s' % (triple, sysroot, stdlib),
+              }
+            else:
+              env = {}
 
-          # Windows requires the environment modifications when building too.
-          api.step('ninja', [cipd_dir.join('ninja'), '-C', src_dir.join('out')])
+            with api.context(env=env, cwd=src_dir):
+              api.python(
+                  'generate',
+                  src_dir.join('build', 'gen.py'),
+                  args=config['args'])
 
-        api.step('test', [src_dir.join('out', 'gn_unittests')])
+              # Windows requires the environment modifications when building too.
+              api.step('build',
+                       [cipd_dir.join('ninja'), '-C',
+                        src_dir.join('out')])
 
-  if build_input.gerrit_changes:
-    return
+            if target.is_host:
+              api.step('test', [src_dir.join('out', 'gn_unittests')])
 
-  cipd_pkg_name = 'gn/gn/${platform}'
-  gn = 'gn' + ('.exe' if api.platform.is_win else '')
+            if build_input.gerrit_changes:
+              continue
 
-  pkg_def = api.cipd.PackageDefinition(
-      package_name=cipd_pkg_name,
-      package_root=src_dir.join('out'),
-      install_mode='copy')
-  pkg_def.add_file(src_dir.join('out', gn))
-  pkg_def.add_version_file('.versions/%s.cipd_version' % gn)
+            if config['name'] != 'release':
+              continue
 
-  cipd_pkg_file = api.path['cleanup'].join('gn.cipd')
+            with api.step.nest('upload'):
+              cipd_pkg_name = 'gn/gn/%s' % target.platform
+              gn = 'gn' + ('.exe' if target.is_win else '')
 
-  api.cipd.build_from_pkg(
-      pkg_def=pkg_def,
-      output_package=cipd_pkg_file,
-  )
+              pkg_def = api.cipd.PackageDefinition(
+                  package_name=cipd_pkg_name,
+                  package_root=src_dir.join('out'),
+                  install_mode='copy')
+              pkg_def.add_file(src_dir.join('out', gn))
+              pkg_def.add_version_file('.versions/%s.cipd_version' % gn)
 
-  if api.buildbucket.builder_id.project == 'infra-internal':
-    with api.context(cwd=src_dir):
-      revision = api.step(
-          'rev-parse', ['git', 'rev-parse', 'HEAD'],
-          stdout=api.raw_io.output()).stdout.strip()
+              cipd_pkg_file = api.path['cleanup'].join('gn.cipd')
 
-    cipd_pin = api.cipd.search(cipd_pkg_name, 'git_revision:' + revision)
-    if cipd_pin:
-      api.step('Package is up-to-date', cmd=None)
-      return
+              api.cipd.build_from_pkg(
+                  pkg_def=pkg_def,
+                  output_package=cipd_pkg_file,
+              )
 
-    api.cipd.register(
-        package_name=cipd_pkg_name,
-        package_path=cipd_pkg_file,
-        refs=['latest'],
-        tags={
-            'git_repository': repository,
-            'git_revision': revision,
-        },
-    )
+              if api.buildbucket.builder_id.project == 'infra-internal':
+                cipd_pin = api.cipd.search(cipd_pkg_name,
+                                           'git_revision:' + revision)
+                if cipd_pin:
+                  api.step('Package is up-to-date', cmd=None)
+                  return
+
+                api.cipd.register(
+                    package_name=cipd_pkg_name,
+                    package_path=cipd_pkg_file,
+                    refs=['latest'],
+                    tags={
+                        'git_repository': repository,
+                        'git_revision': revision,
+                    },
+                )
 
 
 def GenTests(api):
@@ -173,15 +189,20 @@
       project='infra-internal',
       git_repo='gn.googlesource.com/gn',
       revision='a' * 40,
-  ) + api.step_data('rev-parse', api.raw_io.stream_output('a' * 40)) +
-         api.step_data('cipd search gn/gn/${platform} git_revision:' + 'a' * 40,
-                       api.cipd.example_search('gn/gn/linux-amd64',
-                                               ['git_revision:' + 'a' * 40])))
+  ) + api.step_data(
+      'git.rev-parse', api.raw_io.stream_output('a' * 40)
+  ) + api.step_data(
+      'release.linux-amd64.upload.cipd search gn/gn/linux-amd64 git_revision:' +
+      'a' * 40,
+      api.cipd.example_search('gn/gn/linux-amd64',
+                              ['git_revision:' + 'a' * 40])))
 
   yield (api.test('cipd_register') + api.buildbucket.ci_build(
       project='infra-internal',
       git_repo='gn.googlesource.com/gn',
       revision='a' * 40,
-  ) + api.step_data('rev-parse', api.raw_io.stream_output('a' * 40)) +
-         api.step_data('cipd search gn/gn/${platform} git_revision:' + 'a' * 40,
-                       api.cipd.example_search('gn/gn/linux-amd64', [])))
+  ) + api.step_data(
+      'git.rev-parse', api.raw_io.stream_output('a' * 40)
+  ) + api.step_data(
+      'release.linux-amd64.upload.cipd search gn/gn/linux-amd64 git_revision:' +
+      'a' * 40, api.cipd.example_search('gn/gn/linux-amd64', [])))