dev-lang/rust: upgrade to Rust 1.47.0

This CL is created by rust_uprev tool automatically.

BUG=chromium:1136579
TEST=Use CQ to test the new Rust version

Change-Id: Iaef465426aa6e06ffb1649f658a416751708755f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/2472102
Reviewed-by: LaMont Jones <lamontjones@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: LaMont Jones <lamontjones@chromium.org>
Tested-by: LaMont Jones <lamontjones@chromium.org>
diff --git a/dev-lang/rust/Manifest b/dev-lang/rust/Manifest
index 993f054..e146dca 100644
--- a/dev-lang/rust/Manifest
+++ b/dev-lang/rust/Manifest
@@ -1,8 +1,8 @@
-DIST cargo-0.45.0-x86_64-unknown-linux-gnu.tar.gz 7179449 BLAKE2B 45160eb3dbeb201840cffad556c3ce459302ae466ec9ed63f060634b87ee3f61bd1345a24f908cbc435138486f272a052046056b3b6b39d9b65b7d4654b7c9bd SHA512 5d63f9feb2dc9d9675372f0cacabde4ca1236081a42b71488f9697eeeec92b1dba9bd37a33c9d3e2ddbd686d180a488e394139e9ccf8dafdcaaf41485637a028
 DIST cargo-0.46.1-x86_64-unknown-linux-gnu.tar.gz 7235571 BLAKE2B 6d0b64055dd7aa846b7581ab35f4071d30f2bf6e5be838bce4e31e9d42cf89c09ff118277eb6feadad5a168fe7b0460201ccc47fbc4f10bab272d761272bff83 SHA512 edddda8921e4bdcc7a27250f9e6f20f884ec6af9089f6b0f72d7793136d42e430b777e34b285e42d25b70c4374ec8b3db74baadba1283123c0a73a8b42c93e8d
-DIST rust-std-1.44.0-x86_64-unknown-linux-gnu.tar.gz 26283034 BLAKE2B 5115ee74802ca91c4190602633c374323937f29d3419422092abc87fb968fde6be5469120b415f1fb2f0359b09d70cc5101d74281a8d6dbf65ffbad03b177c6b SHA512 54fe33dc7c49082cfa7c7f0e0590d339095d5cae5e038ac97546962a96c02463592b041775c69612c7190dcd157c8292af8ca094377075f10ce2c47c68cbf631
+DIST cargo-0.47.0-x86_64-unknown-linux-gnu.tar.gz 7236297 BLAKE2B a1f11eb5433cd50fcc06df7e8bd54ac2d630f4e1032acd0509d07be48f9174333a9a4f74dbb8d88e41389bc3c787073a7d40e37deaf1a2595a4155bd8ee153cc SHA512 182aad22ac4115839c4356e12997effd6dd67958637e85a6be431d359658a1d702e1083ca49605610592cbd7bd7069dddcaf37ba9afb23baac3a51156ce9ebe4
 DIST rust-std-1.45.2-x86_64-unknown-linux-gnu.tar.gz 26069244 BLAKE2B ae1344ac16f8f9edf8a2e20cf5ea9187c4db79575b6f42b887bfb382f4f5a21e09874a4d322c69a533aff4cb25097e0e19b339d2e1059274d73564714c6e8a77 SHA512 2d0ad09a0c0d1052e59ba29bdc9c0e3e5de0ba38099ecb838923fc75ac124b36066e4c5b9e45f2f373678f38cdd8367eb41d6058186be0b2d8387806e3c1c293
-DIST rustc-1.44.0-x86_64-unknown-linux-gnu.tar.gz 93602946 BLAKE2B 5c9fe1f4e0f575619bbe2d39dc9842f78c87cce9b41985bc4b4234df2b1007ae7c093bb5dd2ff305deb1eeedecd2894ceac977d29f2b9df51885c3bbe56f89d3 SHA512 bcdce3cb71b7c6abbdad79b69f20f3d87621377d48eb07bace8b08a9bb117a0a2ea80c19ab5dc918f1cd5369e361def9cc5090dedaad2715a9c84bb3624ce495
-DIST rustc-1.45.2-src.tar.gz 141671717 BLAKE2B 703d8208fef22acfd232626ad2ea661408745e604a8844eb5a6971e34bf065cd8eb52da43f7a193ae1a4788e6617801f64884b3f0f6c2ca1e4ab1533b4c6d460 SHA512 5996f899d3677dd73487561d95b0bee6d6e33f7087f40806fa8176d685de9e6d42974344c855402a9fc634c0e91e0df6e33fcb3194b3e4296e1a1cb49defb98e
+DIST rust-std-1.46.0-x86_64-unknown-linux-gnu.tar.gz 26310833 BLAKE2B ffcb43b4e1372603c24307461dd7ed5fe9fc06a9f55397350dcbb93c1e838d8855c209e07a205424170bd77795db1d14f20c45d11861e7150cad8f55ac82d901 SHA512 0291f64bb01ca02dbfa8e25c23ff1c90ffc431e8455244e366bc1e88ce3db9ff5de452f744692b5bb3e9c34c50308fe11997737566f378ec3c09ac4345889c8a
 DIST rustc-1.45.2-x86_64-unknown-linux-gnu.tar.gz 73910606 BLAKE2B 4214f11668aca46e4262e459bea75bd95c770c3188ef48e756af03ee6d7a9d0e711a4f0d63de766b9bc8ab3e9e503d75a13f119d28ea7d714c63bdf89d5a7808 SHA512 34e96e7da38e1eec503507a26d4d75d38ef4a6d9dad03afe771d9fd7a79c8dfe430a503101ca311476d2aa260dbd7e984c631fb55ecc6004422962593d57fea6
 DIST rustc-1.46.0-src.tar.gz 149449054 BLAKE2B de01c934b795c01955e665fb9be815bfd75471921c3839f89954e8e91c335dc988a943025cdedde26b988e898d944776848e3869c06de78e34da8f1cb825400e SHA512 5c50f449930473577b1ffb5791e6a688394821b368873f788a7d6c984055500a01897523930b763a454982f31d0a2fd4e87dfe5c416dd83ec9c844017e92b98e
