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

Update Stainless to v0.8 #107

Merged
merged 9 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ jobs:
with:
repository: epfl-lara/stainless
tag: ${{ env.stainless_version }}
file: stainless-${{ env.stainless_version }}-linux.zip
file: stainless-${{ env.stainless_version }}-2-linux.zip
yannbolliger marked this conversation as resolved.
Show resolved Hide resolved

- name: Unzip Stainless
uses: montudor/[email protected]
with:
args: unzip ./stainless-${{ env.stainless_version }}-linux.zip -d ./stainless-noxt
args: unzip ./stainless-${{ env.stainless_version }}-2-linux.zip -d ./stainless-noxt

- name: Run cargo build
uses: actions-rs/cargo@v1
Expand Down
2 changes: 1 addition & 1 deletion .stainless-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
noxt-0.7.6-67-g533f5d5
noxt-0.8.0-41-g20d258d
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ The following instructions assume that you have installed Rust using [rustup](ht
- Clone this repo in `/basedir/rust-stainless`.
- Make sure your `rustup` toolchain within that directory is set to the currently supported nightly version (via `rustup override set $(cat rust-toolchain)` in `/basedir/rust-stainless`).
- Make sure you have the `rustc-dev` and `llvm-tools-preview` components installed (via `rustup component add rustc-dev llvm-tools-preview`).
- Install `stainless_driver` (via `cargo install --path stainless_frontend/`). This will build the `rustc_to_stainless` driver, which is essentially a modified version of `rustc`, and `cargo-stainless`, which provides a convenient way of invoking `rustc_to_stainless` from within Cargo project folders. Installation ensures that both of these binaries end up on your `PATH`.
- Get a copy of the standalone version of `stainless-noxt` for [Linux](lara.epfl.ch/~gschmid/stainless/stainless-noxt-SNAPSHOT-linux.zip) or [macOS](lara.epfl.ch/~gschmid/stainless/stainless-noxt-SNAPSHOT-mac.zip). (This is based on forks of [inox](https://github.com/epfl-lara/inox/tree/rust-interop) and [stainless](https://github.com/epfl-lara/stainless/tree/rust-interop).) Extract it to `/basedir/stainless`.
- Make sure that your `STAINLESS_HOME` environmental variable points to `/basedir/stainless`.
- Install `stainless_frontend` (via `cargo install --path stainless_frontend/`). This will build the `rustc_to_stainless` driver, which is essentially a modified version of `rustc`, and `cargo-stainless`, which provides a convenient way of invoking `rustc_to_stainless` from within Cargo project folders. Installation ensures that both of these binaries end up on your `PATH`.

- Get a copy of the standalone version of `stainless-noxt` from the release of
Stainless that has the tag stated in [`.stainless-version`](.stainless-version).
For example, [this one](https://github.com/epfl-lara/stainless/releases/tag/noxt-0.8.0-41-g20d258d)
with the archive for [Linux](https://github.com/epfl-lara/stainless/releases/download/noxt-0.8.0-41-g20d258d/stainless-noxt-0.8.0-41-g20d258d-linux.zip)
or [macOS](https://github.com/epfl-lara/stainless/releases/download/noxt-0.8.0-41-g20d258d/stainless-noxt-0.8.0-41-g20d258d-mac.zip).
(This is based on forks of
[inox](https://github.com/epfl-lara/inox/tree/rust-interop) and
[stainless](https://github.com/epfl-lara/stainless/tree/rust-interop).)

- Extract it to `/basedir/stainless`.
- Make sure that your `STAINLESS_HOME` environment variable points to `/basedir/stainless`.

Now you should be good to go.

Expand All @@ -32,7 +42,9 @@ Similarly to other cargo commands, you can also use `cargo stainless --example f

## What to expect

Note that the fragment of Rust currently supported is very limited. _TODO: Give some examples_
Note that the fragment of Rust currently supported is very limited. The test
cases give you a good impression of [what works](stainless_frontend/tests/pass)
and [what doesn't yet](stainless_frontend/tests/fail).

## Development

Expand All @@ -41,6 +53,23 @@ First, export the serialized stainless program using `cargo stainless --export o
To then run verification on that file, navigate to your checked-out Stainless repo, run `sbt` in the root folder of the repo, and consequently switch to the appropriate subproject using `project stainless-noxt`.
The actual verification can be started using `run /the/path/to/output.inoxser`.

### Generating the Stainless ADT

The `rust-stainless` frontend transforms Rust programs to Stainless trees which
are fed to the Stainless backend. The definition of these trees is in found in
[`stainless_data`](stainless_data/src/ast/generated.rs) and is automatically generated from the
Stainless repository.

If Stainless gets new features or a fix, it is sometimes necessary to regenerate the AST in order to
stay compatible with the latest version of the Stainless backend. This is done from the `rust-interop` branch
on [Stainless](https://github.com/epfl-lara/stainless/tree/rust-interop).

1. Checkout the `rust-interop` branch.
2. Rebase or change what is needed.
3. Run `sbt` and then `runMain stainless.utils.RustInteropGeneratorTool generated.rs`.
4. Move the newly `generated.rs` file to `stainless_data/src/ast/generated.rs`.
5. Rebuild and test the frontend to see whether everything still works and hope for the best.

## Contributors

- Georg Schmid ([@gsps](https://github.com/gsps))
Expand Down
Loading