Skip to content

Commit 6f793b3

Browse files
committed
Update text and book
1 parent ec8c25c commit 6f793b3

File tree

15 files changed

+384
-0
lines changed

15 files changed

+384
-0
lines changed

.github/workflows/book.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
# This workflow is responsible for building and releasing the book.
5+
# It should only run when there has been a change to the book files
6+
# or via manual trigger.
7+
8+
name: Build Book
9+
on:
10+
workflow_dispatch:
11+
pull_request:
12+
paths:
13+
- 'doc/**'
14+
push:
15+
paths:
16+
- 'doc/**'
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install mdbook
26+
run: |
27+
cargo install mdbook --version "^0.4" --locked
28+
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
29+
30+
- name: Install linkchecker
31+
run: cargo install mdbook-linkcheck --version "^0.7" --locked
32+
33+
- name: Build Documentation
34+
run: mdbook build doc
35+
36+
- name: Upload book
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: book/html
40+
retention-days: "2"
41+
42+
deploy:
43+
needs: build
44+
runs-on: ubuntu-latest
45+
if: ${{ github.event_name == 'push' && startsWith('refs/heads/main', github.ref) }}
46+
47+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
48+
permissions:
49+
pages: write # to deploy to Pages
50+
id-token: write # to verify source
51+
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
56+
steps:
57+
- name: Deploy to GitHub Pages
58+
id: deployment
59+
uses: actions/deploy-pages@v4

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Rust std-lib verification
2+
3+
This repository is a fork of the official Rust programming
4+
language repository, created solely to verify the Rust standard
5+
library. It should not be used as an alternative to the official
6+
Rust releases.
7+
8+
The goal is to have a verified [Rust standard library](https://doc.rust-lang.org/std/) and prove that it is safe.
9+
1. Contributing to the core mechanism of verifying the rust standard library
10+
2. Creating new techniques to perform scalable verification
11+
3. Apply techniques to verify previously unverified parts of the standard library.
12+
13+
## [Kani](https://github.com/model-checking/kani)
14+
15+
The Kani Rust Verifier is a bit-precise model checker for Rust.
16+
Kani verifies:
17+
* Memory safety (e.g., null pointer dereferences)
18+
* User-specified assertions (i.e `assert!(...)`)
19+
* The absence of panics (eg., `unwrap()` on `None` values)
20+
* The absence of some types of unexpected behavior (e.g., arithmetic overflows).
21+
22+
You can find out more about Kani from the [Kani book](https://model-checking.github.io/kani/) or the [Kani repository on Github](https://github.com/model-checking/kani).
23+
24+
## Contact
25+
26+
For questions, suggestions or feedback, feel free to open an [issue here](https://github.com/model-checking/verify-rust-std/issues).
27+
28+
## Security
29+
30+
See [SECURITY](https://github.com/model-checking/kani/security/policy) for more information.
31+
32+
## License
33+
34+
### Kani
35+
36+
Kani is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
37+
See [LICENSE-APACHE](https://github.com/model-checking/kani/blob/main/LICENSE-APACHE) and [LICENSE-MIT](https://github.com/model-checking/kani/blob/main/LICENSE-MIT) for details.
38+
39+
## Rust
40+
41+
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
42+
43+
See [the Rust repository](https://github.com/rust-lang/rust) for details.

doc/book.toml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[book]
4+
title = "Verify Rust Std Lib"
5+
description = "How & What?"
6+
authors = ["Kani Developers"]
7+
language = "en"
8+
multilingual = false
9+
10+
[build]
11+
build-dir = "../book"
12+
13+
[output.html]
14+
site-url = "/verify-rust-std/"
15+
git-repository-url = "https://github.com/model-checking/verify-rust-std"
16+
edit-url-template = "https://github.com/model-checking/verify-rust-std/edit/main/doc/{path}"
17+
18+
[output.html.playground]
19+
runnable = false
20+
21+
[output.linkcheck]
22+
23+
24+
[rust]
25+
edition = "2021"

doc/src/SUMMARY.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Verify Rust Std Lib
2+
3+
[Introduction](intro.md)
4+
5+
- [General Rules](./general-rules.md)
6+
- [Challenge Template](./template.md)
7+
8+
- [Verification Tools](./tools.md)
9+
- [Kani](./tools/kani.md)
10+
11+
12+
---
13+
14+
# Challenges
15+
- [Coming soon](./todo.md)

doc/src/general-rules.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# General Rules
2+
3+
## Terms / Concepts
4+
5+
**Verification Target:** [Our repository](https://github.com/model-checking/verify-rust-std) is a fork of the original Rust repository,
6+
and we kept a copy of the Rust standard library inside the `library/` folder that shall be used as the verification target for all our challenges.
7+
We will periodically update the `library/` folder to track newer versions of the [official Rust standard library](https://github.com/rust-lang/rust/).
8+
NOTE: This work is not officially affiliated, or endorsed by the Rust project or Rust Foundation.
9+
**Challenges:** Each individual verification effort will have a
10+
tracking issue where contributors can add comments and ask clarification questions.
11+
You can find the list of [open challenges here](https://github.com/model-checking/verify-rust-std/labels/Challenge).
12+
13+
**Solutions:** Solutions to a problem should be submitted as a single Pull Request (PR) to this repository.
14+
The solution should run as part of the CI.
15+
See more details about [minimum requirements for each solution](general-rules.md#solution-requirements).
16+
17+
18+
## Basic Workflow
19+
20+
1. A verification effort will be published in the repository with
21+
appropriate details, and a tracking issue labeled with “Challenge”
22+
will be opened, so it can be used for clarifications and questions, as
23+
well as to track the status of the challenge.
24+
25+
2. Participants should create a fork of the repository where they will implement their proposed solution.
26+
3. Once they submit their solution for analysis, participants should create a PR against the repository for analysis.
27+
Please make sure your solution meets [the minimum requirements described here](general-rules.md#solution-requirements).
28+
4. Each contribution will be reviewed on a first come, first served basis.
29+
Acceptance will be based on a review by a committee.
30+
5. Once approved by the review committee, the change will be merged into the repository.
31+
32+
## Solution Requirements
33+
34+
A proposed solution to a verification problem will only **be reviewed** if all the minimum requirements below are met:
35+
36+
* Each contribution or attempt should be submitted via a pull request to be analyzed by reviewers.
37+
* By submitting the solution, participants confirm that they can use, modify, copy, and redistribute their contribution,
38+
under the terms of their choice.
39+
* The contribution must be automated and should be checked and pass as part of the PR checks.
40+
* All tools used by the solution must be in [the list of accepted tools](tools.md#approved-tools),
41+
and previously integrated in the repository.
42+
If that is not the case, please submit a separate [tool application first](todo.md).
43+
* There is no restriction on the number of contributors for a solution.
44+
Make sure you have the rights to submit your solution and that all contributors are properly mentioned.
45+
* The solution cannot impact the runtime logic of the standard library unless the change is proposed and incorporated
46+
into the Rust standard library.
47+
48+
Any exception to these requirements will only be considered if it is specified as part of the acceptance criteria of the
49+
challenged being solved.
50+
51+
## Call for Challenges
52+
53+
The goal of the effort is to enable the verification of the entire Rust standard library.
54+
The type of obstacles users face may depend on which part of the standard library you would like to verify. Thus, our challenges are developed with the target of verifying a specific section of the standard library or strengthening existing verification.
55+
56+
Everyone is welcome to submit new challenge proposals for review by our committee.
57+
Follow the following steps to create a new proposal:
58+
59+
1. Create a tracking issue using the Issue template [Challenge Proposal](todo.md) for your challenge.
60+
2. In your fork of this repository do the following:
61+
1. Copy the template file (`book/src/challenge_template.md`) to `book/src/challenges/<ID_NUMBER>-<challenge-name>.md`.
62+
2. Fill in the details according to the template instructions.
63+
3. Add a link to the new challenge inside `book/src/SUMMARY.md`
64+
4. Submit a pull request.
65+
3. Address any feedback in the pull request.
66+
4. If approved, we will publish your challenge and add the “Challenge” label to the tracking issue.
67+
68+
## Tool Applications
69+
70+
Solutions must be automated using one of the tools previously approved and listed [here](tools.md#approved-tools):
71+
72+
* Any new tool that participants want to enable will require an application using the Issue template [Tool application](todo.md).
73+
* The tool will be analyzed by an independent committee consisting of members from the Rust open-source developers and AWS
74+
* A new tool application should clearly specify the differences to existing techniques and provide sufficient background
75+
of why this is needed.
76+
* The tool application should also include mechanisms to audit its implementation and correctness.
77+
* Once the tool is approved, the participant needs to create a PR that creates a new action that runs the
78+
std library verification using the new tool, as well as an entry to the “Approved Tools” section of this book.
79+
* Once the PR is merged, the tool is considered integrated.
80+
* The repository will be updated periodically, which can impact the tool capacity to analyze the new version of the repository.
81+
I.e., the action may no longer pass after an update.
82+
This will not impact the approval status of the tool, however,
83+
new solutions that want to employ the tool may need to ensure the action is passing first.

doc/src/intro.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Verify Rust Standard Library Effort
2+
3+
The Verify Rust Standard Library effort is an ongoing investment that
4+
targets the verification of the [Rust standard
5+
library](https://doc.rust-lang.org/std/). The goal of this is
6+
to provide automated verification that can be used to verify that a
7+
given Rust standard library implementation is safe.
8+
9+
Efforts are largely classified in the following areas:
10+
11+
1. Contributing to the core mechanism of verifying the rust standard library
12+
2. Creating new techniques to perform scalable verification
13+
3. Apply techniques to verify previously unverified parts of the standard library.
14+
15+
16+
We encourage everyone to watch this repository to be notified of any
17+
changes.

doc/src/template.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Challenge Template

doc/src/todo.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 🚧 Under Construction 🚧
2+
3+
This section is still under construction. Please check it back again soon and we’ll have more details for you.

doc/src/tools.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Verification Tools
2+
3+
The verification tool ecosystem for Rust is rapidly growing, and we welcome the usage of different tools to solve our challenges.
4+
In this chapter, you can find a list of tools that have already been approved for new solutions,
5+
what is their CI current status, as well as more details on how to use them.
6+
7+
If the tool you would like to add a new tool to the list of tool applications,
8+
please see the [Tool Application](general-rules.md#tool-applications) section.
9+
10+
## Approved tools:
11+
12+
| Tool | CI Status |
13+
|-----------|-----------|
14+
| Kani | TODO |
15+
16+
17+
18+

doc/src/tools/kani.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Kani Rust Verifier
2+
3+
The Kani Rust Verifier is a bit-precise model checker for Rust.
4+
This page will give more details on how to use Kani to verify the standard library.
5+
You can find more informations about how to install and use Kani in the
6+
[Kani book](https://model-checking.github.io/kani/).
7+

library/portable-simd/README.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# The Rust standard library's portable SIMD API
2+
![Build Status](https://github.com/rust-lang/portable-simd/actions/workflows/ci.yml/badge.svg?branch=master)
3+
4+
Code repository for the [Portable SIMD Project Group](https://github.com/rust-lang/project-portable-simd).
5+
Please refer to [CONTRIBUTING.md](./CONTRIBUTING.md) for our contributing guidelines.
6+
7+
The docs for this crate are published from the main branch.
8+
You can [read them here][docs].
9+
10+
If you have questions about SIMD, we have begun writing a [guide][simd-guide].
11+
We can also be found on [Zulip][zulip-project-portable-simd].
12+
13+
If you are interested in support for a specific architecture, you may want [stdarch] instead.
14+
15+
## Hello World
16+
17+
Now we're gonna dip our toes into this world with a small SIMD "Hello, World!" example. Make sure your compiler is up to date and using `nightly`. We can do that by running
18+
19+
```bash
20+
rustup update -- nightly
21+
```
22+
23+
or by setting up `rustup default nightly` or else with `cargo +nightly {build,test,run}`. After updating, run
24+
```bash
25+
cargo new hellosimd
26+
```
27+
to create a new crate. Finally write this in `src/main.rs`:
28+
```rust
29+
#![feature(portable_simd)]
30+
use std::simd::f32x4;
31+
fn main() {
32+
let a = f32x4::splat(10.0);
33+
let b = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
34+
println!("{:?}", a + b);
35+
}
36+
```
37+
38+
Explanation: We construct our SIMD vectors with methods like `splat` or `from_array`. Next, we can use operators like `+` on them, and the appropriate SIMD instructions will be carried out. When we run `cargo run` you should get `[11.0, 12.0, 13.0, 14.0]`.
39+
40+
## Supported vectors
41+
42+
Currently, vectors may have up to 64 elements, but aliases are provided only up to 512-bit vectors.
43+
44+
Depending on the size of the primitive type, the number of lanes the vector will have varies. For example, 128-bit vectors have four `f32` lanes and two `f64` lanes.
45+
46+
The supported element types are as follows:
47+
* **Floating Point:** `f32`, `f64`
48+
* **Signed Integers:** `i8`, `i16`, `i32`, `i64`, `isize` (`i128` excluded)
49+
* **Unsigned Integers:** `u8`, `u16`, `u32`, `u64`, `usize` (`u128` excluded)
50+
* **Pointers:** `*const T` and `*mut T` (zero-sized metadata only)
51+
* **Masks:** 8-bit, 16-bit, 32-bit, 64-bit, and `usize`-sized masks
52+
53+
Floating point, signed integers, unsigned integers, and pointers are the [primitive types](https://doc.rust-lang.org/core/primitive/index.html) you're already used to.
54+
The mask types have elements that are "truthy" values, like `bool`, but have an unspecified layout because different architectures prefer different layouts for mask types.
55+
56+
[simd-guide]: ./beginners-guide.md
57+
[zulip-project-portable-simd]: https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd
58+
[stdarch]: https://github.com/rust-lang/stdarch
59+
[docs]: https://rust-lang.github.io/portable-simd/core_simd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### `stdsimd` examples
2+
3+
This crate is a port of example uses of `stdsimd`, mostly taken from the `packed_simd` crate.
4+
5+
The examples contain, as in the case of `dot_product.rs`, multiple ways of solving the problem, in order to show idiomatic uses of SIMD and iteration of performance designs.
6+
7+
Run the tests with the command
8+
9+
```
10+
cargo run --example dot_product
11+
```
12+
13+
and verify the code for `dot_product.rs` on your machine.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The `rustc-std-workspace-core` crate
2+
3+
This crate is a shim and empty crate which simply depends on `libcore` and
4+
reexports all of its contents. The crate is the crux of empowering the standard
5+
library to depend on crates from crates.io
6+
7+
Crates on crates.io that the standard library depend on need to depend on the
8+
`rustc-std-workspace-core` crate from crates.io, which is empty. We use
9+
`[patch]` to override it to this crate in this repository. As a result, crates
10+
on crates.io will draw a dependency edge to `libcore`, the version defined in
11+
this repository. That should draw all the dependency edges to ensure Cargo
12+
builds crates successfully!
13+
14+
Note that crates on crates.io need to depend on this crate with the name `core`
15+
for everything to work correctly. To do that they can use:
16+
17+
```toml
18+
core = { version = "1.0.0", optional = true, package = 'rustc-std-workspace-core' }
19+
```
20+
21+
Through the use of the `package` key the crate is renamed to `core`, meaning
22+
it'll look like
23+
24+
```
25+
--extern core=.../librustc_std_workspace_core-XXXXXXX.rlib
26+
```
27+
28+
when Cargo invokes the compiler, satisfying the implicit `extern crate core`
29+
directive injected by the compiler.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The `rustc-std-workspace-std` crate
2+
3+
See documentation for the `rustc-std-workspace-core` crate.

0 commit comments

Comments
 (0)