Go to file
David Allsopp 0f3b843ba6 tools/msvs-promote-path script
Script intended to make the compilation instructions for the Microsoft
Visual C++ Compiler ports a little simpler.

This script allows the user to start Cygwin from the appropriate Visual
Studio Command Prompt (e.g. by issuing `C:\cygwin\bin\mintty -`) and then,
from the OCaml sources directory, issue

```bash
eval `tools/msvs-promote-path`
```

This script emits an error if the Microsoft Linker cannot be found in any
of the directories in `PATH` or if the `link` command already refers to the
Microsoft Linker. If, as will usually be the default, `link` refers to the
coreutils `link` command, `PATH` is altered to move the first entry
containing the Microsoft Linker to the start of `PATH`. This has the
effect of overriding the Unix interpretation of the `link` command, but
this will never affect OCaml's build process.

This script is taken from msvs-tools
(https://github.com/metastack/msvs-tools) and re-licensed by the copyright
holder.
2016-04-26 06:59:17 -04:00
asmcomp Second attempt at fixing GPR#167 fallout 2016-04-15 13:41:54 +01:00
asmrun Use configured ARCH_UINT64_TYPE, not C99 types 2016-04-04 16:09:01 +02:00
boot change VERSION for 4.03.0+beta1 2016-02-29 14:34:48 +01:00
bytecomp Fix PR#7230 2016-04-22 11:20:14 +09:00
byterun Typo in gc_ctrl.c 2016-03-28 10:09:13 +01:00
compilerlibs add a file in compilerlibs to make git happy 2016-02-19 14:12:01 +01:00
config Provide workaround for missing _vscprintf 2016-03-10 10:56:04 +01:00
debugger Pass -slash to ocamldep so that dependencies generated from a Windows system are closer to those generated from a Unix system. 2016-04-13 17:04:15 +02:00
driver Add `-alias-deps` and `-app-funct` 2016-04-19 12:21:09 -04:00
emacs Add another format to parse compiler output. 2016-03-02 17:15:10 +01:00
experimental Update headers for the new license. 2016-02-18 16:59:16 +01:00
flexdll@c041e8beef Tweaks to hiding the display of .c names with MSVC 2016-01-18 16:06:25 +00:00
lex Pass -slash to ocamldep so that dependencies generated from a Windows system are closer to those generated from a Unix system. 2016-04-13 17:04:15 +02:00
man minor ocamlc.m fix 2016-04-18 11:25:01 -04:00
manual Warning reference: make each warning a subsection for labelling 2016-04-19 12:15:14 -04:00
middle_end Array assignement primitive specialisation using the approximation 2016-04-12 14:50:01 +02:00
ocamldoc Add `-alias-deps` and `-app-funct` 2016-04-19 12:21:09 -04:00
otherlibs PR#7217: Unix.symlink does not raise on Mingw64. 2016-04-13 17:13:36 +02:00
parsing whitespace and long lines 2016-04-19 14:50:43 +02:00
stdlib Pass -slash to ocamldep so that dependencies generated from a Windows system are closer to those generated from a Unix system. 2016-04-13 17:04:15 +02:00
testsuite PR#7239: clarify Warning 42 (Disambiguated constructor or label name) 2016-04-25 18:34:54 -04:00
tools tools/msvs-promote-path script 2016-04-26 06:59:17 -04:00
toplevel Add `-alias-deps` and `-app-funct` 2016-04-19 12:21:09 -04:00
typing minor: avoid confusing then/let/seq indentation 2016-04-20 06:54:38 -04:00
utils PR#7239: clarify Warning 42 (Disambiguated constructor or label name) 2016-04-25 18:34:54 -04:00
yacc yacc/Makefile{,.nt}: merge. 2016-03-17 23:36:44 +01:00
.depend Local let exceptions. 2016-03-15 22:02:55 +01:00
.gitattributes tools/msvs-promote-path script 2016-04-26 06:59:17 -04:00
.gitignore Merge remote-tracking branch 'origin/4.03' into trunk 2016-03-11 18:44:32 +01:00
.gitmodules clean up whitespace and cut long lines 2016-02-17 13:36:27 +01:00
.mailmap minor: mailmap update 2016-03-27 17:10:30 +02:00
.merlin Add middle_end to Makefiles 2016-01-22 01:24:02 +01:00
.ocp-indent Adding an ocp-indent customization file for the project. 2013-09-11 14:13:58 +00:00
.travis-ci.sh Use the 4.03 branch of camlp4 for the travis build 2016-02-29 10:44:17 +00:00
.travis.yml Update headers for the new license. 2016-02-18 16:59:16 +01:00
CONTRIBUTING.md CONTRIBUTING: how to sign the CLA 2016-02-12 11:08:32 -05:00
Changes Fix PR#7230 2016-04-22 11:20:14 +09:00
INSTALL.adoc Remove recommendation not to use parallel make 2016-04-26 06:59:17 -04:00
LICENSE remove ocamlbuild from the compiler distribution 2016-02-01 15:05:18 -05:00
Makefile Merge remote-tracking branch 'origin/4.03' into trunk 2016-03-11 18:44:32 +01:00
Makefile.nt Pass -slash to ocamldep so that dependencies generated from a Windows system are closer to those generated from a Unix system. 2016-04-13 17:04:15 +02:00
Makefile.shared Merge branch '4.03' into trunk 2016-03-16 21:38:10 +01:00
README.adoc Move Cygwin instructions out of README.win32.adoc 2016-04-26 06:59:17 -04:00
README.win32.adoc Move Cygwin instructions out of README.win32.adoc 2016-04-26 06:59:17 -04:00
VERSION PR#6906: wrong error location for unmatched paren with #use in toplevel 2016-04-18 11:51:14 +02:00
appveyor.yml Make AppVeyor run tests 2016-02-10 14:46:39 +01:00
appveyor_build.sh Add AppVeyor testing 2016-02-10 14:46:39 +01:00
configure Remove Cygwin dependency on dos2unix 2016-04-26 06:59:17 -04:00

README.win32.adoc

= Release notes on the Microsoft Windows ports of OCaml =
:toc: macro

There are no fewer than three ports of OCaml for Microsoft Windows, each
available in 32 and 64-bit versions:

  - native Windows, built with the Microsoft C/C++ Optimizing Compiler
  - native Windows, built using the Mingw-w64 version of GCC
  - Cygwin (http://www.cygwin.com[www.cygwin.com])

Here is a summary of the main differences between these ports:

|=====
|                                        | Native Microsoft       | Native Mingw-w64 | Cygwin
4+^| Third-party software required
| for base bytecode system               | none                   | none             | none
| for ocamlc -custom                     | Microsoft Visual C++   | Cygwin           | Cygwin
| for native-code generation             | Microsoft Visual C++   | Cygwin           | Cygwin
4+^| Features
| Speed of bytecode interpreter          | 70%                    | 100%             | 100%
| Replay debugger                        | yes <<tb2,(**)>>       | yes <<tb2,(**)>> | yes
| The Unix library                       | partial                | partial          | full
| The Threads library                    | yes                    | yes              | yes
| The Graphics library                   | yes                    | yes              | no
| Restrictions on generated executables? | none                   | none             | yes <<tb1,(*)>>
|=====

[[tb1]]
(*):: Cygwin-generated .exe files refer to a DLL that is distributed under the
GPL.  Thus, these .exe files can only be distributed under a license that is
compatible with the GPL.  Executables generated by Microsoft Visual C++ or
Mingw-w64 have no such restrictions.

[[tb2]]
(**):: The debugger is supported but the "replay" functions are not enabled.
Other functions are available (step, goto, run...).

Cygwin aims to provide a Unix-like environment on Windows, and the build
procedure for it is the same as for other flavours of Unix. See
link:INSTALL.adoc[] for full instructions.

The four native Windows ports have to be built differently, and the remainder of
this document gives more information.

toc::[]

== The native Win32 port built with Microsoft Windows SDK

=== REQUIREMENTS

This port runs under MS Windows 7 (32 and 64 bits), Vista, XP, and 2000.

The base bytecode system (ocamlc, ocaml, ocamllex, ocamlyacc, ...)
runs without any additional tools.

The native-code compiler (ocamlopt) requires the Microsoft Windows SDK
(item <<tps1,[1]>>) and the flexdll tool (item <<tps2,[2]>>).

Statically linking OCaml bytecode with C code (ocamlc -custom) also requires
items <<tps1,[1]>> and <<tps2,[2]>>.

=== INSTALLATION

The binary distribution is a self-installing executable archive.
Just run it and it should install OCaml automatically.

=== THIRD-PARTY SOFTWARE

[[tps1]]
[1]:: Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 Service Pack 1.
    Can be downloaded for free from
    http://www.microsoft.com/downloads/en/default.aspx
    under the name "Microsoft Windows 7 SDK".

[[tps2]]
[2]:: flexdll version 0.31 or later.
    Can be downloaded from http://alain.frisch.fr/flexdll.html

=== RECOMPILATION FROM THE SOURCES

The command-line tools can be recompiled from the Unix source
distribution (ocaml-X.YY.Z.tar.gz), which also contains the files modified
for Windows.

You will need the following software components to perform the recompilation:

- Windows NT, 2000, XP, Vista, or 7 (32 or 64 bits).
- Items <<tps1,[1]>> and <<tps2,[2]>> from the list of recommended software
  above.
- The Cygwin port of GNU tools, available from http://www.cygwin.com/
  Install at least the following packages (and their dependencies):
  diffutils, dos2unix, gcc-core, make, ncurses.

First, you need to set up your cygwin environment for using the MS
tools.  The following assumes that you have installed <<tps1,[1]>>,
<<tps2,[2]>>, and [3] in their default directories.  If this is not
the case, you will need to adjust the paths accordingly.

. Open a Windows Command Prompt and enter the following command:

    set PFPATH=C:\Program Files

. If you are compiling on the 64-bit version of Windows 7, enter the
  following instead:

    set PFPATH=C:\Program Files (x86)

. Then enter the following commands:

    cd "%PFPATH%\Microsoft Visual Studio 9.0\VC\bin"
    set FLEXDLLDIR=%PFPATH%\flexdll
    vcvars32
    echo VCPATH="`cygpath -p '%Path%'`" >C:\cygwin\tmp\msenv
    echo LIB="%LIB%" >>C:\cygwin\tmp\msenv
    echo LIBPATH="%LIBPATH%" >>C:\cygwin\tmp\msenv
    echo INCLUDE="%INCLUDE%;%FLEXDLLDIR%" >>C:\cygwin\tmp\msenv
    echo FLPATH="`cygpath '%FLEXDLLDIR%'`" >>C:\cygwin\tmp\msenv
    echo PATH="$VCPATH:$FLPATH:$PATH" >>C:\cygwin\tmp\msenv
    echo export PATH LIB LIBPATH INCLUDE >>C:\cygwin\tmp\msenv
    echo export OCAMLBUILD_FIND=/usr/bin/find >>C:\cygwin\tmp\msenv

. Open a Cygwin shell and enter the following commands:

    tr -d '\r' </tmp/msenv >.msenv32
    echo '. $HOME/.msenv32' >>.bashrc

Now, close the Command Prompt and the shell and you're set up for
using the MS tools under Cygwin.


To recompile OCaml, start a new Cygwin shell and change to the top-level
directory of the OCaml distribution.  Then, do

        cp config/m-nt.h config/m.h
        cp config/s-nt.h config/s.h
        cp config/Makefile.msvc config/Makefile

Then, edit config/Makefile as needed, following the comments in this file.
Normally, the only variable that need to be changed is

        PREFIX      where to install everything

Finally, use `make -f Makefile.nt` to build the system, e.g.

        make -f Makefile.nt world
        make -f Makefile.nt bootstrap
        make -f Makefile.nt opt
        make -f Makefile.nt opt.opt
        make -f Makefile.nt install

=== NOTES

* The VC++ compiler does not implement "computed gotos", and therefore
generates inefficient code for 'byterun/interp.c'. Consequently, the
performance of bytecode programs is about 2/3 of that obtained under
Unix/GCC or Cygwin or Mingw on similar hardware.

* Libraries available in this port: `num`, `str`, `threads`, `graphics`,
and large parts of `unix`.

* The replay debugger is partially supported (no reverse execution).

=== CREDITS

The initial port of Caml Special Light (the ancestor of OCaml) to
Windows NT was done by Kevin Gallo at Microsoft Research, who kindly
contributed his changes to the OCaml project.


== The native Win32 and Win64 ports built with Mingw

=== REQUIREMENTS

Those ports run under MS Windows Seven, Vista, XP, and 2000.

The base bytecode system (ocamlc, ocaml, ocamllex, ocamlyacc, ...)
runs without any additional tools.

The native-code compiler (ocamlopt), as well as static linking of
OCaml bytecode with C code (ocamlc -custom), require
the Cygwin development tools, available at
        http://www.cygwin.com/
and the flexdll tool, available at
        http://alain.frisch.fr/flexdll.html
You will need to install at least the following Cygwin packages for
the 32-bit flavor (use the Setup tool from Cygwin):

 mingw64-i686-binutils
 mingw64-i686-gcc-core
 mingw64-i686-runtime

and the following packages for the 64-bit:

 mingw64-x86_64-binutils
 mingw64-x86_64-gcc-core
 mingw64-x86_64-runtime

=== NOTES

  - Do not use the Cygwin version of flexdll for this port.

  - There is another 32-bit gcc compiler, from the MinGW.org
    project, packaged in Cygwin under the name mingw-gcc.
    It is not currently supported by flexdll and OCaml.

  - The standard gcc compiler shipped with Cygwin used to
    support a `-mno-cygwin` option, which turned the compiler
    into a mingw compiler. This option was used
    by previous versions of flexdll and OCaml, but it is no
    longer available in recent version, hence the switch
    to another toolchain packaged in Cygwin.

  - The standalone mingw toolchain from the MinGW-w64 project
    (http://mingw-w64.org/) is not supported. Please use the
    version packaged in Cygwin instead.

=== INSTALLATION

The binary distribution is a self-installing executable archive.
Just run it and it should install OCaml automatically.


=== RECOMPILATION FROM THE SOURCES

You will need the following software components to perform the recompilation:
- Windows NT, 2000, XP, Vista, or Seven.
- Cygwin: http://cygwin.com/
  Install at least the following packages (and their dependencies, as
  computed by Cygwin's setup.exe):

  * For both flavor of OCaml (32-bit and 64-bit):

     diffutils
     make
     ncurses

  * For the 32 bit flavor of OCaml:

     mingw64-i686-binutils
     mingw64-i686-gcc-core
     mingw64-i686-runtime

  * For the 64 bit flavor of OCaml:

     mingw64-x86_64-binutils
     mingw64-x86_64-gcc-core
     mingw64-x86_64-runtime

- The flexdll tool (see above).  Do not forget to add the flexdll directory
  to your PATH

The standalone mingw toolchain from the MinGW-w64 project
(http://mingw-w64.org/) is not supported.  Please use the
version packaged in Cygwin instead.

Start a new Cygwin shell and unpack the source distribution
(ocaml-X.YY.Z.tar.gz) with `tar xzf`.  Change to the top-level
directory of the OCaml distribution.  Then, do

        cp config/m-nt.h config/m.h
        cp config/s-nt.h config/s.h

For a 32 bit OCaml:

        cp config/Makefile.mingw config/Makefile

For a 64 bit OCaml:

        cp config/Makefile.mingw64 config/Makefile

Then, edit config/Makefile as needed, following the comments in this file.
Normally, the only variable that need to be changed is

        PREFIX      where to install everything

Finally, use `make -f Makefile.nt` to build the system, e.g.

        make -f Makefile.nt world
        make -f Makefile.nt bootstrap
        make -f Makefile.nt opt
        make -f Makefile.nt opt.opt
        make -f Makefile.nt install


=== NOTES

* Libraries available in this port: `num`, `str`, `threads`, `graphics`,
  and large parts of `unix`.

* The replay debugger is partially supported (no reverse execution).

* The default Makefile.mingw and Makefile.mingw64 pass `-static-libgcc` to
  the linker.
  For more information on this topic:

  - http://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Link-Options.html#Link-Options
  - http://caml.inria.fr/mantis/view.php?id=6411

== The native Win64 port built with Microsoft Windows SDK

=== REQUIREMENTS

This port runs under MS Windows XP 64, Windows Server 64, and
Windows 7 64 on Intel64/AMD64 machines.

The base bytecode system (ocamlc, ocaml, ocamllex, ocamlyacc, ...)
runs without any additional tools.

Statically linking OCaml bytecode with C code (ocamlc -custom) requires the
Microsoft Platform SDK compiler (item <<tps-native1,[1]>> in the section
"third-party software" below) and the flexdll tool (item <<tps-native2,[2]>>).

The native-code compiler (ocamlopt) requires the Microsoft compiler
and the Microsoft assembler MASM64 (item link:tps-native1[(1(])
and the flexdll tool (item <<tps-native2,[2]>>).

=== INSTALLATION:

There is no binary distribution yet.  Please compile from sources as
described below.


=== THIRD-PARTY SOFTWARE

[[tps-native1]]
[1]:: Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 Service Pack 1.
    Can be downloaded for free from
    http://www.microsoft.com/downloads/en/default.aspx
    under the name "Microsoft Windows 7 SDK".

[[tps-native2]]
[2]:: flexdll version 0.31 or later.
    Can be downloaded from http://alain.frisch.fr/flexdll.html


=== RECOMPILATION FROM THE SOURCES

The command-line tools can be recompiled from the Unix source
distribution ('ocaml-X.YZ.tar.gz'), which also contains the files modified
for Windows.

You will need the following software components to perform the recompilation:
- Windows XP 64, Windows Server 64, or Windows 7 64.
- Items <<tps-native1,[1]>> and <<tps-native2,[2]>> from the list of
  recommended software above.
- The Cygwin port of GNU tools, available from http://www.cygwin.com/
  Install at least the following packages: diffutils, make, ncurses.

First, you need to set up your cygwin environment for using the MS
tools.  The following assumes that you have installed <<tps-native1,[1]>>
and <<tps-native2,[2]>> in their default directories.  If this is not
the case, you will need to adjust the paths accordingly.

. Open a Windows Command Prompt and enter the following commands:

    set PFPATH=C:\Program Files (x86)
    cd "%PFPATH%\Microsoft Visual Studio 9.0\VC\bin"
    vcvars64
    echo VCPATH="`cygpath -p '%Path%'`" >C:\cygwin\tmp\msenv
    echo LIB="%LIB%" >>C:\cygwin\tmp\msenv
    echo LIBPATH="%LIBPATH%" >>C:\cygwin\tmp\msenv
    echo INCLUDE="%INCLUDE%" >>C:\cygwin\tmp\msenv
    echo FLPATH="`cygpath '%PFPATH%\flexdll'`" >>C:\cygwin\tmp\msenv
    echo PATH="$VCPATH:$FLPATH:$PATH" >>C:\cygwin\tmp\msenv
    echo export PATH LIB LIBPATH INCLUDE >>C:\cygwin\tmp\msenv
    echo export OCAMLBUILD_FIND=/usr/bin/find >>C:\cygwin\tmp\msenv

. Open a Cygwin shell and enter the following commands:

    tr -d '\r' </tmp/msenv >.msenv64
    echo '. $HOME/.msenv64' >>.bashrc

Now, close the Command Prompt and the shell and you're set up for
using the MS tools under Cygwin.


To recompile OCaml, start a new Cygwin shell and change to the top-level
directory of the OCaml distribution.  Then, do

        cp config/m-nt.h config/m.h
        cp config/s-nt.h config/s.h
        cp config/Makefile.msvc64 config/Makefile

Then, edit config/Makefile as needed, following the comments in this file.
Normally, the only variable that need to be changed is

        PREFIX      where to install everything

Finally, use `make -f Makefile.nt` to build the system, e.g.

        make -f Makefile.nt world
        make -f Makefile.nt bootstrap
        make -f Makefile.nt opt
        make -f Makefile.nt opt.opt
        make -f Makefile.nt install


=== NOTES

* Libraries available in this port: `num`, `str`, `threads`, `graphics`,
  and large parts of `unix`.

* The replay debugger is partially supported (no reverse execution).

* The graphical browser ocamlbrowser is not supported.

== Trademarks

Microsoft, Visual C++, Visual Studio and Windows are registered trademarks of
Microsoft Corporation in the United States and/or other countries.