Skip to content

Commit

Permalink
Add Windows rustflags (#40)
Browse files Browse the repository at this point in the history
* Add Windows rustflags

This change adds a cargo config.toml with Windows specific rustflags to enable control flow guard, static C runtime, and shadow stack link args. See comments in the config.toml file.

* Include msvc_spectre_libs dependency

* Try using windows-latest

* Revert "Try using windows-latest"

This reverts commit be4e0bb.

* Fix environment variable override in CI

* Update comment
  • Loading branch information
swernli authored Feb 15, 2023
1 parent c67116e commit 029fe83
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -Ccontrol-flow-guard: Enable Control Flow Guard (https://learn.microsoft.com/en-us/windows/win32/secbp/control-flow-guard).
# -Ctarget-feature=+crt-static: Statically link the CRT (required to link the spectre-mitigated CRT).
# -Clink-args=/DYNAMICBASE /CETCOMPAT: Enable "shadow stack" (https://docs.microsoft.com/en-us/cpp/build/reference/cetcompat)
[target.'cfg(target_os = "windows")']
rustflags = ["-Ccontrol-flow-guard", "-Ctarget-feature=+crt-static", "-Clink-args=/DYNAMICBASE /CETCOMPAT"]
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- feature/*

env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
CARGO_INCREMENTAL: 0

jobs:
Expand All @@ -32,7 +32,7 @@ jobs:
run: cargo fmt -v --all -- --check

- name: cargo clippy
run: cargo clippy -vv --all-targets
run: cargo clippy -vv --all-targets -- -D warnings

- name: cargo doc
run: cargo doc -vv --all --no-deps
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ features = ["llvm14-0"]
qir-stdlib = { path = "../stdlib", features = ["range-support"] }
qir-backend = { path = "../backend" }
clap = "4.1.4"
msvc_spectre_libs = { version = "0.1", features = ["error"] }

0 comments on commit 029fe83

Please sign in to comment.