-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
308 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ lib/steel/META | |
lib/steel/dune-package | ||
*.krml | ||
*.o | ||
LICENSE-z3.txt | ||
|
||
# Created by CI | ||
BUILDLOG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
steel | ||
steel.zip | ||
steel.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# The Steel and Pulse separation logic system for F* | ||
|
||
## Contents of this package | ||
|
||
This binary package contains z3 4.8.5, F*, Karamel, Steel, Pulse, and | ||
(except on Windows) Pulse2Rust: | ||
|
||
* in `bin`: the executables for z3, F* and Karamel | ||
|
||
* in `lib/steel`: | ||
* the Steel F* modules of the `Steel` and `Steel.ST` namespaces | ||
* the Steel F* plugin, `steel.cmxs`, containing the Steel and Pulse | ||
tactics, and the Steel and SteelC extraction to krml, is installed | ||
here | ||
* the LibSteel C library, `libsteel.a`, containing an implementation of | ||
what used to be the Steel part of krmllib (currently binding the | ||
pthreads spinlock), is installed here | ||
|
||
* in `lib/steel/runtime`: the Steel OCaml runtime, | ||
`steel_runtime.cmxa`, necessary to compile and run Steel code | ||
extracted to OCaml, is installed here | ||
|
||
* in `lib/steel/pulse`: the Pulse F* modules of the `Pulse` namespace | ||
(except `Pulse.Lib`) | ||
|
||
* in `lib/steel/c`: the SteelC F* modules of the `Steel.C` and | ||
`Steel.ST.C` namespaces | ||
|
||
* in `include/steel`: the C include files necessary to compile Steel | ||
code extracted to C | ||
|
||
* in `share/steel`: `Makefile.include`, the GNU Make rules to verify | ||
Steel and Pulse code | ||
|
||
* in `share/steel/examples/pulse`: | ||
* in `lib`: the Pulse user library files (namespace `Pulse.Lib`) | ||
* in `_output/cache`: the corresponding `.checked` files | ||
|
||
* in `pulse2rust`: the executable for Pulse2Rust. (Absent from the | ||
Windows binary package) | ||
|
||
## Using Steel and Pulse | ||
|
||
### Writing a Makefile to verify Steel or Pulse code | ||
|
||
Steel and Pulse come with `share/steel/Makefile.include`, which contains the | ||
GNU Make rules to call F* with the Steel include path and the Steel/Pulse | ||
plugin loaded. | ||
|
||
1. Make sure the `bin` subdirectory is in your `PATH`. | ||
|
||
2. Define the `STEEL_HOME` environment variable to the root directory | ||
of this package. | ||
|
||
3. (Optional) In your Makefile, define the following variables with `+=` or `:=` : | ||
* `FSTAR_FILES`: some more F* files to verify, in addition to the | ||
`*.fst` and `.fsti` files of your project | ||
* `EXCLUDE_FILES`: some F* to skip for verification | ||
* `FSTAR_OPTIONS`: additional options to pass to F*. While | ||
`Makefile.include` is already configured to use Steel, you need | ||
to add more options if you need Pulse and/or SteelC: | ||
* if you want to use Pulse, add `--include $STEEL_HOME/lib/steel/pulse` | ||
* if you want to use SteelC, add `--include $STEEL_HOME/lib/steel/c` | ||
* `FSTAR_DEP_OPTIONS`: additional options to pass to F* to compute | ||
dependencies (in addition to `FSTAR_OPTIONS`), such as `--extract` | ||
* `FSTAR_ML_CODEGEN`: useful only if you want to extract OCaml | ||
code. If you want to extract a F* plugin, set this option to | ||
`Plugin`. Otherwise, it is set by default to `OCaml`. | ||
|
||
4. After those variable definitions, insert `include | ||
$STEEL_HOME/share/steel/Makefile.include` to your Makefile. | ||
|
||
5. In your project directory, run `make -j verify` | ||
|
||
### Calling F* directly | ||
|
||
If you already have an existing `Makefile` for your Steel- or | ||
Pulse-based project, you now need to pass new options to your Makefile | ||
to use Steel from this repository, as described in this section. | ||
|
||
To call F* with Steel or Pulse, pass the following options to F*: | ||
* in all cases, `--include $STEEL_HOME/lib/steel --load_cmxs steel` | ||
* if you want to use Pulse, add `--include $STEEL_HOME/lib/steel/pulse` | ||
* if you want to use SteelC, add `--include $STEEL_HOME/lib/steel/c` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This Dockerfile should be run from the root Steel directory | ||
|
||
ARG ocaml_version=4.12 | ||
FROM ocaml/opam:ubuntu-20.04-ocaml-$ocaml_version | ||
|
||
# CI dependencies for the Wasm11 test: node.js | ||
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - | ||
RUN sudo apt-get install -y --no-install-recommends nodejs | ||
|
||
# install rust | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
||
ARG opamthreads=24 | ||
|
||
# (for .NET, cf. https://aka.ms/dotnet-missing-libicu ) | ||
# CI dependencies: .NET Core | ||
# Repository install may incur some (transient?) failures (see for instance https://github.com/dotnet/sdk/issues/27082 ) | ||
# So, we use manual install instead, from https://docs.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#manual-install | ||
ENV DOTNET_ROOT /home/opam/dotnet | ||
RUN sudo apt-get install --yes --no-install-recommends \ | ||
libicu-dev \ | ||
wget \ | ||
&& \ | ||
wget https://download.visualstudio.microsoft.com/download/pr/cd0d0a4d-2a6a-4d0d-b42e-dfd3b880e222/008a93f83aba6d1acf75ded3d2cfba24/dotnet-sdk-6.0.400-linux-x64.tar.gz && \ | ||
mkdir -p $DOTNET_ROOT && \ | ||
tar xf dotnet-sdk-6.0.400-linux-x64.tar.gz -C $DOTNET_ROOT | ||
|
||
ENV PATH=${PATH}:$DOTNET_ROOT:$DOTNET_ROOT/tools | ||
|
||
ADD --chown=opam:opam ./ steel/ | ||
|
||
# Install F* and Karamel from the Karamel CI install script | ||
# FIXME: the `opam depext` command should be unnecessary with opam 2.1 | ||
ENV FSTAR_HOME=$HOME/FStar | ||
ENV KRML_HOME=$HOME/karamel | ||
RUN sudo apt-get update && sudo apt-get install --yes --no-install-recommends \ | ||
wget \ | ||
jq \ | ||
&& \ | ||
git clone --branch $(jq -c -r '.RepoVersions.fstar' steel/src/ci/config.json || echo master) https://github.com/FStarLang/FStar $FSTAR_HOME && \ | ||
eval $(opam env) && \ | ||
opam depext conf-gmp z3.4.8.5-1 conf-m4 && \ | ||
opam install --deps-only $FSTAR_HOME/fstar.opam && \ | ||
env OTHERFLAGS='--admit_smt_queries true' make -C $FSTAR_HOME -j $opamthreads && \ | ||
git clone --branch $(jq -c -r '.RepoVersions.karamel' steel/src/ci/config.json || echo master) https://github.com/FStarLang/karamel $KRML_HOME && \ | ||
eval $(opam env) && $KRML_HOME/.docker/build/install-other-deps.sh && \ | ||
env OTHERFLAGS='--admit_smt_queries true' make -C $KRML_HOME -j $opamthreads | ||
|
||
# FIXME: The recent changes to MLish and bootstrapping mean that we must | ||
# not try to check prims.fst or the rest of ulib in --MLish mode, since | ||
# some files fail to do so. This will happen when trying to extract the | ||
# files in src/syntax_extension, as there are no checked files for them. | ||
# So, call the F* makefile to bootstrap F* and generate the files. This | ||
# is probably only a bandaid... but I'm not sure what the best thing to | ||
# do is. | ||
RUN eval $(opam env) && \ | ||
env OTHERFLAGS='--admit_smt_queries true' make -C $FSTAR_HOME -j $opamthreads bootstrap | ||
|
||
# Produce the binary package | ||
RUN eval $(opam env) && . $HOME/.cargo/env && steel/src/ci/package.sh -j $opamthreads | ||
|
||
ENV STEEL_HOME $HOME/steel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -x | ||
|
||
if [[ -z "$OS" ]] ; then | ||
OS=$(uname) | ||
fi | ||
|
||
is_windows=false | ||
if [[ "$OS" = "Windows_NT" ]] ; then | ||
is_windows=true | ||
fi | ||
|
||
fixpath () { | ||
if $is_windows ; then | ||
cygpath -m "$1" | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
cp0=$(which gcp >/dev/null 2>&1 && echo gcp || echo cp) | ||
cp="$cp0 --preserve=mode,timestamps" | ||
make="$(which gmake >/dev/null 2>&1 && echo gmake || echo make)" | ||
|
||
# make sure the package has not already been built | ||
cd $(cd `dirname $0` && pwd) | ||
[[ ! -e steel ]] | ||
|
||
# download the z3 license file | ||
if ! [[ -f LICENSE-z3.txt ]] ; then | ||
curl -o LICENSE-z3.txt https://raw.githubusercontent.com/Z3Prover/z3/master/LICENSE.txt | ||
fi | ||
|
||
# build a F* package | ||
if [[ -z "$FSTAR_HOME" ]] ; then | ||
if ! [[ -d FStar ]] ; then | ||
git clone https://github.com/FStarLang/FStar | ||
fi | ||
FSTAR_HOME=$(pwd)/FStar | ||
fi | ||
export FSTAR_HOME=$(fixpath "$FSTAR_HOME") | ||
old_FSTAR_HOME="$FSTAR_HOME" | ||
fstar_package_dir=$(fixpath "$FSTAR_HOME"/src/ocaml-output/fstar) | ||
rm -rf "$fstar_package_dir" | ||
Z3_LICENSE=$(pwd)/LICENSE-z3.txt $make -C "$FSTAR_HOME" package "$@" | ||
|
||
# build Karamel and add it to the package | ||
if [[ -z "$KRML_HOME" ]] ; then | ||
if ! [[ -d karamel ]] ; then | ||
git clone https://github.com/FStarLang/karamel | ||
fi | ||
KRML_HOME=$(pwd)/karamel | ||
fi | ||
export KRML_HOME=$(fixpath "$KRML_HOME") | ||
$make -C "$KRML_HOME" minimal "$@" | ||
OTHERFLAGS='--admit_smt_queries true' $make -C "$KRML_HOME"/krmllib verify-all "$@" | ||
$cp -L $KRML_HOME/krml $fstar_package_dir/bin/krml$exe | ||
$cp -r $KRML_HOME/krmllib $fstar_package_dir/ | ||
$cp -r $KRML_HOME/include $fstar_package_dir/ | ||
$cp -r $KRML_HOME/misc $fstar_package_dir/ | ||
|
||
# assume current directory is $STEEL_HOME/src/ci | ||
export STEEL_HOME=$(fixpath $(cd ../.. && pwd)) | ||
|
||
# use the package to build Steel | ||
export FSTAR_HOME="$fstar_package_dir" | ||
OTHERFLAGS='--admit_smt_queries true' $make -C "$STEEL_HOME" "$@" | ||
$make -C "$STEEL_HOME"/share/steel/examples/pulse lib "$@" | ||
mkdir -p "$old_FSTAR_HOME"/src/.cache.boot | ||
if ! $is_windows ; then | ||
FSTAR_HOME="$old_FSTAR_HOME" $make -C "$STEEL_HOME"/pulse2rust "$@" | ||
fi | ||
|
||
# install Steel into the package directory | ||
export PREFIX="$FSTAR_HOME" | ||
$make -C "$STEEL_HOME" install "$@" | ||
$make -C "$STEEL_HOME"/share/steel/examples/pulse install-lib "$@" | ||
if ! $is_windows ; then | ||
mkdir -p "$PREFIX"/pulse2rust | ||
$cp "$STEEL_HOME"/pulse2rust/main.exe "$PREFIX"/pulse2rust/ | ||
fi | ||
|
||
# create the archive package | ||
mv "$PREFIX" steel | ||
rm -rf steel/share/fstar steel/INSTALL.md steel/README.md steel/version.txt | ||
$cp package-README.md steel/README.md | ||
if $is_windows ; then | ||
zip -r -9 steel.zip steel | ||
else | ||
tar czf steel.tar.gz steel | ||
fi |