+DIST rustc-1.46.0-x86_64-unknown-linux-gnu.tar.gz 76990308 BLAKE2B 6680f68c27d4ec8d961b3187fa47289129a1598b3f0ca1bdd40c0fde114ae65c596ea0f1a29f3d76317ce0ad4d45da9ef45de5cc6cc9feb10b3be4e08907601d SHA512 fb214be2f1008955d5722eb85189d733574326e4d43e3d701d3f58235a6ce82fdcfd6aa7f5d7101003ebf29589a8854cba280051298b7c63e19a08f459567ce3
+DIST rustc-1.47.0-src.tar.gz 151861620 BLAKE2B 8fef2e63ac98b44f4a74ad68c7225851d7f382aca573f9e0cab89131eea38c1f1b38c8cc267856cd2fe401621af8f7cc53fa24281365a535b0d70b32463adcb0 SHA512 a6df9e2d599806eeddbfb35f7dea976781533f63d369a765b8a304221281c9f9e642ff952978f69eaaa0b28740ab5ea566b35ce481097c37fd5117bfec1f43dd
diff --git a/dev-lang/rust/files/rust-1.45.2-Revert-CMake-Unconditionally-add-.h-and-.td-files-to.patch b/dev-lang/rust/files/rust-1.45.2-Revert-CMake-Unconditionally-add-.h-and-.td-files-to.patch
deleted file mode 100644
index 5f6c3a5..0000000
--- a/dev-lang/rust/files/rust-1.45.2-Revert-CMake-Unconditionally-add-.h-and-.td-files-to.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 0d2bca57088e9024760c5b0629e7b2df021a4020 Mon Sep 17 00:00:00 2001
-From: Zach Reizner <zachr@google.com>
-Date: Wed, 23 Jan 2019 14:48:27 -0800
-Subject: [PATCH] Revert "[CMake] Unconditionally add .h and .td files to
- target sources"
-
-This reverts commit 6fb010f388bb2cb2f00fe039123092308ac4865d.
-
-Reason for revert: LLVM includes /usr/include/demangle.h which is not installed.
-
-BUG=chromium:924647
-TEST=cros tryjob chromiumos-sdk-tryjob
----
- src/llvm/cmake/modules/LLVMProcessSources.cmake | 17 +++++++++--------
- 1 file changed, 9 insertions(+), 8 deletions(-)
-
-diff --git a/src/llvm/cmake/modules/LLVMProcessSources.cmake b/src/llvm/cmake/modules/LLVMProcessSources.cmake
-index 7cbd2863500..f65f31d797c 100644
---- a/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
-+++ b/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
-@@ -52,15 +52,16 @@ function(llvm_process_sources OUT_VAR)
-   cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
-   set(sources ${ARG_UNPARSED_ARGUMENTS})
-   llvm_check_source_file_list( ${sources} )
--  
--  # This adds .td and .h files to the Visual Studio solution:
--  add_td_sources(sources)
--  find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
--  if (hdrs)
--    set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
-+  if( LLVM_ENABLE_IDE )
-+    # This adds .td and .h files to the Visual Studio solution:
-+    add_td_sources(sources)
-+    find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
-+    if (hdrs)
-+      set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
-+    endif()
-+    set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
-+    list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
-   endif()
--  set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
--  list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
- 
-   set( ${OUT_VAR} ${sources} PARENT_SCOPE )
- endfunction(llvm_process_sources)
--- 
-2.20.1.321.g9e740568ce-goog
diff --git a/dev-lang/rust/files/rust-1.45.2-enable-sanitizers.patch b/dev-lang/rust/files/rust-1.45.2-enable-sanitizers.patch
deleted file mode 100644
index 59204a9..0000000
--- a/dev-lang/rust/files/rust-1.45.2-enable-sanitizers.patch
+++ /dev/null
@@ -1,193 +0,0 @@
-Sanitizer runtimes are currently behind the `-Z` flag, which is only available
-on nightly builds of the compiler.  We would like to enable fuzzing on chrome
-os anyway so move the sanitizer option under `-C` instead since we don't build
-the toolchain in nightly mode.
-
-The changes this patch makes are:
- - changing debugging_opts.sanitizer to cg.sanitizer.
- - add the appropriate options to options.rs.
-
-diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs
-index a4e17a5f675..0b109d392bf 100644
---- a/src/librustc_codegen_llvm/attributes.rs
-+++ b/src/librustc_codegen_llvm/attributes.rs
-@@ -46,7 +46,7 @@ fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
- /// Apply LLVM sanitize attributes.
- #[inline]
- pub fn sanitize(cx: &CodegenCx<'ll, '_>, codegen_fn_flags: CodegenFnAttrFlags, llfn: &'ll Value) {
--    if let Some(ref sanitizer) = cx.tcx.sess.opts.debugging_opts.sanitizer {
-+    if let Some(ref sanitizer) = cx.tcx.sess.opts.cg.sanitizer {
-         match *sanitizer {
-             Sanitizer::Address => {
-                 if !codegen_fn_flags.contains(CodegenFnAttrFlags::NO_SANITIZE_ADDRESS) {
-@@ -123,7 +123,7 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
-     // Currently stack probes seem somewhat incompatible with the address
-     // sanitizer and thread sanitizer. With asan we're already protected from
-     // stack overflow anyway so we don't really need stack probes regardless.
--    match cx.sess().opts.debugging_opts.sanitizer {
-+    match cx.sess().opts.cg.sanitizer {
-         Some(Sanitizer::Address | Sanitizer::Thread) => return,
-         _ => {}
-     }
-diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
-index dcce1d45298..ef5e7d2a42a 100644
---- a/src/librustc_codegen_ssa/back/link.rs
-+++ b/src/librustc_codegen_ssa/back/link.rs
-@@ -718,7 +718,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
- }
- 
- fn link_sanitizer_runtime(sess: &Session, crate_type: CrateType, linker: &mut dyn Linker) {
--    let sanitizer = match &sess.opts.debugging_opts.sanitizer {
-+    let sanitizer = match &sess.opts.cg.sanitizer {
-         Some(s) => s,
-         None => return,
-     };
-@@ -752,7 +752,11 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: CrateType, linker: &mut dy
-             linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
-             linker.link_dylib(Symbol::intern(&libname));
-         }
--        "x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
-+        "x86_64-unknown-linux-gnu"
-+        | "x86_64-fuchsia"
-+        | "aarch64-fuchsia"
-+        | "x86_64-cros-linux-gnu"
-+        | "x86_64-pc-linux-gnu" => {
-             let filename = format!("librustc{}_rt.{}.a", channel, name);
-             let path = default_tlib.join(&filename);
-             linker.link_whole_rlib(&path);
-@@ -1509,7 +1513,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
- 
-     // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
-     if sess.target.target.options.is_like_fuchsia && crate_type == CrateType::Executable {
--        let prefix = match sess.opts.debugging_opts.sanitizer {
-+        let prefix = match sess.opts.cg.sanitizer {
-             Some(Sanitizer::Address) => "asan/",
-             _ => "",
-         };
-diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs
-index 970d13b30c0..50a82461fef 100644
---- a/src/librustc_codegen_ssa/back/symbol_export.rs
-+++ b/src/librustc_codegen_ssa/back/symbol_export.rs
-@@ -202,7 +202,7 @@ fn exported_symbols_provider_local(
-         }));
-     }
- 
--    if let Some(Sanitizer::Memory) = tcx.sess.opts.debugging_opts.sanitizer {
-+    if let Some(Sanitizer::Memory) = tcx.sess.opts.cg.sanitizer {
-         // Similar to profiling, preserve weak msan symbol during LTO.
-         const MSAN_WEAK_SYMBOLS: [&str; 2] = ["__msan_track_origins", "__msan_keep_going"];
- 
-diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs
-index cb5c95c11fa..a040013901a 100644
---- a/src/librustc_codegen_ssa/back/write.rs
-+++ b/src/librustc_codegen_ssa/back/write.rs
-@@ -189,7 +189,7 @@ impl ModuleConfig {
-             ),
-             pgo_use: if_regular!(sess.opts.cg.profile_use.clone(), None),
- 
--            sanitizer: if_regular!(sess.opts.debugging_opts.sanitizer.clone(), None),
-+            sanitizer: if_regular!(sess.opts.cg.sanitizer.clone(), None),
-             sanitizer_recover: if_regular!(
-                 sess.opts.debugging_opts.sanitizer_recover.clone(),
-                 vec![]
-diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs
-index 35d55c4cb9b..e167ca3da51 100644
---- a/src/librustc_mir/transform/inline.rs
-+++ b/src/librustc_mir/transform/inline.rs
-@@ -232,7 +232,7 @@ impl Inliner<'tcx> {
- 
-         // Avoid inlining functions marked as no_sanitize if sanitizer is enabled,
-         // since instrumentation might be enabled and performed on the caller.
--        match self.tcx.sess.opts.debugging_opts.sanitizer {
-+        match self.tcx.sess.opts.cg.sanitizer {
-             Some(Sanitizer::Address) => {
-                 if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NO_SANITIZE_ADDRESS) {
-                     return false;
-diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs
-index 5bdd7b67723..41569753010 100644
---- a/src/librustc_session/config.rs
-+++ b/src/librustc_session/config.rs
-@@ -726,7 +726,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
-             }
-         }
-     }
--    if let Some(s) = &sess.opts.debugging_opts.sanitizer {
-+    if let Some(s) = &sess.opts.cg.sanitizer {
-         let symbol = Symbol::intern(&s.to_string());
-         ret.insert((sym::sanitize, Some(symbol)));
-     }
-diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs
-index a38e7f063d7..838fd26700f 100644
---- a/src/librustc_session/options.rs
-+++ b/src/librustc_session/options.rs
-@@ -759,6 +759,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
-         "print remarks for these optimization passes (space separated, or \"all\")"),
-     rpath: bool = (false, parse_bool, [UNTRACKED],
-         "set rpath values in libs/exes (default: no)"),
-+    sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
-+        "use a sanitizer"),
-     save_temps: bool = (false, parse_bool, [UNTRACKED],
-         "save all temporary output files during compilation (default: no)"),
-     soft_float: bool = (false, parse_bool, [TRACKED],
-diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs
-index 048033846a1..b09e6acb981 100644
---- a/src/librustc_session/session.rs
-+++ b/src/librustc_session/session.rs
-@@ -650,7 +650,7 @@ impl Session {
-             || self.opts.output_types.contains_key(&OutputType::Bitcode);
- 
-         // Address sanitizer and memory sanitizer use alloca name when reporting an issue.
--        let more_names = match self.opts.debugging_opts.sanitizer {
-+        let more_names = match self.opts.cg.sanitizer {
-             Some(Sanitizer::Address) => true,
-             Some(Sanitizer::Memory) => true,
-             _ => more_names,
-@@ -1017,7 +1017,7 @@ impl Session {
- 
-     /// Checks if LLVM lifetime markers should be emitted.
-     pub fn emit_lifetime_markers(&self) -> bool {
--        match self.opts.debugging_opts.sanitizer {
-+        match self.opts.cg.sanitizer {
-             // AddressSanitizer uses lifetimes to detect use after scope bugs.
-             // MemorySanitizer uses lifetimes to detect use of uninitialized stack variables.
-             Some(Sanitizer::Address | Sanitizer::Memory) => true,
-@@ -1354,18 +1354,32 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
-     }
- 
-     // Sanitizers can only be used on some tested platforms.
--    if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer {
-+    if let Some(ref sanitizer) = sess.opts.cg.sanitizer {
-         const ASAN_SUPPORTED_TARGETS: &[&str] = &[
-             "x86_64-unknown-linux-gnu",
-+            "x86_64-cros-linux-gnu",
-+            "x86_64-pc-linux-gnu",
-             "x86_64-apple-darwin",
-             "x86_64-fuchsia",
-             "aarch64-fuchsia",
-         ];
--        const TSAN_SUPPORTED_TARGETS: &[&str] =
--            &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
--        const LSAN_SUPPORTED_TARGETS: &[&str] =
--            &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
--        const MSAN_SUPPORTED_TARGETS: &[&str] = &["x86_64-unknown-linux-gnu"];
-+        const TSAN_SUPPORTED_TARGETS: &[&str] = &[
-+            "x86_64-unknown-linux-gnu",
-+            "x86_64-cros-linux-gnu",
-+            "x86_64-pc-linux-gnu",
-+            "x86_64-apple-darwin",
-+        ];
-+        const LSAN_SUPPORTED_TARGETS: &[&str] = &[
-+            "x86_64-unknown-linux-gnu",
-+            "x86_64-cros-linux-gnu",
-+            "x86_64-pc-linux-gnu",
-+            "x86_64-apple-darwin",
-+        ];
-+        const MSAN_SUPPORTED_TARGETS: &[&str] = &[
-+            "x86_64-unknown-linux-gnu",
-+            "x86_64-cros-linux-gnu",
-+            "x86_64-pc-linux-gnu",
-+        ];
- 
-         let supported_targets = match *sanitizer {
-             Sanitizer::Address => ASAN_SUPPORTED_TARGETS,
-
diff --git a/dev-lang/rust/files/rust-1.45.2-sanitizer-supported.patch b/dev-lang/rust/files/rust-1.45.2-sanitizer-supported.patch
deleted file mode 100644
index 8e0e7aa..0000000
--- a/dev-lang/rust/files/rust-1.45.2-sanitizer-supported.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-Ensure that sanitizer runtimes are built for all our supported x86_64
-platforms.
-
-Now that we patch in our own custom -cros and -pc targets instead
-of falling back to -unknown, we need to add builds for those
-targets as well to allow the linker to find the correct versions
-of the librustc_[almt]san static libraries.
-
-diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
-index a796685f9dd..20a7f0d8e59 100644
---- a/src/bootstrap/native.rs
-+++ b/src/bootstrap/native.rs
-@@ -660,7 +660,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
-                 });
-             }
-         }
--        "x86_64-unknown-linux-gnu" => {
-+        "x86_64-unknown-linux-gnu" | "x86_64-cros-linux-gnu" | "x86_64-pc-linux-gnu" => {
-             for s in &["asan", "lsan", "msan", "tsan"] {
-                 result.push(SanitizerRuntime {
-                     cmake_target: format!("clang_rt.{}-x86_64", s),
diff --git a/dev-lang/rust/files/rust-1.47.0-Revert-CMake-Unconditionally-add-.h-and-.td-files-to.patch b/dev-lang/rust/files/rust-1.47.0-Revert-CMake-Unconditionally-add-.h-and-.td-files-to.patch
new file mode 100644
index 0000000..da9e10b
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.47.0-Revert-CMake-Unconditionally-add-.h-and-.td-files-to.patch
@@ -0,0 +1,25 @@
+diff --git a/llvm/cmake/modules/LLVMProcessSources.cmake b/llvm/cmake/modules/LLVMProcessSources.cmake
+index ba8dca313c8..b99430c0f30 100644
+--- a/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
++++ b/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
+@@ -63,11 +63,15 @@ function(llvm_process_sources OUT_VAR)
+     llvm_check_source_file_list(${sources})
+   endif()
+ 
+-  # This adds .td and .h files to the Visual Studio solution:
+-  add_td_sources(sources)
+-  find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
+-  if (hdrs)
+-    set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
++  if( LLVM_ENABLE_IDE )
++    # This adds .td and .h files to the Visual Studio solution:
++    add_td_sources(sources)
++    find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
++    if (hdrs)
++      set_source_files_properties(${hdrs} PROPERTIES HEADER_FILE_ONLY ON)
++    endif()
++    set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
++    list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
+   endif()
+   set_source_files_properties(${ARG_ADDITIONAL_HEADERS} PROPERTIES HEADER_FILE_ONLY ON)
+   list(APPEND sources ${ARG_ADDITIONAL_HEADERS} ${hdrs})
diff --git a/dev-lang/rust/files/rust-1.45.2-add-cros-targets.patch b/dev-lang/rust/files/rust-1.47.0-add-cros-targets.patch
similarity index 100%
rename from dev-lang/rust/files/rust-1.45.2-add-cros-targets.patch
rename to dev-lang/rust/files/rust-1.47.0-add-cros-targets.patch
diff --git a/dev-lang/rust/files/rust-1.45.2-cc.patch b/dev-lang/rust/files/rust-1.47.0-cc.patch
similarity index 93%
rename from dev-lang/rust/files/rust-1.45.2-cc.patch
rename to dev-lang/rust/files/rust-1.47.0-cc.patch
index eae217a..b2651c1 100644
--- a/dev-lang/rust/files/rust-1.45.2-cc.patch
+++ b/dev-lang/rust/files/rust-1.47.0-cc.patch
@@ -2,10 +2,10 @@
 This fixes crbug.com/1090829.
 
 diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
-index dcce1d4..cf306a4 100644
+index 8725bfa..5984569 100644
 --- a/src/librustc_codegen_ssa/back/link.rs
 +++ b/src/librustc_codegen_ssa/back/link.rs
-@@ -789,12 +789,12 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
+@@ -752,12 +752,12 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
              (Some(linker), Some(flavor)) => Some((linker, flavor)),
              // only the linker flavor is known; use the default linker for the selected flavor
              (None, Some(flavor)) => Some((
@@ -21,7 +21,7 @@
                          }
                      }
                      LinkerFlavor::Gcc => {
-@@ -805,16 +805,19 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
+@@ -768,16 +768,19 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
                              // and many modern illumos distributions today
                              // ship GCC as "gcc" without also making it
                              // available as "cc".
diff --git a/dev-lang/rust/files/rust-1.47.0-enable-sanitizers.patch b/dev-lang/rust/files/rust-1.47.0-enable-sanitizers.patch
new file mode 100644
index 0000000..739ab09
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.47.0-enable-sanitizers.patch
@@ -0,0 +1,224 @@
+Sanitizer runtimes are currently behind the `-Z` flag, which is only available
+on nightly builds of the compiler.  We would like to enable fuzzing on chrome
+os anyway so move the sanitizer option under `-C` instead since we don't build
+the toolchain in nightly mode.
+
+The changes this patch makes are:
+ - changing debugging_opts.sanitizer to cg.sanitizer.
+ - add the appropriate options to options.rs.
+
+diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs
+index 227a87ff819..7d9682883a8 100644
+--- a/src/librustc_codegen_llvm/attributes.rs
++++ b/src/librustc_codegen_llvm/attributes.rs
+@@ -46,7 +46,7 @@ fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
+ /// Apply LLVM sanitize attributes.
+ #[inline]
+ pub fn sanitize(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &'ll Value) {
+-    let enabled = cx.tcx.sess.opts.debugging_opts.sanitizer - no_sanitize;
++    let enabled = cx.tcx.sess.opts.cg.sanitizer - no_sanitize;
+     if enabled.contains(SanitizerSet::ADDRESS) {
+         llvm::Attribute::SanitizeAddress.apply_llfn(Function, llfn);
+     }
+@@ -113,13 +113,7 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
+     // Currently stack probes seem somewhat incompatible with the address
+     // sanitizer and thread sanitizer. With asan we're already protected from
+     // stack overflow anyway so we don't really need stack probes regardless.
+-    if cx
+-        .sess()
+-        .opts
+-        .debugging_opts
+-        .sanitizer
+-        .intersects(SanitizerSet::ADDRESS | SanitizerSet::THREAD)
+-    {
++    if cx.sess().opts.cg.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::THREAD) {
+         return;
+     }
+ 
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index bfcf979d125..5c353856bd5 100644
+--- a/src/librustc_codegen_ssa/back/link.rs
++++ b/src/librustc_codegen_ssa/back/link.rs
+@@ -785,7 +785,7 @@ fn link_sanitizers(sess: &Session, crate_type: CrateType, linker: &mut dyn Linke
+         return;
+     }
+ 
+-    let sanitizer = sess.opts.debugging_opts.sanitizer;
++    let sanitizer = sess.opts.cg.sanitizer;
+     if sanitizer.contains(SanitizerSet::ADDRESS) {
+         link_sanitizer_runtime(sess, linker, "asan");
+     }
+@@ -823,7 +823,9 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) {
+         | "aarch64-unknown-linux-gnu"
+         | "x86_64-fuchsia"
+         | "x86_64-unknown-freebsd"
+-        | "x86_64-unknown-linux-gnu" => {
++        | "x86_64-unknown-linux-gnu"
++        | "x86_64-cros-linux-gnu"
++        | "x86_64-pc-linux-gnu" => {
+             let filename = format!("librustc{}_rt.{}.a", channel, name);
+             let path = default_tlib.join(&filename);
+             linker.link_whole_rlib(&path);
+@@ -1596,11 +1598,8 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
+ 
+     // NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
+     if sess.target.target.options.is_like_fuchsia && crate_type == CrateType::Executable {
+-        let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
+-            "asan/"
+-        } else {
+-            ""
+-        };
++        let prefix =
++            if sess.opts.cg.sanitizer.contains(SanitizerSet::ADDRESS) { "asan/" } else { "" };
+         cmd.arg(format!("--dynamic-linker={}ld.so.1", prefix));
+     }
+ 
+diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs
+index 51cc1ada432..e57a885db5c 100644
+--- a/src/librustc_codegen_ssa/back/symbol_export.rs
++++ b/src/librustc_codegen_ssa/back/symbol_export.rs
+@@ -203,7 +203,7 @@ fn exported_symbols_provider_local(
+         }));
+     }
+ 
+-    if tcx.sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::MEMORY) {
++    if tcx.sess.opts.cg.sanitizer.contains(SanitizerSet::MEMORY) {
+         // Similar to profiling, preserve weak msan symbol during LTO.
+         const MSAN_WEAK_SYMBOLS: [&str; 2] = ["__msan_track_origins", "__msan_keep_going"];
+ 
+diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs
+index 7d69bb983dd..66b5e2f3833 100644
+--- a/src/librustc_codegen_ssa/back/write.rs
++++ b/src/librustc_codegen_ssa/back/write.rs
+@@ -194,7 +194,7 @@ impl ModuleConfig {
+             ),
+             pgo_use: if_regular!(sess.opts.cg.profile_use.clone(), None),
+ 
+-            sanitizer: if_regular!(sess.opts.debugging_opts.sanitizer, SanitizerSet::empty()),
++            sanitizer: if_regular!(sess.opts.cg.sanitizer, SanitizerSet::empty()),
+             sanitizer_recover: if_regular!(
+                 sess.opts.debugging_opts.sanitizer_recover,
+                 SanitizerSet::empty()
+diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs
+index 315d4fa9d47..b188a9f3743 100644
+--- a/src/librustc_mir/transform/inline.rs
++++ b/src/librustc_mir/transform/inline.rs
+@@ -238,7 +238,7 @@ impl Inliner<'tcx> {
+ 
+         // Avoid inlining functions marked as no_sanitize if sanitizer is enabled,
+         // since instrumentation might be enabled and performed on the caller.
+-        if self.tcx.sess.opts.debugging_opts.sanitizer.intersects(codegen_fn_attrs.no_sanitize) {
++        if self.tcx.sess.opts.cg.sanitizer.intersects(codegen_fn_attrs.no_sanitize) {
+             return false;
+         }
+ 
+diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs
+index 1808a0ca59b..2a6e7082031 100644
+--- a/src/librustc_session/config.rs
++++ b/src/librustc_session/config.rs
+@@ -752,7 +752,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
+         }
+     }
+ 
+-    for s in sess.opts.debugging_opts.sanitizer {
++    for s in sess.opts.cg.sanitizer {
+         let symbol = Symbol::intern(&s.to_string());
+         ret.insert((sym::sanitize, Some(symbol)));
+     }
+diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs
+index d05f1a3f34b..3ace7f77a70 100644
+--- a/src/librustc_session/options.rs
++++ b/src/librustc_session/options.rs
+@@ -764,6 +764,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
+         "print remarks for these optimization passes (space separated, or \"all\")"),
+     rpath: bool = (false, parse_bool, [UNTRACKED],
+         "set rpath values in libs/exes (default: no)"),
++    sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
++        "use a sanitizer"),
+     save_temps: bool = (false, parse_bool, [UNTRACKED],
+         "save all temporary output files during compilation (default: no)"),
+     soft_float: bool = (false, parse_bool, [TRACKED],
+@@ -985,8 +987,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
+     // soon.
+     run_dsymutil: bool = (true, parse_bool, [TRACKED],
+         "if on Mac, run `dsymutil` and delete intermediate object files (default: yes)"),
+-    sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
+-        "use a sanitizer"),
+     sanitizer_memory_track_origins: usize = (0, parse_sanitizer_memory_track_origins, [TRACKED],
+         "enable origins tracking in MemorySanitizer"),
+     sanitizer_recover: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
+diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs
+index c006e593e47..beecf41d9e5 100644
+--- a/src/librustc_session/session.rs
++++ b/src/librustc_session/session.rs
+@@ -656,7 +656,7 @@ impl Session {
+         let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly)
+             || self.opts.output_types.contains_key(&OutputType::Bitcode)
+             // AddressSanitizer and MemorySanitizer use alloca name when reporting an issue.
+-            || self.opts.debugging_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY);
++            || self.opts.cg.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY);
+ 
+         self.opts.debugging_opts.fewer_names || !more_names
+     }
+@@ -1018,7 +1018,7 @@ impl Session {
+         self.opts.optimize != config::OptLevel::No
+         // AddressSanitizer uses lifetimes to detect use after scope bugs.
+         // MemorySanitizer uses lifetimes to detect use of uninitialized stack variables.
+-        || self.opts.debugging_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY)
++        || self.opts.cg.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY)
+     }
+ 
+     pub fn mark_attr_known(&self, attr: &Attribute) {
+@@ -1449,20 +1449,34 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
+         "x86_64-fuchsia",
+         "x86_64-unknown-freebsd",
+         "x86_64-unknown-linux-gnu",
++        "x86_64-cros-linux-gnu",
++        "x86_64-pc-linux-gnu",
++    ];
++    const LSAN_SUPPORTED_TARGETS: &[&str] = &[
++        "aarch64-unknown-linux-gnu",
++        "x86_64-apple-darwin",
++        "x86_64-cros-linux-gnu",
++        "x86_64-pc-linux-gnu",
++        "x86_64-unknown-linux-gnu",
++    ];
++    const MSAN_SUPPORTED_TARGETS: &[&str] = &[
++        "aarch64-unknown-linux-gnu",
++        "x86_64-cros-linux-gnu",
++        "x86_64-pc-linux-gnu",
++        "x86_64-unknown-freebsd",
++        "x86_64-unknown-linux-gnu",
+     ];
+-    const LSAN_SUPPORTED_TARGETS: &[&str] =
+-        &["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"];
+-    const MSAN_SUPPORTED_TARGETS: &[&str] =
+-        &["aarch64-unknown-linux-gnu", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"];
+     const TSAN_SUPPORTED_TARGETS: &[&str] = &[
+         "aarch64-unknown-linux-gnu",
+         "x86_64-apple-darwin",
++        "x86_64-cros-linux-gnu",
++        "x86_64-pc-linux-gnu",
+         "x86_64-unknown-freebsd",
+         "x86_64-unknown-linux-gnu",
+     ];
+ 
+     // Sanitizers can only be used on some tested platforms.
+-    for s in sess.opts.debugging_opts.sanitizer {
++    for s in sess.opts.cg.sanitizer {
+         let supported_targets = match s {
+             SanitizerSet::ADDRESS => ASAN_SUPPORTED_TARGETS,
+             SanitizerSet::LEAK => LSAN_SUPPORTED_TARGETS,
+@@ -1477,10 +1491,10 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
+                 supported_targets.join(", ")
+             ));
+         }
+-        let conflicting = sess.opts.debugging_opts.sanitizer - s;
++        let conflicting = sess.opts.cg.sanitizer - s;
+         if !conflicting.is_empty() {
+             sess.err(&format!(
+-                "`-Zsanitizer={}` is incompatible with `-Zsanitizer={}`",
++                "`-Csanitizer={}` is incompatible with `-Csanitizer={}`",
+                 s, conflicting,
+             ));
+             // Don't report additional errors.
diff --git a/dev-lang/rust/files/rust-1.45.2-fix-rpath.patch b/dev-lang/rust/files/rust-1.47.0-fix-rpath.patch
similarity index 100%
rename from dev-lang/rust/files/rust-1.45.2-fix-rpath.patch
rename to dev-lang/rust/files/rust-1.47.0-fix-rpath.patch
diff --git a/dev-lang/rust/files/rust-1.47.0-ld-argv0.patch b/dev-lang/rust/files/rust-1.47.0-ld-argv0.patch
new file mode 100644
index 0000000..ac9005b
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.47.0-ld-argv0.patch
@@ -0,0 +1,56 @@
+Our cross-compilers and related tooling are executed via ld.so trickery, which
+makes /proc/self/exe not point to the right place. If we detect that we're in
+that situation in `current_exe()`, we _should_ have `LD_ARGV0_REL` in an env
+var. This is the path to the _original_ binary, relative to ld.so.
+
+diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs
+index a9cd509..92dd6b9 100644
+--- a/library/std/src/sys/unix/os.rs
++++ b/library/std/src/sys/unix/os.rs
+@@ -327,12 +327,45 @@ pub fn current_exe() -> io::Result<PathBuf> {
+ 
+ #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))]
+ pub fn current_exe() -> io::Result<PathBuf> {
++    let is_ld_so = |p: &crate::path::Path| -> Option<bool> {
++        let parent_dir_name = p.parent()?.file_name()?;
++        if parent_dir_name != OsStr::new("lib") {
++            return Some(false);
++        }
++        // We assume that the `ld.so` path is always valid unicode, since there's... no reason for
++        // it not to be. :)
++        let file_name = p.file_name()?.to_str()?;
++        Some(
++            file_name.starts_with("ld-linux-")
++                && (file_name.ends_with(".so") || file_name.contains(".so.")),
++        )
++    };
++
+     match crate::fs::read_link("/proc/self/exe") {
+         Err(ref e) if e.kind() == io::ErrorKind::NotFound => Err(io::Error::new(
+             io::ErrorKind::Other,
+             "no /proc/self/exe available. Is /proc mounted?",
+         )),
+-        other => other,
++        Err(x) => Err(x),
++        Ok(p) => {
++            // Chrome OS-specific: in some configurations, Rust binaries are invoked through
++            // `ld.so`. In these cases, we want to present the user with the path to the Rust
++            // binary that was invoked.
++            //
++            // Because the ld.so wrappers _generally_ don't want to invoke things with absolute
++            // paths, this is _generally_ a path relative to dirname(ld.so).
++            if is_ld_so(&p) == Some(true) {
++                if let Some(relative_to_ld) = crate::env::var_os("LD_ARGV0_REL") {
++                    let relative_to_ld = PathBuf::from(relative_to_ld);
++                    if relative_to_ld.is_absolute() {
++                        return Ok(relative_to_ld);
++                    }
++                    // safety: is_ld_so checks the parent directory of `p`.
++                    return Ok(p.parent().unwrap().join(relative_to_ld));
++                }
++            }
++            Ok(p)
++        }
+     }
+ }
+ 
diff --git a/dev-lang/rust/files/rust-1.45.2-no-test-on-build.patch b/dev-lang/rust/files/rust-1.47.0-no-test-on-build.patch
similarity index 100%
rename from dev-lang/rust/files/rust-1.45.2-no-test-on-build.patch
rename to dev-lang/rust/files/rust-1.47.0-no-test-on-build.patch
diff --git a/dev-lang/rust/files/rust-1.47.0-no-weak-symbols.patch b/dev-lang/rust/files/rust-1.47.0-no-weak-symbols.patch
new file mode 100644
index 0000000..82b6176
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.47.0-no-weak-symbols.patch
@@ -0,0 +1,80 @@
+This is a slightly-modified cherrypick from llvm. Without this, we see undefined
+symbols in the CQ for amd64-generic ASAN builds. Specifically, we're missing
+__start_asan_globals and __stop_asan_globals.
+
+commit cf5df40c4cf1a53a02ab1d56a488642e3dda8f6d
+Author: Leonard Chan <leonardchan@google.com>
+Date:   Fri Jul 17 15:29:50 2020 -0700
+
+    Revert "[AddressSanitizer] Don't use weak linkage for __{start,stop}_asan_globals"
+    
+    This reverts commit d76e62fdb7a93d9a33f642b6b528f2562cc3c3f4.
+    
+    Reverting since this can lead to linker errors:
+    
+    ```
+    ld.lld: error: undefined hidden symbol: __start_asan_globals
+    ```
+    
+    when using --gc-sections. The linker can discard __start_asan_globals
+    once there are no more `asan_globals` sections left, which can lead to
+    this error if we have external linkages to them.
+
+diff --git a/src/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/src/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+index ee09a4d9db7..7516a64c6a3 100644
+--- a/src/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
++++ b/src/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+@@ -2103,23 +2103,10 @@ void ModuleAddressSanitizer::InstrumentGlobalsELF(
+     SetComdatForGlobalMetadata(G, Metadata, UniqueModuleId);
+   }
+ 
+-  // This should never be called when there are no globals, by the logic that
+-  // computes the UniqueModuleId string, which is "" when there are no globals.
+-  // It's important that this path is only used when there are actually some
+-  // globals, because that means that there will certainly be a live
+-  // `asan_globals` input section at link time and thus `__start_asan_globals`
+-  // and `__stop_asan_globals` symbols will definitely be defined at link time.
+-  // This means there's no need for the references to them to be weak, which
+-  // enables better code generation because ExternalWeakLinkage implies
+-  // isInterposable() and thus requires GOT indirection for PIC.  Since these
+-  // are known-defined hidden/dso_local symbols, direct PIC accesses without
+-  // dynamic relocation are always sufficient.
+-  assert(!MetadataGlobals.empty());
+-  assert(!UniqueModuleId.empty());
+-
+   // Update llvm.compiler.used, adding the new metadata globals. This is
+   // needed so that during LTO these variables stay alive.
+-  appendToCompilerUsed(M, MetadataGlobals);
++  if (!MetadataGlobals.empty())
++    appendToCompilerUsed(M, MetadataGlobals);
+ 
+   // RegisteredFlag serves two purposes. First, we can pass it to dladdr()
+   // to look up the loaded image that contains it. Second, we can store in it
+@@ -2132,18 +2119,15 @@ void ModuleAddressSanitizer::InstrumentGlobalsELF(
+       ConstantInt::get(IntptrTy, 0), kAsanGlobalsRegisteredFlagName);
+   RegisteredFlag->setVisibility(GlobalVariable::HiddenVisibility);
+ 
+-  // Create start and stop symbols.  These are known to be defined by
+-  // the linker, see comment above.
+-  auto MakeStartStopGV = [&](const char *Prefix) {
+-    GlobalVariable *StartStop =
+-        new GlobalVariable(M, IntptrTy, false, GlobalVariable::ExternalLinkage,
+-                           nullptr, Prefix + getGlobalMetadataSection());
+-    StartStop->setVisibility(GlobalVariable::HiddenVisibility);
+-    assert(StartStop->isImplicitDSOLocal());
+-    return StartStop;
+-  };
+-  GlobalVariable *StartELFMetadata = MakeStartStopGV("__start_");
+-  GlobalVariable *StopELFMetadata = MakeStartStopGV("__stop_");
++  // Create start and stop symbols.
++  GlobalVariable *StartELFMetadata = new GlobalVariable(
++      M, IntptrTy, false, GlobalVariable::ExternalWeakLinkage, nullptr,
++      "__start_" + getGlobalMetadataSection());
++  StartELFMetadata->setVisibility(GlobalVariable::HiddenVisibility);
++  GlobalVariable *StopELFMetadata = new GlobalVariable(
++      M, IntptrTy, false, GlobalVariable::ExternalWeakLinkage, nullptr,
++      "__stop_" + getGlobalMetadataSection());
++  StopELFMetadata->setVisibility(GlobalVariable::HiddenVisibility);
+ 
+   // Create a call to register the globals with the runtime.
+   IRB.CreateCall(AsanRegisterElfGlobals,
diff --git a/dev-lang/rust/files/rust-1.47.0-revert-libunwind-build.patch b/dev-lang/rust/files/rust-1.47.0-revert-libunwind-build.patch
new file mode 100644
index 0000000..b338cb9
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.47.0-revert-libunwind-build.patch
@@ -0,0 +1,21 @@
+This reverts commit 21abc88.
+
+Fixes https://github.com/rust-lang/rust/issues/76020
+
+Quote the open upstream CL (https://github.com/rust-lang/rust/issues/76026):
+I'm not sure what exact problem #72746 is supposed to fix, but it's probably incomplete as it breaks the build of 1.46.0 with llvm-libunwind enabled
+
+
+diff --git a/library/unwind/build.rs b/library/unwind/build.rs
+index 31d235cf679..d4bcd2ed4e8 100644
+--- a/library/unwind/build.rs
++++ b/library/unwind/build.rs
+@@ -116,8 +116,6 @@ mod llvm_libunwind {
+             cfg.flag("-fstrict-aliasing");
+             cfg.flag("-funwind-tables");
+             cfg.flag("-fvisibility=hidden");
+-            cfg.flag_if_supported("-fvisibility-global-new-delete-hidden");
+-            cfg.define("_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS", None);
+         }
+ 
+         let mut unwind_sources = vec![
diff --git a/dev-lang/rust/files/rust-1.47.0-sanitizer-supported.patch b/dev-lang/rust/files/rust-1.47.0-sanitizer-supported.patch
new file mode 100644
index 0000000..c47b412
--- /dev/null
+++ b/dev-lang/rust/files/rust-1.47.0-sanitizer-supported.patch
@@ -0,0 +1,21 @@
+Ensure that sanitizer runtimes are built for all our supported x86_64
+platforms.
+
+Now that we patch in our own custom -cros and -pc targets instead
+of falling back to -unknown, we need to add builds for those
+targets as well to allow the linker to find the correct versions
+of the librustc_[almt]san static libraries.
+
+diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
+index 97d9dbdd63f..5a97f635957 100644
+--- a/src/bootstrap/native.rs
++++ b/src/bootstrap/native.rs
+@@ -796,7 +796,7 @@ fn supported_sanitizers(
+         "x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
+         "x86_64-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),
+         "x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]),
+-        "x86_64-unknown-linux-gnu" => {
++        "x86_64-unknown-linux-gnu" | "x86_64-cros-linux-gnu" | "x86_64-pc-linux-gnu" => {
+             common_libs("linux", "x86_64", &["asan", "lsan", "msan", "tsan"])
+         }
+         _ => Vec::new(),
diff --git a/dev-lang/rust/rust-1.45.2-r1.ebuild b/dev-lang/rust/rust-1.47.0.ebuild
similarity index 94%
rename from dev-lang/rust/rust-1.45.2-r1.ebuild
rename to dev-lang/rust/rust-1.47.0.ebuild
index 705cd71..d97877a 100644
--- a/dev-lang/rust/rust-1.45.2-r1.ebuild
+++ b/dev-lang/rust/rust-1.47.0.ebuild
@@ -22,9 +22,9 @@
 fi
 
 
-STAGE0_VERSION="1.$(($(get_version_component_range 2) - 1)).0"
-STAGE0_VERSION_CARGO="0.$(($(get_version_component_range 2))).0"
-STAGE0_DATE="2020-06-04"
+STAGE0_VERSION="1.46.0"
+STAGE0_VERSION_CARGO="0.47.0"
+STAGE0_DATE="2020-08-27"
 RUST_STAGE0_amd64="rustc-${STAGE0_VERSION}-x86_64-unknown-linux-gnu"
 
 DESCRIPTION="Systems programming language from Mozilla"
@@ -56,6 +56,9 @@
 	"${FILESDIR}/${P}-no-test-on-build.patch"
 	"${FILESDIR}/${P}-sanitizer-supported.patch"
 	"${FILESDIR}/${P}-cc.patch"
+	"${FILESDIR}/${P}-revert-libunwind-build.patch"
+	"${FILESDIR}/${P}-ld-argv0.patch"
+	"${FILESDIR}/${P}-no-weak-symbols.patch"
 )
 
 S="${WORKDIR}/${MY_P}-src"
@@ -189,7 +192,8 @@
 }
 
 src_compile() {
-	${EPYTHON} x.py build --config cros-config.toml || die
+	# FIXME: upstream is now using `dist` instead of `build` -- should we do the same?
+	${EPYTHON} x.py build --stage 2 --config cros-config.toml || die
 }
 
 src_install() {
diff --git a/profiles/targets/chromeos/package.provided b/profiles/targets/chromeos/package.provided
index f410186..4bed533 100644
--- a/profiles/targets/chromeos/package.provided
+++ b/profiles/targets/chromeos/package.provided
@@ -134,8 +134,8 @@
 dev-util/boost-build-1.65.0
 
 # We don't need the toolchain itself in the target board.
-dev-lang/rust-1.45.2
 dev-lang/rust-1.46.0
+dev-lang/rust-1.47.0
 
 # We sometimes need ruby for building, but don't yet care about targets.
 dev-lang/ruby-1.9.4
diff --git a/virtual/rust/rust-1.45.2.ebuild b/virtual/rust/rust-1.47.0.ebuild
similarity index 100%
rename from virtual/rust/rust-1.45.2.ebuild
rename to virtual/rust/rust-1.47.0.ebuild