Set DYLD_LIBRARY_PATH correctly for rustc.

--
MOS_MIGRATED_REVID=102121504
diff --git a/tools/build_rules/rust/BUILD b/tools/build_rules/rust/BUILD
index b314c0d..2849334 100644
--- a/tools/build_rules/rust/BUILD
+++ b/tools/build_rules/rust/BUILD
@@ -19,6 +19,14 @@
 )
 
 filegroup(
+    name = "rustc_lib",
+    srcs = select({
+        ":darwin": ["@rust-darwin-x86_64//:rustc_lib"],
+        ":k8": ["@rust-linux-x86_64//:rustc_lib"],
+    }),
+)
+
+filegroup(
     name = "rustlib",
     srcs = select({
         ":darwin": ["@rust-darwin-x86_64//:rustlib"],
diff --git a/tools/build_rules/rust/rust-darwin-x86_64.BUILD b/tools/build_rules/rust/rust-darwin-x86_64.BUILD
index 1e3b7c9..cc7aaad 100644
--- a/tools/build_rules/rust/rust-darwin-x86_64.BUILD
+++ b/tools/build_rules/rust/rust-darwin-x86_64.BUILD
@@ -7,6 +7,12 @@
 )
 
 filegroup(
+    name = "rustc_lib",
+    srcs = glob([BASE_DIR + "rustc/lib/*.dylib"]),
+    visibility = ["//visibility:public"],
+)
+
+filegroup(
     name = "rustdoc",
     srcs = [BASE_DIR + "rustc/bin/rustdoc"],
     visibility = ["//visibility:public"],
diff --git a/tools/build_rules/rust/rust-linux-x86_64.BUILD b/tools/build_rules/rust/rust-linux-x86_64.BUILD
index 2755910..7d4a7e34 100644
--- a/tools/build_rules/rust/rust-linux-x86_64.BUILD
+++ b/tools/build_rules/rust/rust-linux-x86_64.BUILD
@@ -7,6 +7,12 @@
 )
 
 filegroup(
+    name = "rustc_lib",
+    srcs = glob([BASE_DIR + "rustc/lib/*.so"]),
+    visibility = ["//visibility:public"],
+)
+
+filegroup(
     name = "rustdoc",
     srcs = [BASE_DIR + "rustc/bin/rustdoc"],
     visibility = ["//visibility:public"],
diff --git a/tools/build_rules/rust/rust.bzl b/tools/build_rules/rust/rust.bzl
index 149f415..847775d 100644
--- a/tools/build_rules/rust/rust.bzl
+++ b/tools/build_rules/rust/rust.bzl
@@ -120,6 +120,7 @@
 
   # Paths to the Rust compiler and standard libraries.
   rustc_path = ctx.file._rustc.path
+  rustc_lib_path = ctx.files._rustc_lib[0].dirname
   rustlib_path = ctx.files._rustlib[0].dirname
 
   # Paths to cc (for linker) and ar
@@ -140,6 +141,7 @@
   return " ".join([
       "set -e;",
       " ".join(depinfo.setup_cmd),
+      "DYLD_LIBRARY_PATH=" + rustc_lib_path,
       rustc_path + " " + src,
       "--crate-name " + ctx.label.name,
       "--crate-type " + crate_type,
@@ -267,6 +269,8 @@
         default = Label("//tools/build_rules/rust:rustc"),
         executable = True,
         single_file = True),
+    "_rustc_lib": attr.label(
+        default = Label("//tools/build_rules/rust:rustc_lib")),
     "_rustlib": attr.label(default = Label("//tools/build_rules/rust:rustlib")),
 }