Skip to content

Commit

Permalink
Merge pull request #184 from mtzguido/stage
Browse files Browse the repository at this point in the history
Removing the snapshot and staging the build
  • Loading branch information
mtzguido authored Dec 18, 2024
2 parents 30a310e + 70974f5 commit 9bbb640
Show file tree
Hide file tree
Showing 22 changed files with 224 additions and 28,822 deletions.
72 changes: 36 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,48 @@ endif

all: lib verify

# Find fstar.exe and the fstar.lib OCaml package
ifeq (,$(FSTAR_HOME))
_check_fstar := $(shell which fstar.exe)
ifeq ($(.SHELLSTATUS),0)
_fstar_home := $(realpath $(dir $(_check_fstar))/..)
ifeq ($(OS),Windows_NT)
OCAMLPATH := $(shell cygpath -m $(_fstar_home)/lib);$(OCAMLPATH)
else
OCAMLPATH := $(_fstar_home)/lib:$(OCAMLPATH)
endif
endif
else
_fstar_home := $(FSTAR_HOME)
ifeq ($(OS),Windows_NT)
OCAMLPATH := $(shell cygpath -m $(FSTAR_HOME)/lib);$(OCAMLPATH)
else
OCAMLPATH := $(FSTAR_HOME)/lib:$(OCAMLPATH)
endif
# Find fstar.exe
ifdef FSTAR_HOME
FSTAR_EXE ?= $(FSTAR_HOME)/bin/fstar.exe
endif
export OCAMLPATH
_check_fstar_lib_package := $(shell env OCAMLPATH="$(OCAMLPATH)" ocamlfind query fstar.lib)
ifneq ($(.SHELLSTATUS),0)
$(error "Cannot find fstar.lib in $(OCAMLPATH). Please make sure fstar.exe is properly installed and in your PATH or FSTAR_HOME points to its prefix directory or the F* source repository.")
FSTAR_EXE ?= $(shell which fstar.exe)

ifeq (,$(FSTAR_EXE))
$(error "Did not find fstar.exe in PATH and FSTAR_EXE/FSTAR_HOME unset, aborting.")
endif
export FSTAR_EXE

# Define the Steel root directory. We need to fix it to use the Windows path convention on Windows+Cygwin.
ifeq ($(OS),Windows_NT)
STEEL_HOME := $(shell cygpath -m $(CURDIR))
else
STEEL_HOME := $(CURDIR)
endif
export STEEL_HOME := $(CURDIR)

.PHONY: ocaml
ocaml:
cd src/ocaml && dune build
.PHONY: .force
.force:

plugin: plugin.src
cd src/ocaml && $(FSTAR_EXE) --ocamlenv dune build
cd src/ocaml && dune install --prefix=$(STEEL_HOME)

plugin.src: .force
@# NOTE: I would have preferred to separate the cache dir
@# into something like build/plugin.checked, but this
@# means every client now has to point there too, and we have
@# to install that directory. So I'm just placing them in lib/steel
@# as the Makefile there does. This should be fine really.
$(MAKE) -f mk/plugin.mk \
CACHE_DIR=lib/steel \
OUTPUT_DIR=build/plugin.ml \
CODEGEN=Plugin \
SRC=lib/steel \
TAG=plugin \
EXTRACT="--extract '+Steel.Effect.Common +Steel.ST.GenElim.Base +Steel.ST.GenElim1.Base'" \
ROOTS="Steel.Effect.Common.fst Steel.ST.GenElim.Base.fst Steel.ST.GenElim1.Base.fst"

.PHONY: lib
lib:
+$(MAKE) -C src/c

.PHONY: verify-steel
verify-steel: ocaml
verify-steel: plugin
+$(MAKE) -C lib/steel steel

.PHONY: verify-steelc
Expand All @@ -62,6 +61,8 @@ verify: verify-steel verify-steelc

clean: clean_ocaml
+$(MAKE) -C lib/steel clean ; true
rm -rf build/plugin.checked
rm -rf build/plugin.ml

clean_ocaml:
cd src/ocaml && { dune uninstall --prefix=$(STEEL_HOME) ; dune clean ; true ; }
Expand All @@ -71,6 +72,7 @@ test: all
+$(MAKE) -C share/steel

