-
Notifications
You must be signed in to change notification settings - Fork 21
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
Extraction to OCaml + OCaml wrapper code #18
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
OCAMLBUILD := env OCAMLPATH=$(shell pwd) ocamlbuild \ | ||
-tag thread -tag debug -use-ocamlfind \ | ||
-lib str -lib nums \ | ||
-I codegen -I mllib -X ocamlfuse \ | ||
-package extunix -package zarith -package ocamlfuse | ||
MODULES := Lock Nomega Word WordAuto WordZ Bytes Rounding \ | ||
Mem AsyncDisk Pred Prog ProgMonad PredCrash Hoare \ | ||
OperationalSemantics \ | ||
|
@@ -46,55 +41,15 @@ HSLIB_FUSE := hscgen/Fuse.hs hslib/libopfuse.a | |
HSLIB_PRE := hslib/Word.hs hslib/Evict.hs hslib/Profile.hs | ||
HSLIB_POST := hslib/Disk.hs hslib/Interpreter.hs | ||
|
||
OCAMLFUSE_ML := ocamlfuse/Result.ml \ | ||
ocamlfuse/Unix_util.ml \ | ||
ocamlfuse/Fuse_bindings.ml \ | ||
ocamlfuse/Fuse_lib.ml \ | ||
ocamlfuse/Fuse.ml | ||
OCAMLFUSE_MLI := ocamlfuse/Fuse.mli \ | ||
ocamlfuse/Fuse_bindings.mli | ||
|
||
OCAMLFUSE_CMX := $(patsubst %.ml,%.cmx,$(OCAMLFUSE_ML)) | ||
OCAMLFUSE_DEP := $(patsubst %.ml,%.d,$(OCAMLFUSE_ML)) \ | ||
$(patsubst %.mli,%.di,$(OCAMLFUSE_MLI)) | ||
OCAMLFUSE := ocamlfuse/Fuse.a ocamlfuse/Fuse.cmxa | ||
|
||
.PHONY: coq proof clean | ||
|
||
all: fscq mkfs | ||
|
||
-include $(OCAMLFUSE_DEP) | ||
|
||
%.mli %.ml %_stubs.c: %.idl | ||
camlidl -header $< | ||
|
||
%.d: %.ml | ||
ocamldep $< > $@ | ||
|
||
%.di: %.mli | ||
ocamldep $< > $@ | ||
|
||
ocamlfuse/%.o: ocamlfuse/%.c | ||
ocamlc -c -ccopt '-fPIC -D_FILE_OFFSET_BITS=64 -I. -pthread -DPIC -DNATIVE_CODE -o $@' $< | ||
|
||
ocamlfuse/libFuse_stubs.a: ocamlfuse/Fuse_bindings_stubs.o ocamlfuse/Unix_util_stubs.o ocamlfuse/Fuse_util.o | ||
ar rcs $@ $^ | ||
|
||
%.cmx: %.ml | ||
ocamlopt -I ocamlfuse -c -thread $< | ||
|
||
%.cmi: %.mli | ||
ocamlopt -I ocamlfuse -c -thread $< | ||
|
||
ocamlfuse/Fuse.cmxa ocamlfuse/Fuse.a: $(OCAMLFUSE_CMX) ocamlfuse/libFuse_stubs.a | ||
ocamlopt -a -thread -linkall -cclib -lFuse_stubs -cclib -lfuse -cclib -lcamlidl -o $@ $(OCAMLFUSE_CMX) | ||
mlbin/mkfs.exe: mlbin/mkfs.ml $(VS_ML) $(wildcard mllib/*.ml) | ||
dune build $@ | ||
|
||
%: %.ml $(VS_ML) $(wildcard */*.ml) $(OCAMLFUSE) | ||
rm -f $@ | ||
-mv codegen/Word.ml codegen/WordCoq.ml | ||
-mv codegen/Word.mli codegen/WordCoq.mli | ||
$(OCAMLBUILD) -no-links [email protected] | ||
ln -s $(CURDIR)/_build/[email protected] $@ | ||
mlbin/fscqfuse.exe: mlbin/fscqfuse.ml $(VS_ML) $(wildcard mllib/*.ml) | ||
dune build $@ | ||
|
||
hscgen/%.hs: hslib/%.hsc | ||
@mkdir -p $(@D) | ||
|
@@ -113,13 +68,14 @@ $(VS_HS): $(VS_VIO) coqbuild/ExtractHaskell.v | |
|
||
$(VS_ML): $(VS_VIO) coqbuild/ExtractOcaml.v | ||
( cd coqbuild && coqc -q -R . Fscq ExtractOcaml.v ) | ||
mv codegen/Word.ml codegen/.WordCoq.ml | ||
mv codegen/Word.mli codegen/.WordCoq.mli | ||
|
||
$(VS_JSON): $(VS_VIO) coqbuild/ExtractJSON.v | ||
( cd coqbuild && coqc -q -R . Fscq ExtractJSON.v ) | ||
|
||
$(VS_VIO): coqbuild/Makefile.coq | ||
( cd coqbuild && $(MAKE) -j $(J) -f Makefile.coq quick ) | ||
@touch coqbuild/*.vio | ||
( cd coqbuild && $(MAKE) -j $(J) -f Makefile.coq vio ) | ||
|
||
checkproofs: coqbuild/Makefile.coq | ||
( cd coqbuild && $(MAKE) -f Makefile.coq checkproofs J=$(J) ) | ||
|
@@ -157,10 +113,8 @@ hslib/libopfuse.a: hslib/opqueue.o hslib/opfuse.o | |
|
||
clean: | ||
rm -rf codegen coqbuild _build fstest hstest gotest disk.img \ | ||
fscq mkfs *.o *.hi ocamlfuse/*.d ocamlfuse/*.di \ | ||
ocamlfuse/*.cmi ocamlfuse/*.cmx ocamlfuse/*.cmo \ | ||
ocamlfuse/*.o ocamlfuse/Fuse_bindings_stubs.c \ | ||
ocamlfuse/Fuse_bindings.h ocamlfuse/Fuse_bindings.ml \ | ||
ocamlfuse/libFuse_stubs.a hslib/*.o hscgen | ||
fscq mkfs *.o *.hi \ | ||
hslib/*.o hscgen \ | ||
mlbin/*.exe | ||
|
||
.PRECIOUS: hscgen/%.hs %_stubs.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Require Import String. | ||
Require Import Hashmap. | ||
Require Import Arith. | ||
Require Import Bool. | ||
|
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 @@ | ||
(lang dune 2.0) |
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,13 @@ | ||
(executable | ||
(name mkfs) | ||
(libraries fscq zarith) | ||
(modules mkfs) | ||
(promote (until-clean)) | ||
) | ||
|
||
(executable | ||
(name fscqfuse) | ||
(libraries fscq fuse fpath) | ||
(modules fscqfuse) | ||
(promote (until-clean)) | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: what's the rationale for using
HexString.to_nat
instead of doing the computation directly in nat as before? Does this help avoid some kind of degenerate nat performance issue with Ocaml extraction? I have to admit I've never even known aboutHexString.to_nat
before seeing this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise (AFAIR) the generated OCaml code would be building a nat by piling up 1024 S constructors, and that would make compiling (!) the ocaml code quite slow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense; thanks!