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

CI: test EasyCrypt extraction #260

Merged
merged 5 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,31 @@ libjade-extract-to-ec:
paths:
- libjade-main/proof/check.tar.gz

test-extract-to-ec:
stage: test
parallel:
matrix:
- EASYCRYPT_REF: [release, dev]
variables:
EXTRA_NIX_ARGUMENTS: --arg ocamlDeps true --arg testDeps true --argstr ecRef $EASYCRYPT_REF
WHY3_CONF: $CI_PROJECT_DIR/why3.conf
ECARGS: -why3 $WHY3_CONF -I Jasmin:$CI_PROJECT_DIR/eclib
JSJOBS: $(NIX_BUILD_CORES)
extends: .common
needs:
- coq
- ocaml
dependencies:
- coq
- ocaml
script:
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'easycrypt why3config -why3 $WHY3_CONF'
- nix-shell --arg inCI true $EXTRA_NIX_ARGUMENTS --run 'make -C compiler CHECKCATS=extraction check'
artifacts:
when: always
paths:
- compiler/report.log

push-compiler-code:
stage: deploy
environment: deployment
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
fixes [#29](https://github.com/jasmin-lang/jasmin/issues/29),
fixes [#150](https://github.com/jasmin-lang/jasmin/issues/150)).

- Using option `-oec` without option `-ec` extracts all functions.

- Extraction to EasyCrypt is now tested in continuous integration
([PR #260](https://github.com/jasmin-lang/jasmin/pull/260);
fixes [#136](https://github.com/jasmin-lang/jasmin/issues/136),
fixes [#104](https://github.com/jasmin-lang/jasmin/issues/104)).

# Jasmin 22.0

This release is the result of more than two years of active development. It thus
Expand Down
7 changes: 6 additions & 1 deletion compiler/config/tests.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ okdirs = !CCT/success
kodirs = !CCT/fail

[test-all]
okdirs = examples examples/gimli tests/success tests/success/pointers tests/success/subroutines tests/success/subarrays tests/success/syscall
okdirs = !examples !tests/success
kodirs = tests/fail tests/fail/annotation

[test-print]
bin = ./scripts/parse-print-parse
okdirs = tests/success

[test-extraction]
bin = ./scripts/extract-and-check
okdirs = !examples !tests/success
exclude = tests/success/noextract
2 changes: 1 addition & 1 deletion compiler/examples/gimli/ecproof/gimli_ref.jazz
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn gimli_body(stack u32[12] state) -> stack u32[12] {
return state;
}

export
inline
fn gimli(reg u64 istate) {
stack u32[12] state;
inline int i;
Expand Down
2 changes: 1 addition & 1 deletion compiler/examples/gimli/ecproof/gimli_ref1.jazz
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn gimli_body(stack u32[12] state) -> stack u32[12] {
return state;
}

export
inline
fn gimli(reg u64 istate) {
stack u32[12] state;
inline int i;
Expand Down
17 changes: 17 additions & 0 deletions compiler/scripts/extract-and-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -e

DIR=$(mktemp -d jasminXXXXXX)
EC=${DIR}/jasmin.ec
CT=${DIR}/jasmin_ct.ec

trap "rm -r ${DIR}" EXIT

set -x

$(dirname $0)/../jasminc.native -oecarray ${DIR} -oec ${EC} "$@"
$(dirname $0)/../jasminc.native -oecarray ${DIR} -CT -oec ${CT} "$@"

easycrypt ${ECARGS} ${EC}
easycrypt ${ECARGS} ${CT}
8 changes: 6 additions & 2 deletions compiler/src/main_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,21 @@ let main () =

visit_prog_after_pass ~debug:true Compiler.ParamsExpansion prog;

if !ec_list <> [] then begin
if !ec_list <> [] || !ecfile <> "" then begin
let fmt, close =
if !ecfile = "" then Format.std_formatter, fun () -> ()
else
let out = open_out !ecfile in
let fmt = Format.formatter_of_out_channel out in
fmt, fun () -> close_out out in
let fnames =
match !ec_list with
| [] -> List.map (fun { f_name ; _ } -> f_name.fn_name) (snd prog)
| fnames -> fnames in
begin try
BatPervasives.finally
(fun () -> close ())
(fun () -> ToEC.extract Arch.reg_size Arch.asmOp fmt !model prog !ec_list)
(fun () -> ToEC.extract Arch.reg_size Arch.asmOp fmt !model prog fnames)
()
with e ->
BatPervasives.ignore_exceptions
Expand Down