PREFIX ?= /usr/local
override PREFIX:=$(abspath $(PREFIX))
ifeq ($(OS),Windows_NT)
STEEL_INSTALL_PREFIX=$(shell cygpath -m $(PREFIX))
else
Expand Down Expand Up @@ -105,9 +107,7 @@ install-share:

install: install-ocaml install-lib install-include install-share install-src-c

boot:
+$(MAKE) -C lib/steel steel
+$(MAKE) -C src boot

.PHONY: ci
ci:
+$(MAKE) -C src ci
+$(MAKE) all
+$(MAKE) test
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ those are not installed as of now.
opam, you may need to run `eval $(opam env)`. If F* is not in your
`PATH`, set the `FSTAR_HOME` environment variable to the directory
where F* was installed (or to the F* source tree), so that the F*
executable should be in `$FSTAR_HOME/bin/fstar.exe`.
executable should be in `$FSTAR_HOME/bin/fstar.exe`; or set the
environment variable `FSTAR_EXE` to the path of the executable.
2. Run `make -j`

### Building the source and installing to a custom location
Expand Down
2 changes: 1 addition & 1 deletion Steel.fst.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fstar_exe": "fstar.exe",
"fstar_exe": "/home/guido/r/fstar/dev/bin/fstar.exe",
"options": [
"--load_cmxs",
"steel"
Expand Down
2 changes: 2 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.ml
*.checked
12 changes: 5 additions & 7 deletions lib/steel/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
all: steel steelc
STEEL_ROOT ?= ../..
include $(STEEL_ROOT)/mk/common.mk
$(call need_exe,FSTAR_EXE)

ifneq (,$(FSTAR_HOME))
FSTAR=$(FSTAR_HOME)/bin/fstar.exe
else
FSTAR=fstar.exe
endif
all: steel steelc

FSTAR_FILES:=$(wildcard *.fst *.fsti)

FSTAR_OPTIONS=$(OTHERFLAGS) --cache_checked_modules --warn_error @241 --already_cached '*,-Steel' --load_cmxs steel

COMPAT_INDEXED_EFFECTS=--compat_pre_typed_indexed_effects
MY_FSTAR=$(RUNLIM) $(FSTAR) $(SIL) $(FSTAR_OPTIONS)
MY_FSTAR=$(RUNLIM) $(FSTAR_EXE) $(SIL) $(FSTAR_OPTIONS)

include runlim.mk

Expand Down
Empty file modified lib/steel/Steel.ST.BitVector.fsti
100755 → 100644
Empty file.
12 changes: 5 additions & 7 deletions lib/steel/c/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
all: steelc
STEEL_ROOT ?= ../../..
include $(STEEL_ROOT)/mk/common.mk
$(call need_exe,FSTAR_EXE)

ifneq (,$(FSTAR_HOME))
FSTAR=$(FSTAR_HOME)/bin/fstar.exe
else
FSTAR=fstar.exe
endif
all: steelc

FSTAR_FILES:=$(wildcard *.fst *.fsti)

FSTAR_OPTIONS=$(OTHERFLAGS) --cache_checked_modules --warn_error @241 --already_cached '*,-Steel.C,-Steel.ST.C' --include .. --load_cmxs steel

MY_FSTAR=$(RUNLIM) $(FSTAR) $(SIL) $(FSTAR_OPTIONS)
MY_FSTAR=$(RUNLIM) $(FSTAR_EXE) $(SIL) $(FSTAR_OPTIONS)

%.checked:
$(call msg, "CHECK", $(basename $(notdir $@)))
Expand Down
92 changes: 92 additions & 0 deletions mk/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# This makefile is included from several other makefiles in the tree.

MAKEFLAGS += --no-builtin-rules
Q?=@
SIL?=--silent
RUNLIM=
ifneq ($(V),)
Q=
SIL=
else
MAKEFLAGS += -s
endif

define NO_RUNLIM_ERR
runlim not found:
To use RESOURCEMONITOR=1, the `runlim` tool must be installed and in your $$PATH.
It must also be a recent version supporting the `-p` option.
You can get it from: [https://github.com/arminbiere/runlim]
endef

define msg =
@printf " %-14s %s\n" $(1) $(2)
endef
define bold_msg =
@#-tput bold 2>/dev/null
@printf -- " %-15s" $(1)
@#-tput sgr0 2>/dev/null
@printf " %s\n" $(2)
endef

# Passing RESOURCEMONITOR=1 will create .runlim files through the source tree with
# information about the time and space taken by each F* invocation.
ifneq ($(RESOURCEMONITOR),)
ifeq ($(shell which runlim),)
_ := $(error $(NO_RUNLIM_ERR)))
endif
ifneq ($(MONID),)
MONPREFIX=$(MONID).
endif
RUNLIM=runlim -p -o $@.$(MONPREFIX)runlim
endif

# Ensure that any failing rule will not create its target file.
# In other words, make `make` less insane.
.DELETE_ON_ERROR:

.DEFAULT_GOAL:=__undef
.PHONY: __undef
__undef:
$(error "This makefile does not have a default goal")

# Check that a variable is defined. If not, abort with an (optional) error message.
need = \
$(if $(value $(strip $1)),, \
$(error Need a value for $(strip $1)$(if $2, ("$(strip $2)"))))

# Check that a variable is defined and pointing to an executable.
# Is there no negation in make...?
# Wew! this was interesting to write. Especially the override part.
need_exe = \
$(if $(value $(strip $1)), \
$(if $(wildcard $(value $(strip $1))), \
$(if $(shell test -x $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not executable)), \
$(error $(strip $1) ("$(value $(strip $1))") does not exist (cwd = $(CURDIR)))), \
$(error Need an executable for $(strip $1)$(if $2, ("$(strip $2)")))) \

need_file = \
$(if $(value $(strip $1)), \
$(if $(wildcard $(value $(strip $1))), \
$(if $(shell test -f $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not executable)), \
$(error $(strip $1) ("$(value $(strip $1))") does not exist (cwd = $(CURDIR)))), \
$(error Need a file path for $(strip $1)$(if $2, ("$(strip $2)")))) \

need_dir = \
$(if $(value $(strip $1)), \
$(if $(wildcard $(value $(strip $1))), \
$(if $(shell test -d $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not executable)), \
$(error $(strip $1) ("$(value $(strip $1))") is not a directory (cwd = $(CURDIR)))), \
$(error Need an *existing* directory path for $(strip $1)$(if $2, ("$(strip $2)")))) \

need_dir_mk = \
$(if $(value $(strip $1)), \
$(if $(shell mkdir -p $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not a directory (mkdir failed, cwd = $(CURDIR)))), \
$(error Need a directory path for $(strip $1)$(if $2, ("$(strip $2)")))) \
69 changes: 69 additions & 0 deletions mk/plugin.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
include $(STEEL_HOME)/mk/common.mk

.DEFAULT_GOAL := ocaml
$(call need_exe, FSTAR_EXE, fstar.exe to be used)
$(call need_dir_mk, CACHE_DIR, directory for checked files)
$(call need_dir_mk, OUTPUT_DIR, directory for extracted OCaml files)
$(call need, CODEGEN, backend (OCaml / Plugin))
$(call need_dir, SRC, source directory)
$(call need, TAG, a tag for the .depend; to prevent clashes. Sorry.)
$(call need, ROOTS, a list of roots for the dependency analysis)
# Optional: EXTRACT, DEPFLAGS

# This is to support both --lax and non --lax clients.
EXTENSION := $(if $(findstring --lax,$(FSTAR_OPTIONS)),.checked.lax,.checked)

.PHONY: clean
clean:
rm -rf $(CACHE_DIR)
rm -rf $(OUTPUT_DIR)

.PHONY: all
all: verify ocaml

.PHONY: ocaml
ocaml: all-ml

.PHONY: verify
verify: all-checked

FSTAR_OPTIONS += $(OTHERFLAGS)
FSTAR_OPTIONS += --odir "$(OUTPUT_DIR)"
FSTAR_OPTIONS += --cache_dir "$(CACHE_DIR)"
FSTAR_OPTIONS += --include "$(SRC)"
FSTAR_OPTIONS += --cache_checked_modules
FSTAR_OPTIONS += --warn_error -321
FSTAR_OPTIONS += --compat_pre_typed_indexed_effects
ifeq ($(ADMIT),1)
FSTAR_OPTIONS += --admit_smt_queries true
endif

FSTAR = $(FSTAR_EXE) $(SIL) $(FSTAR_OPTIONS)

%$(EXTENSION): FF=$(notdir $(subst $(EXTENSION),,$@))
%$(EXTENSION):
$(call msg, "CHECK", $(FF))
$(FSTAR) --already_cached '*' $<
@touch -c $@ ## SHOULD NOT BE NEEDED

%.ml: FF=$(notdir $(subst $(EXTENSION),,$<))
%.ml: MM=$(basename $(FF))
%.ml: LBL=$(notdir $@)
# ^ HACK we use notdir to get the module name since we need to pass in
# the fst (not the checked file), but we don't know where it is, so this
# is relying on F* looking in its include path.
%.ml:
$(call msg, "EXTRACT", $(LBL))
$(FSTAR) $(FF) --already_cached '*' --codegen $(CODEGEN) --extract_module $(MM)
@touch -c $@ ## SHOULD NOT BE NEEDED

$(CACHE_DIR)/.depend$(TAG):
$(call msg, "DEPEND", $(SRC))
$(FSTAR) --dep full $(ROOTS) $(EXTRACT) $(DEPFLAGS) --output_deps_to $@
mkdir -p $(CACHE_DIR)

depend: $(CACHE_DIR)/.depend$(TAG)
include $(CACHE_DIR)/.depend$(TAG)

all-ml: $(ALL_ML_FILES)
all-checked: $(ALL_CHECKED_FILES)
32 changes: 8 additions & 24 deletions share/steel/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
ifeq (,$(STEEL_HOME))
$(error STEEL_HOME should be defined in the enclosing Makefile as the prefix directory where Steel was installed, or the root directory of its source repository)
endif
include $(STEEL_HOME)/mk/common.mk
.DEFAULT_GOAL := verify

ifneq (,$(FSTAR_HOME))
FSTAR=$(FSTAR_HOME)/bin/fstar.exe
else
FSTAR=fstar.exe
FSTAR_EXE ?= $(FSTAR_HOME)/bin/fstar.exe
endif

FSTAR_EXE ?= $(shell which fstar.exe)

$(call need_exe,FSTAR_EXE)

# Add Steel to the OCaml (ocamlfind) search path
ifeq ($(OS),Windows_NT)
OCAMLPATH := $(shell cygpath -m $(STEEL_HOME)/lib);$(OCAMLPATH)
else
OCAMLPATH := $(STEEL_HOME)/lib:$(OCAMLPATH)
endif

# Find fstar.exe and the fstar.lib OCaml package
ifeq (,$(FSTAR_HOME))
_check_fstar := $(shell which fstar.exe)
ifeq ($(.SHELLSTATUS),0)
_fstar_home := $(realpath $(dir $(_check_fstar))/..)
ifeq ($(OS),Windows_NT)
OCAMLPATH := $(shell cygpath -m $(_fstar_home)/lib);$(OCAMLPATH)
else
OCAMLPATH := $(_fstar_home)/lib:$(OCAMLPATH)
endif
endif
else
ifeq ($(OS),Windows_NT)
OCAMLPATH := $(shell cygpath -m $(FSTAR_HOME)/lib);$(OCAMLPATH)
else
OCAMLPATH := $(FSTAR_HOME)/lib:$(OCAMLPATH)
endif
endif
export OCAMLPATH

FSTAR_FILES += $(filter-out $(EXCLUDE_FILES),$(wildcard *.fst *.fsti))
ADDITIONAL_INCLUDES ?=
FSTAR_OPTIONS += $(OTHERFLAGS) --cmi --cache_checked_modules --warn_error @241 --already_cached 'Prims,FStar,LowStar,Steel,C' --include $(STEEL_HOME)/lib/steel $(ADDITIONAL_INCLUDES) --load_cmxs steel
Expand All @@ -44,7 +28,7 @@ COMPAT_INDEXED_EFFECTS?=--compat_pre_typed_indexed_effects
# Used only for OCaml extraction, not krml extraction
FSTAR_ML_CODEGEN ?= OCaml

MY_FSTAR=$(RUNLIM) $(FSTAR) $(SIL) $(FSTAR_OPTIONS)
MY_FSTAR=$(RUNLIM) $(FSTAR_EXE) $(SIL) $(FSTAR_OPTIONS)

%.checked:
$(call msg, "CHECK", $(basename $(notdir $@)))
Expand Down
Loading

0 comments on commit 9bbb640

Please sign in to comment.