Similiar to the LLVM cross toolchain in void linux, the rust toolchain
also does not ship the rust stdlib for every target, so add an additional
`rust_cross_sysroot` variable that is used when cross compiling.
--- a/build/config/rust.gni
+++ b/build/config/rust.gni
@@ -60,6 +60,7 @@
   # a Rust sysroot, which will have a 'bin' directory and others. Commonly
   # <home dir>/.rustup/toolchains/nightly-<something>-<something>
   rust_sysroot_absolute = ""
+  rust_cross_sysroot_absolute = ""

   # Directory under which to find `bin/bindgen` (a `bin` directory containing
   # the bindgen exectuable).
--- a/build/rust/std/BUILD.gn
+++ b/build/rust/std/BUILD.gn
@@ -294,6 +294,13 @@
         rust_abi_target,
       ]

+      if (current_cpu == target_cpu && rust_cross_sysroot_absolute != "") {
+        args += [
+          "--sysroot",
+          rust_cross_sysroot_absolute,
+        ]
+      }
+
       outputs = []
       foreach(lib, all_stdlibs_to_copy) {
         outputs += [ "$target_out_dir/lib$lib.rlib" ]
--- a/build/rust/std/find_std_rlibs.py
+++ b/build/rust/std/find_std_rlibs.py
@@ -26,6 +26,7 @@
                       help="Path to Rust binaries",
                       required=True),
   parser.add_argument("--target", help="Rust target triple", required=False),
+  parser.add_argument("--sysroot", help="Rust sysroot", required=False),
   parser.add_argument("--output",
                       help="Path to rlibs without suffixes",
                       required=True)
@@ -50,6 +51,8 @@
   rustc_args = [rustc, "--print", "target-libdir"]
   if args.target:
     rustc_args.extend(["--target", args.target])
+  if args.sysroot:
+    rustc_args.extend(["--sysroot", args.sysroot])
   rustlib_dir = subprocess.check_output(rustc_args).rstrip().decode()

   # Copy the rlibs to a predictable location. Whilst we're doing so,
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -1158,6 +1158,12 @@
   if (rust_abi_target != "") {
     rustflags += [ "--target=$rust_abi_target" ]
   }
+  if (current_cpu != host_cpu && rust_cross_sysroot_absolute != "") {
+    rustflags += [
+      "--sysroot",
+      rust_cross_sysroot_absolute,
+    ]
+  }
   if (!use_thin_lto || !toolchain_supports_rust_thin_lto) {
     # Don't include bitcode if it won't be used.
     rustflags += [ "-Cembed-bitcode=no" ]
