about summary refs log tree commit diff
path: root/src/bootstrap/builder.rs
diff options
context:
space:
mode:
authorAndrew Paverd <andrew.paverd@microsoft.com>2020-01-28 14:29:44 +0000
committerAndrew Paverd <andrew.paverd@microsoft.com>2020-02-10 19:26:25 +0000
commit87df124ba77a2ce64e11782bddeadae85d26603d (patch)
treea6944b2647d643cc3a1833c006b4a55686d0e44f /src/bootstrap/builder.rs
parentc58e09f138075ce6b3079f41f9c2f192a15b896c (diff)
downloadrust-87df124ba77a2ce64e11782bddeadae85d26603d.tar.gz
rust-87df124ba77a2ce64e11782bddeadae85d26603d.zip
Enable Control Flow Guard in rustbuild
Diffstat (limited to 'src/bootstrap/builder.rs')
-rw-r--r--src/bootstrap/builder.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index d9c894aa9c6..0737d017df2 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1111,6 +1111,20 @@ impl<'a> Builder<'a> {
             );
         }
 
+        // If Control Flow Guard is enabled, pass the `control_flow_guard=checks` flag to rustc
+        // when compiling the standard library, since this might be linked into the final outputs
+        // produced by rustc. Since this mitigation is only available on Windows, only enable it
+        // for the standard library in case the compiler is run on a non-Windows platform.
+        // This is not needed for stage 0 artifacts because these will only be used for building
+        // the stage 1 compiler.
+        if cfg!(windows)
+            && mode == Mode::Std
+            && self.config.control_flow_guard
+            && compiler.stage >= 1
+        {
+            rustflags.arg("-Zcontrol_flow_guard=checks");
+        }
+
         // For `cargo doc` invocations, make rustdoc print the Rust version into the docs
         cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version());