F# 3.1 Compiler matching Visual Studio 2013 RTM binary release
This directory contains a drop of the source code for an F# 3.1 compiler and core library.
The code has been cleaned up "a little" to try to help ensure better stability as
more development is done on the codebase.
The compiler is normally compiled as a set of .NET 4.0 components.
Before we start, are sure you're in the right place?
To emphasize, this distribution should not be seen as a way to "get" an F#
compiler for immediate use. For that you're better going to fsharp.org.
License: subject to terms and conditions of the Apache License, Version 2.0. A
copy of the license can be found in the License.html file at the root of this distribution.
By using this source code in any fashion, you are agreeing to be bound
by the terms of the Apache License, Version 2.0. You must not remove this notice, or any other, from this software.
Questions? If you have questions about the source code, please ask at the F# Open Source Google Group.
Please do not ask the F# team at Microsoft for
help with this source code: they like to be friendly, but they are very busy
working on improving F# and need to focus on that.
Updates? The F# team do not do active development in open repositories,
though some changes such as cleanup or additional tools may be submitted. They
aspire to update the code drop when future versions of F# compilers are
released from Microsoft, usually at or around the RTM stage.
Copyright: Copyright 2002-2012 (c) Microsoft Corporation.
What do I get when I compile?
When you build the compiler using the standard instructions below, you get fsc.exe, fsi.exe, FSharp.Core.dll, FSharp.Compiler.dll and some related DLLs.
The compiler binaries produced are "private" and
strong-named signed with a test key (src\fsharp\test.snk). They use CLI
assembly version nunmber 2.9.9.999. You can place these components in
the GAC but they will not replace
the components used by normal Visual Studio or normal F# programs.
Steps - Building a Proto Compiler
cd src
gacutil /i ..\lkg\FSharp-2.0.50726.900\bin\FSharp.Core.dll
msbuild fsharp-proto-build.proj
Note: Make sure you run the .NET 4.0 msbuild.exe, e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.
Optional: NGEN the Proto Compiler for faster future startup (optional)
ngen install ..\Proto\net40\bin\fsc-proto.exe
Steps - Building the F# Core Library
This uses the proto compiler to build the FSharp.Core library, for Mono/.NET 4.0.
msbuild fsharp-library-build.proj /p:TargetFramework=net40
msbuild fsharp-library-build.proj /p:TargetFramework=net20
Note: Make sure you run the .NET 4.0 msbuild.exe, e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.
Steps - Building the F# Compiler
This uses the proto compiler to build the FSharp.Compiler.dll and fsc.exe to run on for Mono/.NET 4.0.
msbuild fsharp-compiler-build.proj /p:TargetFramework=net40
Note: Make sure you run the .NET 4.0 msbuild.exe, e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.
Notes on the build
The prerequisites and build command line for compiling the source (on Windows) are shown
later in this README. Here's the logic of the build:
- We first need an existing F# compiler, using the one in the 'lkg'
directory. Let's assume this compiler has an FSharp.Core.dll with
version X.
- We use this compiler to compile the source in this distribution, to produce a "proto" compiler, in the Proto
directory. When run, this compiler still relies on the FSharp.Core.dll with version X.
- We use the proto compiler to compile the source for FSharp.Core.dll in this distribution, producing
an FSharp.Core.dll with the version identified in src\source-build-version, usually 1.9.999.
- We use the proto compiler to compile the source for FSharp.Compiler.dll, fsc.exe, fsi.exe and other
binaries found in this distribution. When run, these binaries will rely on the FSharp.Core.dll with version
1.9.999. This is good, since it means the 1.9.999 binaries now form a consistent, bootstrapped compiler. If
you like you should now be able to throw away the compiler with version X.
Some additional tools are required to build the compiler, notably fslex.exe, fsyacc.exe,
FSharp.PowerPack.Build.Tasks.dll, FsSrGen.exe, FSharp.SRGen.Build.Tasks.dll and the other
tools found in the lkg directory. These are "Last Known Good" binaries created from a version of the F# Power Pack
on CodePlex. If you like you can throw away these binaries and use your own compiled versions of these.
tools.
Use
Here are some simple tests to validate what you have built by checking fsi.exe (F# Interactive) starts up:
ngen install ..\Debug\net40\bin\fsi.exe
..\Debug\net40\bin\fsi.exe
1 + 1;;
#q;;
..\Debug\net40\bin\fsi.exe /help
..\Debug\net40\bin\fsc.exe /help
echo printfn "hello world" > hello.fs
..\Debug\net40\bin\fsc.exe hello.fs
copy ..\Debug\net40\bin\FSharp.Core.dll .
hello.exe
del /q FSharp.Core.dll
Some alternative Steps - Building an optimized (Release) compiler for .NET 4.0 profile
msbuild fsharp-compiler-build.proj /p:TargetFramework=net40 /p:Configuration=Release
ngen install ..\Release\net40\bin\fsi.exe
..\Release\net40\bin\fsi.exe
1 + 1;;
#q;;
..\Release\net40\bin\fsi.exe /help
..\Release\net40\bin\fsc.exe /help
echo printfn "hello world" > hello.fs
..\Release\net40\bin\fsc.exe hello.fs
copy ..\Release\net40\bin\FSharp.Core.dll .
hello.exe
del /q FSharp.Core.dll