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

fstar.exe is no longer buildable in F# as a .NET executable #2512

Merged
merged 20 commits into from
Mar 30, 2022

Conversation

nikswamy
Copy link
Collaborator

For several years now, we have been using F* after bootstrapping it in OCaml. However, the sources of F* were also compilable in F# (since the sources were in a shared subset of F* and F#), but the F# version lacked many features of the official OCaml version of F*, including basic things checked files and native plugins, and besides had many other unpredictable discrepancies.

So, with this PR, we finally break the ability to compile F* as a .NET executable.

Note, this does not mean that we are de-prioritizing the use of F* in .NET scenarios. F* still very much supports the --codegen FSharp option, the standard library is built after extraction to F# as a .NET dll (ulibfs.dll), and sample solution files in examples/{algorithms, data_structures, hello} all illustrate how to use F* files within an F# project.

The main changes in this PR:

  • All .fs/.fsi source files are renamed to .fst/.fsti
  • .fsproj and .sln files are removed in src
  • we retain .fsproj and .sln files in ulib/fs
  • Build hacks to pre-process .fs files into .fst files are gone

FStar_Integers.fs \
FStar_Ref.fs

all-fs: $(addprefix $(OUTPUT_DIRECTORY)/, $(FS_FILES))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mateuszbujalski , I now extract files from F* to fs with this Makefile

@@ -87,7 +89,7 @@

<!-- Run extraction for .fst files -->
<!-- TODO: What about interfaces? Should we at least run verification for them? -->
<Exec ConsoleToMsBuild="true" Condition="'%(Compile.Extension)' == '.fst'" Command="$(FSTAR_EXE) $(FSTAR_WARN_ERROR) $(FSTAR_EXTRACTION_FLAGS) $(FSTAR_FLAGS) %(Compile.Identity) --extract &quot;+%(Compile.Filename)&quot;" IgnoreStandardErrorWarningFormat="true" />
<Exec ConsoleToMsBuild="true" Condition="'%(Compile.Extension)' == '.fst'" Command="$(CALL_PROC_EXE) $(FSTAR_EXE) $(FSTAR_WARN_ERROR) $(FSTAR_EXTRACTION_FLAGS) $(FSTAR_FLAGS) %(Compile.Identity) --extract &quot;+%(Compile.Filename)&quot;" IgnoreStandardErrorWarningFormat="true" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mateuszbujalski @kant2002

I retained a version of fsharp.extraction.targets, but wrapped it with CallProc, a small .NET program I wrote to wrap the call to a native fstar.exe. This works on both Windows & Linux

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a way to make this work on Linux without the CallProc wrapper that would be great ... happy to have a PR for that

<OutputType>Exe</OutputType>
<RootNamespace>CallProc</RootNamespace>
<AssemblyName>CallProc</AssemblyName>
<OtherFlags>--nowarn:0086 --mlcompatibility --nologo</OtherFlags>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important! Otherwise, if the environment sets the OTHERFLAGS variable (which our build scripts routinely do) then the value of that variable is passed to fsc. So, you must set here. Crazy, but true.


# --------------------------------------------------------------------
nuget-restore:
$(RUNTIME) VS/.nuget/NuGet.exe restore VS/FStar.sln
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F#-specific stuff is gone

boot_dir:
mkdir -p boot

boot: $(ALL_BOOT)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patching files and copying them to boot is gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant