Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
471dffe
refactoring dependence analysis to allow incremental analysis of decl…
nikswamy Nov 26, 2025
ad86c16
checkpoint fly deps with push/pop
nikswamy Dec 4, 2025
7d8aa90
checkpoint, before revising batch mode with fly deps
nikswamy Dec 4, 2025
22057e8
checkpoint; revise batch mode typechecker to optionally support loadi…
nikswamy Dec 5, 2025
741c498
simpler design for fly_deps in batch mode
nikswamy Dec 5, 2025
2742b02
revert changes to Tc
nikswamy Dec 5, 2025
c8281c7
some more cleanup
nikswamy Dec 5, 2025
b2e5f75
merging in master
nikswamy Dec 5, 2025
caa6d27
incremental deps must include the scope of the current environment; h…
nikswamy Dec 6, 2025
0f927d9
fly_deps works on tests/micro-benchmarks
nikswamy Dec 6, 2025
59813ee
handle interface files in fly_deps batch mode
nikswamy Dec 6, 2025
448a31c
enable fly_deps for error_messages and update expected output
nikswamy Dec 7, 2025
e56d6ed
lots of tweaks to match up behaviors with and without fly_deps
nikswamy Dec 7, 2025
295ecdf
accept output changes for printing error message with names in proper…
nikswamy Dec 7, 2025
d9b3952
make fly_deps work for emacs-style push fragments; support interfaces…
nikswamy Dec 8, 2025
e8b9bc8
fix dependences in checked files with fly_deps
nikswamy Dec 9, 2025
4ff0d34
fixes for fly_deps: persisting checked files when a module has an int…
nikswamy Dec 9, 2025
8e0002d
checkpoint; trying to solve IDE regression
nikswamy Dec 9, 2025
86bd2ac
debugging pushes and pops
nikswamy Dec 9, 2025
ba2605d
friends work in fly_deps, enforcing that friends dependences are decl…
nikswamy Dec 10, 2025
1320345
remove support of --lsp and --in (legacy interactive mode)
nikswamy Dec 10, 2025
88308af
persist proper module inclusion info in file for fly_deps
nikswamy Dec 10, 2025
be19f8b
ulib checks with fly_deps
nikswamy Dec 11, 2025
78362e2
enable fly_deps in all makefiles
nikswamy Dec 11, 2025
c9322db
revert some needless changes
nikswamy Dec 11, 2025
349dba0
move fly_deps option to common.mk, to enable it more systematically
nikswamy Dec 11, 2025
734c34d
adding --ext fly_deps also to FSTAR_ARGS, so that it is used everywhe…
nikswamy Dec 11, 2025
2303535
fly_deps works on compiler sources too
nikswamy Dec 12, 2025
756fa5b
Merge remote-tracking branch 'origin/master' into _nik_load_deps_fly
nikswamy Dec 12, 2025
1b05d87
trying to load checked files if they exist (disabled)
nikswamy Dec 12, 2025
2edf907
Merge branch 'master' into _nik_load_deps_fly
nikswamy Dec 12, 2025
7737e5a
if valid checked files exist for the current file, use them even if f…
nikswamy Dec 12, 2025
2e2064f
properly accumulate extraction environment when extracting code direc…
nikswamy Dec 13, 2025
00b6817
preserve behavior of --force/-f
nikswamy Dec 13, 2025
61cdd74
fix interaction between interface interleaving and fly dep scanning i…
nikswamy Dec 13, 2025
1759ee4
enable fly_deps for cfg files for vscode
nikswamy Dec 13, 2025
1764b21
adding some comments, cleaning up some debug output
nikswamy Dec 13, 2025
c0cf0c9
enable fly_deps for compiler sources IDE
nikswamy Dec 13, 2025
a60a77f
merging in master
nikswamy Dec 13, 2025
8ae7cfc
update expected output
nikswamy Dec 13, 2025
0860bb0
fix issue with transitive friend dependences (revealed in Pulse)
nikswamy Dec 14, 2025
075a2ec
silly leftover from a test
nikswamy Dec 14, 2025
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
3 changes: 2 additions & 1 deletion FStar.fst.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"fstar_exe": "./out/bin/fstar.exe",
"options": [
"--ext", "optimize_let_vc"
"--ext", "optimize_let_vc",
"--ext", "fly_deps"
],
"include_dirs": [
]
Expand Down
3 changes: 2 additions & 1 deletion examples/Cfg.fst.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"fstar_exe": "../out/bin/fstar.exe",
"options": [
"--ext", "optimize_let_vc"
"--ext", "optimize_let_vc",
"--ext", "fly_deps"
],
"include_dirs": [
]
Expand Down
2 changes: 1 addition & 1 deletion examples/dependencies/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ROOTS = Test.fst

FSTAR_FLAGS = $(OTHERFLAGS) --cmi --odir $(OUT_DIR) --cache_dir $(CACHE_DIR) \
--cache_checked_modules --already_cached 'Prims FStar' \
--ext optimize_let_vc
--ext optimize_let_vc --ext fly_deps

FSTAR = $(FSTAR_EXE) $(FSTAR_FLAGS)

Expand Down
3 changes: 2 additions & 1 deletion examples/dsls/DSL.fst.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"fstar_exe": "fstar.exe",
"options": [
"--ext", "optimize_let_vc"
"--ext", "optimize_let_vc",
"--ext", "fly_deps"
],
"include_dirs": [
"bool_refinement",
Expand Down
3 changes: 2 additions & 1 deletion examples/miniparse/MiniParse.fst.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"fstar_exe": "fstar.exe",
"options": [
"--ext", "optimize_let_vc"
"--ext", "optimize_let_vc",
"--ext", "fly_deps"
],
"include_dirs": [
]
Expand Down
2 changes: 1 addition & 1 deletion examples/native_tactics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# 'include test.mk'.

FSTAR_HOME=../..
OTHERFLAGS += --ext optimize_let_vc
OTHERFLAGS += --ext optimize_let_vc --ext fly_deps
FSTAR_EXE ?= $(FSTAR_HOME)/out/bin/fstar.exe
FSTAR=$(FSTAR_EXE) $(OTHERFLAGS)

Expand Down
14 changes: 7 additions & 7 deletions examples/old/tls-record-layer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ chacha-aead-test: chacha-aead-compile
./test_chacha_aead.exe

bignum-ver:
$(FSTAR) --ext optimize_let_vc crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part1.fst --include crypto
$(FSTAR) --ext optimize_let_vc crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part2.fst --include crypto
$(FSTAR) --ext optimize_let_vc crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part3.fst --include crypto
$(FSTAR) --ext optimize_let_vc crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part4.fst --include crypto
$(FSTAR) --ext optimize_let_vc crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part5.fst --include crypto
$(FSTAR) --ext optimize_let_vc crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part6.fst --include crypto
$(FSTAR) --ext optimize_let_vc --include crypto crypto/Crypto.Symmetric.Poly1305.Bignum.fst
$(FSTAR) --ext optimize_let_vc --ext fly_deps crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part1.fst --include crypto
$(FSTAR) --ext optimize_let_vc --ext fly_deps crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part2.fst --include crypto
$(FSTAR) --ext optimize_let_vc --ext fly_deps crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part3.fst --include crypto
$(FSTAR) --ext optimize_let_vc --ext fly_deps crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part4.fst --include crypto
$(FSTAR) --ext optimize_let_vc --ext fly_deps crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part5.fst --include crypto
$(FSTAR) --ext optimize_let_vc --ext fly_deps crypto/Crypto.Symmetric.Poly1305.Bignum.Lemmas.Part6.fst --include crypto
$(FSTAR) --ext optimize_let_vc --ext fly_deps --include crypto crypto/Crypto.Symmetric.Poly1305.Bignum.fst

KRML_INCLUDES=$(addprefix -I ,spartan_aes crypto $(KRML_HOME)/krmllib $(KRML_HOME)/test)
ifeq ($(OS),Windows_NT)
Expand Down
2 changes: 1 addition & 1 deletion examples/old/tls-record-layer/crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FSTAR_HOME=../../..

FSTAR?=$(FSTAR_HOME)/bin/fstar.exe

OPTIONS=--fstar_home $(FSTAR_HOME) --max_fuel 4 --initial_fuel 0 --max_ifuel 2 --initial_ifuel 0 --z3rlimit 20 --ext optimize_let_vc $(OTHERFLAGS)
OPTIONS=--fstar_home $(FSTAR_HOME) --max_fuel 4 --initial_fuel 0 --max_ifuel 2 --initial_ifuel 0 --z3rlimit 20 --ext optimize_let_vc --ext fly_deps $(OTHERFLAGS)

FSTAR_INCLUDE_PATHS=--include $(FSTAR_HOME)/ulib/hyperstack --include hacl

Expand Down
2 changes: 1 addition & 1 deletion examples/sample_project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TOP_LEVEL_FILE=ml/main.ml
OUTPUT_DIRECTORY=_output

################################################################################
FSTAR=fstar.exe --cache_checked_modules --odir $(OUTPUT_DIRECTORY) --ext optimize_let_vc $(OTHERFLAGS)
FSTAR=fstar.exe --cache_checked_modules --odir $(OUTPUT_DIRECTORY) --ext optimize_let_vc --ext fly_deps $(OTHERFLAGS)
ML_FILES=$(addprefix $(OUTPUT_DIRECTORY)/,$(addsuffix .ml,$(subst .,_, $(subst .fst,,$(FSTAR_FILES)))))
OCAML_EXE=$(PROGRAM).ocaml.exe
KRML_EXE=$(PROGRAM).exe
Expand Down
2 changes: 2 additions & 0 deletions mk/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ else
cygpath=$(abspath $(1))
endif

FSTAR_OPTIONS += --ext fly_deps
FSTAR_ARGS += --ext fly_deps
MAKEFLAGS += --no-builtin-rules
Q?=@
SIL?=--silent
Expand Down
3 changes: 2 additions & 1 deletion src/FStarCompiler.fst.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"--lax",
"--cache_dir", "../stage1/fstarc.checked",
"--warn_error",
"-271-272-241-319-274"
"-271-272-241-319-274",
"--ext", "fly_deps"
],
"include_dirs": [
"."
Expand Down
9 changes: 6 additions & 3 deletions src/basic/FStarC.Common.fst
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ module List = FStarC.List
module BU = FStarC.Util
module SB = FStarC.StringBuffer

let snapshot (push: 'a -> 'b) (stackref: ref (list 'c)) (arg: 'a) : (int & 'b) = BU.atomically (fun () ->
let snapshot msg (push: 'a -> 'b) (stackref: ref (list 'c)) (arg: 'a) : (int & 'b) = BU.atomically (fun () ->
let len : int = List.length !stackref in
let arg' = push arg in
if FStarC.Debug.any () then Format.print2 "(%s)snapshot %s\n" msg (string_of_int len);
(len, arg'))

let rollback (pop: unit -> 'a) (stackref: ref (list 'c)) (depth: option int) =
let rollback msg (pop: unit -> 'a) (stackref: ref (list 'c)) (depth: option int) =
if FStarC.Debug.any () then Format.print2 "(%s)rollback %s ... " msg (match depth with None -> "None" | Some len ->string_of_int len);
let rec aux n : 'a =
if n <= 0 then failwith "Too many pops"
if n <= 0 then failwith "(rollback) Too many pops"
else if n = 1 then pop ()
else (ignore (pop ()); aux (n - 1)) in
let curdepth = List.length !stackref in
let n = match depth with Some d -> curdepth - d | None -> 1 in
if FStarC.Debug.any () then Format.print1 " depth is %s\n "(string_of_int (List.length (!stackref)));
BU.atomically (fun () -> aux n)

// This function is separate to make it easier to put breakpoints on it
Expand Down
4 changes: 2 additions & 2 deletions src/basic/FStarC.Common.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
module FStarC.Common
open FStarC.Effect

val snapshot (push: 'a -> 'b) (stackref: ref (list 'c)) (arg: 'a) : (int & 'b)
val snapshot (msg:string) (push: 'a -> 'b) (stackref: ref (list 'c)) (arg: 'a) : (int & 'b)

val rollback (pop: unit -> 'a) (stackref: ref (list 'c)) (depth: option int) : 'a
val rollback (msg:string) (pop: unit -> 'a) (stackref: ref (list 'c)) (depth: option int) : 'a

val runtime_assert (b:bool) (msg:string) : unit

Expand Down
2 changes: 1 addition & 1 deletion src/basic/FStarC.EditDist.fst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module FStarC.EditDist

open FStarC.Effect

let edit_distance (s1 s2 : string) : int =
let cache : IMap.t (IMap.t int) = IMap.create 10 in
Expand Down
30 changes: 10 additions & 20 deletions src/basic/FStarC.Options.fst
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ let depth () =
let lev::_ = !history in
List.length lev

let snapshot () = Common.snapshot push history ()
let rollback depth = Common.rollback pop history depth
let snapshot () = Common.snapshot "Options" push history ()
let rollback depth = Common.rollback "Options" pop history depth

let set_option k v =
let map : optionstate = peek() in
Expand Down Expand Up @@ -229,7 +229,6 @@ let defaults = [
("ide" , Bool false);
("ide_id_info_off" , Bool false);
("ifuel" , Unset);
("in" , Bool false);
("include" , List []);
("initial_fuel" , Int 2);
("initial_ifuel" , Int 1);
Expand All @@ -248,7 +247,6 @@ let defaults = [
("log_failing_queries" , Bool false);
("log_queries" , Bool false);
("log_types" , Bool false);
("lsp" , Bool false);
("max_fuel" , Int 8);
("max_ifuel" , Int 2);
("message_format" , String "auto");
Expand Down Expand Up @@ -494,10 +492,8 @@ let get_hide_uvar_nums () = lookup_opt "hide_uvar_nums"
let get_hint_info () = lookup_opt "hint_info" as_bool
let get_hint_dir () = lookup_opt "hint_dir" (as_option as_string)
let get_hint_file () = lookup_opt "hint_file" (as_option as_string)
let get_in () = lookup_opt "in" as_bool
let get_ide () = lookup_opt "ide" as_bool
let get_ide_id_info_off () = lookup_opt "ide_id_info_off" as_bool
let get_lsp () = lookup_opt "lsp" as_bool
let get_print () = lookup_opt "print" as_bool
let get_print_in_place () = lookup_opt "print_in_place" as_bool
let get_initial_fuel () = lookup_opt "initial_fuel" as_int
Expand Down Expand Up @@ -1035,26 +1031,16 @@ let specs_with_types warn_unsafe : list (char & string & opt_type & Pprint.docum
Const (Bool true),
text "Print information regarding hints (deprecated; use --query_stats instead)");

( noshort,
"in",
Const (Bool true),
text "Legacy interactive mode; reads input from stdin");

( noshort,
"ide",
Const (Bool true),
text "JSON-based interactive mode for IDEs");
text "JSON-based interactive mode for IDEs (used by VSCode, emacs, neovim, etc.)");

( noshort,
"ide_id_info_off",
Const (Bool true),
text "Disable identifier tables in IDE mode (temporary workaround useful in Steel)");

( noshort,
"lsp",
Const (Bool true),
text "Language Server Protocol-based interactive mode for IDEs");

( noshort,
"include",
ReverseAccumulated (PathStr "dir"),
Expand Down Expand Up @@ -1955,6 +1941,12 @@ let restore_cmd_line_options should_clear =
set_option' ("verify_module", List (List.map String old_verify_module));
Success

let with_restored_cmd_line_options (f:unit -> 'a) : 'a =
let snap = snapshot_all () in
let h = !history in
let _ = restore_cmd_line_options true in
finally (fun _ -> history := h; restore_all snap) f

let module_name_of_file_name f =
let f = Filepath.basename f in
let f = String.substring f 0 (String.length f - String.length (Filepath.get_file_extension f) - 1) in
Expand Down Expand Up @@ -2084,7 +2076,7 @@ let dump_module s = get_dump_module() |> List.existsb (module_
let eager_subtyping () = get_eager_subtyping()
let error_contexts () = get_error_contexts ()
let expose_interfaces () = get_expose_interfaces ()
let interactive () = get_in () || get_ide () || get_lsp ()
let interactive () = get_ide ()
let message_format () =
match get_message_format () with
| "auto" -> (
Expand Down Expand Up @@ -2138,8 +2130,6 @@ let lang_extensions () = get_lang_extensions ()
let lax () = get_lax ()
let load () = get_load ()
let load_cmxs () = get_load_cmxs ()
let legacy_interactive () = get_in ()
let lsp_server () = get_lsp ()
let log_queries () = get_log_queries ()
let log_failing_queries () = get_log_failing_queries ()
let keep_query_captions () =
Expand Down
4 changes: 1 addition & 3 deletions src/basic/FStarC.Options.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ val defaults : list (string & option_val)
val init : unit -> unit //sets the current options to their defaults
val clear : unit -> unit //wipes the stack of options, and then inits
val restore_cmd_line_options : bool -> parse_cmdline_res //inits or clears (if the flag is set) the current options and then sets it to the cmd line

val with_restored_cmd_line_options : (unit -> 'a) -> 'a
(* Control the option stack *)
(* Briefly, push/pop are used by the interactive mode and internal_*
* by #push-options/#pop-options. Read the comment in the .fs for more
Expand Down Expand Up @@ -166,8 +166,6 @@ val lang_extensions : unit -> list string
val lax : unit -> bool
val load : unit -> list string
val load_cmxs : unit -> list string
val legacy_interactive : unit -> bool
val lsp_server : unit -> bool
val log_queries : unit -> bool
val log_failing_queries : unit -> bool
val log_types : unit -> bool
Expand Down
3 changes: 1 addition & 2 deletions src/basic/FStarC.Range.Ops.fst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
Operations over the FStarC.Range.Type.range type.
*)
module FStarC.Range.Ops

open FStarC
friend FStarC.Range.Type

open FStarC
open FStarC.Json
open FStarC.Effect
open FStarC.Class.Ord
Expand Down
2 changes: 2 additions & 0 deletions src/extraction/FStarC.Extraction.ML.Modul.fst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module TcUtil = FStarC.TypeChecker.Util
module EMB = FStarC.Syntax.Embeddings
module Cfg = FStarC.TypeChecker.Cfg
module PO = FStarC.TypeChecker.Primops
module Print = FStarC.Syntax.Print

let dbg_ExtractionReify = Debug.get_toggle "ExtractionReify"

Expand Down Expand Up @@ -1322,6 +1323,7 @@ let extract' (g:uenv) (m:modul) : uenv & option mlmodule =

let extract (g:uenv) (m:modul) =
ignore <| Options.restore_cmd_line_options true;
debug g (fun _ -> Format.print1 "Starting extraction, uenv=%s\n" (show g));
let tgt =
match Options.codegen() with
| None -> failwith "Impossible: We're in extract, codegen must be set!"
Expand Down
24 changes: 24 additions & 0 deletions src/extraction/FStarC.Extraction.ML.UEnv.fst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ let plug () = Options.codegen () = Some Options.Plugin
|| Options.codegen () = Some Options.PluginNoLib
let plug_no_lib () = Options.codegen () = Some Options.PluginNoLib

instance showable_mlbinding : showable mlbinding = {
show = function
| Bv (x, _) -> show x
| Fv (x, _) -> show x
| ErasedFv x -> Format.fmt1 "Erased %s" (show x)
}

(**** Type definitions *)

(** A top-level F* type definition, i.e., a type abbreviation,
Expand Down Expand Up @@ -108,6 +115,23 @@ type uenv = {
currentModule: mlpath // needed to properly translate the definitions in the current file
}

let with_restored_tc_scope
(env:uenv)
(f:uenv -> 'a & uenv)
: 'a & uenv
= let (res, uenv'), tcenv' =
TypeChecker.Env.with_restored_scope
env.env_tcenv
(fun tcenv ->
let uenv = {env with env_tcenv=tcenv} in
let res, uenv' = f uenv in
(res, uenv'), uenv'.env_tcenv)
in
res, {uenv' with env_tcenv=tcenv'}

instance showable_uenv : showable uenv = {
show = fun e -> show e.env_bindings
}
(**** Getters and Setters *)

let tcenv_of_uenv (u:uenv) : TypeChecker.Env.env = u.env_tcenv
Expand Down
5 changes: 5 additions & 0 deletions src/extraction/FStarC.Extraction.ML.UEnv.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

module FStarC.Extraction.ML.UEnv
open FStarC
open FStarC.Class.Show
open FStarC.Effect
open FStarC.Ident
open FStarC.Extraction.ML.Syntax
Expand Down Expand Up @@ -50,6 +51,8 @@ type mlbinding =
| Fv of fv & exp_binding
| ErasedFv of fv

instance val showable_mlbinding : showable mlbinding

(** Type abbreviations, aka definitions *)
val tydef : Type0
val tydef_fv : tydef -> fv
Expand All @@ -59,6 +62,8 @@ val tydef_def: tydef -> mltyscheme

(** The main type of this module *)
val uenv : Type0
instance val showable_uenv: showable uenv
val with_restored_tc_scope (env:uenv) (f:uenv -> 'a & uenv) : 'a & uenv
val tcenv_of_uenv : u:uenv -> TypeChecker.Env.env
val set_tcenv : u:uenv -> t:TypeChecker.Env.env -> uenv
val current_module_of_uenv : u:uenv -> mlpath
Expand Down
Loading
Loading