Repository: rust
Issue: Tracking Issue for LLVM Control Flow Integrity (CFI) Support for Rust
Labels: A-sanitizers,C-tracking-issue,PG-exploit-mitigations

<!--
NOTE: For library features, please use the "Library Tracking Issue" template instead.

Thank you for creating a tracking issue! 📜 Tracking issues are for tracking a
feature from implementation to stabilisation. Make sure to include the relevant
RFC for the feature if it has one. Otherwise provide a short summary of the
feature and link any relevant PRs or issues, and remove any sections that are
not relevant to the feature.

Remember to add team labels to the tracking issue.
For a language team feature, this would e.g., be `T-lang`.
Such a feature should also be labeled with e.g., `F-my_feature`.
This label is used to associate issues (e.g., bugs and design questions) to the feature.
-->

<!--
This is a tracking issue for the RFC "XXX" (rust-lang/rfcs#NNN).
The feature gate for the issue is `#![feature(FFF)]`.
-->
This is a tracking issue for the LLVM Control Flow Integrity (CFI) Support for Rust project (see the [design document](https://rcvalle.com/docs/rust-cfi-design-doc.pdf)).

<!--
### About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however *not* meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
-->

### Steps
<!--
Include each step required to complete the feature. Typically this is a PR
implementing a feature, followed by a PR that stabilises the feature. However
for larger features an implementation could be broken up into multiple PRs.
-->

<!--
- [ ] Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
      instructions?)
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
-->

LLVM CFI support for Rust work will be implemented in these steps:

 - [x] Add option to the Rust compiler driver and frontend. (#89652)
 - [x] Add support for emitting type metadata and checks to the Rust compiler code generation. (#89652)
 - [x] Implement Rust-compiled code only LLVM CFI support by using Rust-specific type metadata identifiers. (#89652, #95548)
 - [x] Define type metadata identifiers for cross-language LLVM CFI support. (See the [design document](https://rcvalle.com/docs/rust-cfi-design-doc.pdf).)
 - [x] Change initial implementation to use the defined type metadata identifiers for cross-language LLVM CFI support. (#95548, rust-lang/rfcs#3296, #105452)
 - [x] Create documentation and tests. (#89652, rust-lang/rustc-dev-guide#1234, #95548, #105452)

[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs

### Unresolved Questions
<!--
Include any open questions that need to be answered before the feature can be
stabilised.
-->

- Should integers always be normalized?

### Implementation history

<!--
Include a list of all the PRs that were involved in implementing the feature.
-->

 1. #89652
 2. rust-lang/rustc-dev-guide#1234
 3. #95548
 4. rust-lang/rfcs#3296
 5. ![octicon-git-merge-merged](https://user-images.githubusercontent.com/3988004/232912454-739e4559-f2d1-4e8c-80f8-99073386902e.png) **[[LLVM] Add CFI integer types normalization to Clang compiler](https://reviews.llvm.org/D139395)**
 6. #105452

### Bonus implementation

 1. #105109
 2. rust-lang/rustc-dev-guide#1529

### Known issues

**https://github.com/rust-lang/rust/issues?q=is:open+label:PG-exploit-mitigations+-label:C-tracking-issue+CFI**