Repository: rust
Issue: Compiling project makes rustc emit STATUS_ILLEGAL_INSTRUCTION
Labels: I-crash,A-LLVM,T-compiler,O-windows-msvc,C-bug

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I was trying to compile [this 3rd party project](https://github.com/upsuper/rust-cheatsheet) with `cargo build` when I received an `exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION`.

Depending on what Rust version I use I get slightly different errors, but I can reproduce the behavior as follows:


| Command | Version | Result |
|---|---|---|
| `cargo build` | 1.46 | `STATUS_ILLEGAL_INSTRUCTION` |
| `cargo +beta build` |  1.48.0-beta | `STATUS_STACK_BUFFER_OVERRUN` |
| `cargo +nightly build` |  2020-10-06 | `STATUS_STACK_BUFFER_OVERRUN`. |
| `cargo build --release` | 1.46 | Compiles. |
| `cargo +beta build --release` |  1.48.0-beta | Compiles. |
| `cargo +nightly build --release` |  2020-10-06 | Compiles. |
| `cargo check` | 1.46 | Works and reports no issues. |

In other words `--release` builds are fine, while debug builds fail. 

A failing build that produces a `STATUS_STACK_BUFFER_OVERRUN` looks like this:

```
PS D:\Development\Source\_thirdparty\rust-cheatsheet> cargo +nightly build
   Compiling proc-macro2 v1.0.19
   Compiling unicode-xid v0.2.1
   Compiling syn v1.0.38
   Compiling memchr v2.3.3
   Compiling version_check v0.1.5
   Compiling serde_derive v1.0.115
   Compiling bytes v0.5.6
   Compiling v_escape v0.12.1
   Compiling serde v1.0.115
   Compiling v_htmlescape v0.10.0
   Compiling bitflags v1.2.1
   Compiling linked-hash-map v0.5.3
   Compiling cfg-if v0.1.10
   Compiling dtoa v0.4.6
   Compiling either_n v0.2.0
   Compiling lazy_static v1.4.0
   Compiling yaml-rust v0.4.4
   Compiling nom v4.2.3
   Compiling buf-min v0.1.1
   Compiling combine v4.2.1
   Compiling quote v1.0.7
   Compiling v_escape_derive v0.8.1
   Compiling serde_yaml v0.8.13
   Compiling cheatsheet-gen v0.1.0 (D:\Development\Source\_thirdparty\rust-cheatsheet)
error: Stream Error: The stream is too short to perform the requested operation.
error: could not compile `cheatsheet-gen`

Caused by:
  process didn't exit successfully: `rustc --crate-name cheatsheet_gen --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=db2d8889f40e140f --out-dir D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps -C incremental=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\incremental -L dependency=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps --extern bitflags=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libbitflags-b3aa381b8c8a158c.rlib --extern combine=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libcombine-a4a9f1aaa590fa13.rlib --extern either_n=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libeither_n-8a7740130419f71a.rlib --extern lazy_static=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\liblazy_static-c07407d0f2563334.rlib --extern serde=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libserde-a435d4a09a21010e.rlib --extern serde_yaml=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libserde_yaml-ee801d4aeb4bdd7f.rlib --extern v_htmlescape=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libv_htmlescape-a10e79e7a0db13f9.rlib` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
```

A build that fails with `STATUS_ILLEGAL_INSTRUCTION` looks similar but outputs this instead at the end:

```
 `rustc --crate-name cheatsheet_gen --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=db2d8889f40e140f --out-dir D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps -C incremental=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\incremental -L dependency=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps --extern bitflags=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libbitflags-4b4428b676fd67d4.rlib --extern combine=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libcombine-70407e7c92f08ddf.rlib --extern either_n=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libeither_n-7aad0be053028d4d.rlib --extern lazy_static=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\liblazy_static-3058c6f12d44e685.rlib --extern serde=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libserde-7dcd74385906b4ee.rlib --extern serde_yaml=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libserde_yaml-0e470368d8293784.rlib --extern v_htmlescape=D:\Development\Source\_thirdparty\rust-cheatsheet\target\debug\deps\libv_htmlescape-fe2fd1af7676b224.rlib` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)
```

Running `rustc --version --verbose` for my latest stable gives

```
rustc 1.46.0 (04488afe3 2020-08-24)
binary: rustc
commit-hash: 04488afe34512aa4c33566eb16d8c912a3ae04f9
commit-date: 2020-08-24
host: x86_64-pc-windows-msvc
release: 1.46.0
LLVM version: 10.0
```

Additional Info
- This happens on a Windows 10 system with a 9900k CPU
- Enabling `RUST_BACKTRACE` does not really change anything about that behavior and provides no further insights. 
- `cargo clean` does not change anything either
- The rest of my Rust setup is 'generally working' and compiles other projects without issues