about summary refs log tree commit diff
path: root/src/bootstrap/builder.rs
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-02-11 16:36:57 +0100
committerGitHub <noreply@github.com>2020-02-11 16:36:57 +0100
commitc8c2b2bc547f4fc0e36ced79cd7f64d514cc5329 (patch)
treed73400050270e15af3d04ed364ecb8ffce0f87f7 /src/bootstrap/builder.rs
parentb6024c47663c92f43a125bcafd7f6fffd058d2c1 (diff)
parent87df124ba77a2ce64e11782bddeadae85d26603d (diff)
downloadrust-c8c2b2bc547f4fc0e36ced79cd7f64d514cc5329.tar.gz
rust-c8c2b2bc547f4fc0e36ced79cd7f64d514cc5329.zip
Rollup merge of #68824 - ajpaverd:cfguard-rustbuild, r=Mark-Simulacrum
Enable Control Flow Guard in rustbuild

Now that Rust supports Control Flow Guard (#68180), add a config.toml option to build the standard library with CFG enabled.

r? @nagisa
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 d0eed3f12d1..e4b57cddfb8 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1135,6 +1135,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());