Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Control Flow Guard on Windows. #68180

Merged
merged 1 commit into from Feb 1, 2020

Conversation

@ajpaverd
Copy link
Contributor

ajpaverd commented Jan 13, 2020

LLVM now supports Windows Control Flow Guard (CFG): llvm/llvm-project@d157a9b
This patch adds support for rustc to emit the required LLVM module flags to enable CFG metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 13, 2020

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthewjasper (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 13, 2020

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-13T13:47:29.6080386Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-13T13:47:29.6091988Z ##[command]git config gc.auto 0
2020-01-13T13:47:29.6095286Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-13T13:47:29.6097530Z ##[command]git config --get-all http.proxy
2020-01-13T13:47:29.6100476Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68180/merge:refs/remotes/pull/68180/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

src/librustc_codegen_ssa/back/linker.rs Outdated Show resolved Hide resolved
src/librustc_session/options.rs Outdated Show resolved Hide resolved
src/librustc_session/options.rs Outdated Show resolved Hide resolved
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 13, 2020

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-13T15:57:32.7350355Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-13T15:57:32.7360960Z ##[command]git config gc.auto 0
2020-01-13T15:57:32.7363750Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-13T15:57:32.7365883Z ##[command]git config --get-all http.proxy
2020-01-13T15:57:32.7368451Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68180/merge:refs/remotes/pull/68180/merge
---
2020-01-13T16:04:39.8690992Z     Checking rustc_resolve v0.0.0 (/checkout/src/librustc_resolve)
2020-01-13T16:04:42.7249528Z     Checking rustc_privacy v0.0.0 (/checkout/src/librustc_privacy)
2020-01-13T16:04:43.1766749Z     Checking rustc_plugin_impl v0.0.0 (/checkout/src/librustc_plugin_impl)
2020-01-13T16:04:43.3331896Z     Checking rustc_codegen_ssa v0.0.0 (/checkout/src/librustc_codegen_ssa)
2020-01-13T16:04:44.1411270Z error[E0609]: no field `control_flow_guard` on type `rustc::rustc_session::config::CodegenOptions`
2020-01-13T16:04:44.1412373Z     --> src/librustc_codegen_ssa/back/link.rs:1297:21
2020-01-13T16:04:44.1412850Z      |
2020-01-13T16:04:44.1413429Z 1297 |     if sess.opts.cg.control_flow_guard.is_some() {
2020-01-13T16:04:44.1414388Z      |
2020-01-13T16:04:44.1414388Z      |
2020-01-13T16:04:44.1415118Z      = note: available fields are: `ar`, `linker`, `link_arg`, `link_args`, `link_dead_code` ... and 34 others
2020-01-13T16:04:50.3124930Z error: aborting due to previous error
2020-01-13T16:04:50.3128561Z 
2020-01-13T16:04:50.3136682Z For more information about this error, try `rustc --explain E0609`.
2020-01-13T16:04:50.3211485Z error: could not compile `rustc_codegen_ssa`.
2020-01-13T16:04:50.3211485Z error: could not compile `rustc_codegen_ssa`.
2020-01-13T16:04:50.3240390Z warning: build failed, waiting for other jobs to finish...
2020-01-13T16:05:06.2488826Z error: build failed
2020-01-13T16:05:06.2509124Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "-Zconfig-profile" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--color" "always" "--features" " llvm" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
2020-01-13T16:05:06.2522441Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
2020-01-13T16:05:06.2523120Z Build completed unsuccessfully in 0:05:21
2020-01-13T16:05:06.2574211Z == clock drift check ==
2020-01-13T16:05:06.2587231Z   local time: Mon Jan 13 16:05:06 UTC 2020
2020-01-13T16:05:06.2587231Z   local time: Mon Jan 13 16:05:06 UTC 2020
2020-01-13T16:05:06.5233919Z   network time: Mon, 13 Jan 2020 16:05:06 GMT
2020-01-13T16:05:06.5238393Z == end clock drift check ==
2020-01-13T16:05:06.8740093Z 
2020-01-13T16:05:06.8834248Z ##[error]Bash exited with code '1'.
2020-01-13T16:05:06.8878701Z ##[section]Starting: Checkout
2020-01-13T16:05:06.8880294Z ==============================================================================
2020-01-13T16:05:06.8880342Z Task         : Get sources
2020-01-13T16:05:06.8880397Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@ajpaverd ajpaverd force-pushed the ajpaverd:cfguard-rust branch from 8cafeb7 to 885f977 Jan 13, 2020
Copy link
Contributor

bjorn3 left a comment

Please remove yet from not yet supported.

src/librustc_codegen_ssa/back/linker.rs Outdated Show resolved Hide resolved
src/librustc_codegen_ssa/back/linker.rs Outdated Show resolved Hide resolved
src/librustc_codegen_ssa/back/linker.rs Outdated Show resolved Hide resolved
src/librustc_session/config.rs Outdated Show resolved Hide resolved
@ajpaverd ajpaverd requested a review from jonas-schievink Jan 17, 2020
@matthewjasper

This comment has been minimized.

Copy link
Contributor

matthewjasper commented Jan 17, 2020

r? @nagisa

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 23, 2020

☔️ The latest upstream changes (presumably #68474) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

nagisa left a comment

r=me sans some cosmetic nits.

#[derive(Clone, Hash, Debug)]
pub enum CFGuard {
/// Emit Control Flow Guard metadata but no checks.
Nochecks,

This comment has been minimized.

Copy link
@nagisa

nagisa Jan 26, 2020

Contributor

Please rename this variant to MetadataOnly or something else along the lines. Nochecks seems to imply CFG is disabled entirely, which it isn’t.

This comment has been minimized.

Copy link
@ajpaverd

ajpaverd Jan 27, 2020

Author Contributor

The nochecks variant was intended to match the corresponding -cfguard,nochecks option in Clang (https://reviews.llvm.org/rL339420). Should we keep this terminology for consistency?

The intention is really to convey that this is "Control Flow Guard without any run-time checks". Is there somewhere in the documentation I could explain this?

This comment has been minimized.

Copy link
@nagisa

nagisa Jan 27, 2020

Contributor

I guess you can keep it in that case. Just s/Nochecks/NoChecks/. There are a couple of places for this documentation to go, including in the manpages and the unstable book.

src/librustc_session/options.rs Outdated Show resolved Hide resolved
src/librustc_session/options.rs Outdated Show resolved Hide resolved
src/librustc_session/options.rs Outdated Show resolved Hide resolved
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 27, 2020

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-27T15:18:03.4052000Z ========================== Starting Command Output ===========================
2020-01-27T15:18:03.4054599Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/900a3905-9dfa-4ff9-88bf-554e55e5563c.sh
2020-01-27T15:18:03.4054761Z 
2020-01-27T15:18:03.4058061Z ##[section]Finishing: Disable git automatic line ending conversion
2020-01-27T15:18:03.4063731Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68180/merge to s
2020-01-27T15:18:03.4065317Z Task         : Get sources
2020-01-27T15:18:03.4065353Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-27T15:18:03.4065431Z Version      : 1.0.0
2020-01-27T15:18:03.4065466Z Author       : Microsoft
---
2020-01-27T15:18:04.1845464Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-27T15:18:04.1939013Z ##[command]git config gc.auto 0
2020-01-27T15:18:04.1997939Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-27T15:18:04.2054176Z ##[command]git config --get-all http.proxy
2020-01-27T15:18:04.2190961Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68180/merge:refs/remotes/pull/68180/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@ajpaverd ajpaverd force-pushed the ajpaverd:cfguard-rust branch from 592b3dd to 33df727 Jan 27, 2020
src/librustc_session/config.rs Outdated Show resolved Hide resolved
@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Jan 28, 2020

@bors r+

Thanks!

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2020

📌 Commit 3b91aad has been approved by nagisa

@ajpaverd

This comment has been minimized.

Copy link
Contributor Author

ajpaverd commented Jan 28, 2020

@bors r+

Thanks!

Thanks @nagisa! Quick question: should I squash the commits in this PR and rebase onto master to avoid including the merge commit?

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2020

@ajpaverd: 🔑 Insufficient privileges: Not in reviewers

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Jan 28, 2020

Sure, please do squash.

This patch enables rustc to emit the required LLVM module flags to enable Control Flow Guard metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2020

⌛️ Testing commit 3b91aad with merge 176b807...

bors added a commit that referenced this pull request Jan 28, 2020
Add support for Control Flow Guard on Windows.

LLVM now supports Windows Control Flow Guard (CFG): llvm/llvm-project@d157a9b
This patch adds support for rustc to emit the required LLVM module flags to enable CFG metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.
@ajpaverd ajpaverd force-pushed the ajpaverd:cfguard-rust branch from 3b91aad to c0744e1 Jan 28, 2020
@ajpaverd

This comment has been minimized.

Copy link
Contributor Author

ajpaverd commented Jan 30, 2020

Sure, please do squash.

Did my squash+rebase inadvertently interrupt bors' testing and merging?

@bjorn3

This comment has been minimized.

Copy link
Contributor

bjorn3 commented Jan 30, 2020

Did my squash+rebase inadvertently interrupt bors' testing and merging?

Yes, any push will prevent a PR from being merged before someone approves it again.

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Jan 30, 2020

@bors r+ Sorry didn’t notice the squash. Thanks for doing it.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 30, 2020

📌 Commit c0744e1 has been approved by nagisa

bors added a commit that referenced this pull request Jan 30, 2020
Add support for Control Flow Guard on Windows.

LLVM now supports Windows Control Flow Guard (CFG): llvm/llvm-project@d157a9b
This patch adds support for rustc to emit the required LLVM module flags to enable CFG metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 30, 2020

⌛️ Testing commit c0744e1 with merge 4924b66...

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 30, 2020

💥 Test timed out

@ajpaverd

This comment has been minimized.

Copy link
Contributor Author

ajpaverd commented Feb 1, 2020

Is there a way to figure out what caused the bors tests to time out (the logs just seem to say the operation was cancelled)?

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Feb 1, 2020

Looks like it may have been cancelled manually (https://dev.azure.com/rust-lang/rust/_build/results?buildId=19568&view=results) probably to give way to something more important. Lets just retry for now. Thanks for bringing it to my attention.

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2020

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: #68698
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2020

📌 Commit c0744e1 has been approved by nagisa

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2020

⌛️ Testing commit c0744e1 with merge 64184a3...

bors added a commit that referenced this pull request Feb 1, 2020
Add support for Control Flow Guard on Windows.

LLVM now supports Windows Control Flow Guard (CFG): llvm/llvm-project@d157a9b
This patch adds support for rustc to emit the required LLVM module flags to enable CFG metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 1, 2020

☀️ Test successful - checks-azure
Approved by: nagisa
Pushing 64184a3 to master...

@bors bors added the merged-by-bors label Feb 1, 2020
@bors bors merged commit c0744e1 into rust-lang:master Feb 1, 2020
5 checks passed
5 checks passed
homu Test successful
Details
pr Build #20200128.30 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Feb 11, 2020
…Simulacrum

Enable Control Flow Guard in rustbuild

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

r? @nagisa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.