The core OCaml system: compilers, runtime system, base libraries
  • OCaml 87.3%
  • Go Template 9%
  • Makefile 1.9%
  • Shell 1.3%
  • Dune 0.4%
Find a file
Nicolás Ojeda Bär dfe2dc1963 check-typo
2026-08-21 08:25:31 +02:00
.github Disable fail-fast on full-matrix jobs 2026-07-21 10:07:40 +01:00
api_docgen Use macros to generate installation commands 2025-12-12 12:14:09 +00:00
asmcomp RISC-V fix assembler errors when offset exceeds a 12-bit immediate (#14943) 2026-07-21 07:04:59 +02:00
boot Promote menhir to 20260209 2026-06-15 15:57:57 +02:00
build-aux Remove nested shell calls from Dune files 2026-02-08 15:22:44 +00:00
bytecomp Generate native Iatomic_fetch_add across all architectures (#14575) 2026-06-25 12:14:45 +02:00
compilerlibs Merge compilerlibs/Makefile.compilerlibs into the root Makefile 2023-10-19 11:49:11 +02:00
debugger debugger: breakpoint on tfunctor 2026-04-24 13:09:53 +02:00
driver Add Typing Recovery (#14241) 2026-05-20 15:45:59 +02:00
file_formats Implement primitive aliases (RFC #44) 2026-04-03 13:01:00 -04:00
flexdll@3400287999 Update flexdll submodule to 0.44 2025-05-14 12:29:26 +02:00
lambda switch: fix overflow on min_int 2026-07-29 17:08:26 +02:00
lex Add exhaustiveness checking for ocamllex regular expressions (#14448) 2026-02-22 15:01:49 +01:00
man Added documentation on the ocamllex -w argument in the manpage 2026-07-23 16:03:13 +02:00
manual Merge pull request #14924 from OlivierNicole/doc-domain-frontier 2026-07-15 20:11:21 +02:00
middle_end Generate native Iatomic_fetch_add across all architectures (#14575) 2026-06-25 12:14:45 +02:00
ocamldoc Add Typing Recovery (#14241) 2026-05-20 15:45:59 +02:00
ocamltest Add run_can_skip setting to ocamltest 2026-07-21 07:59:46 +01:00
otherlibs Update documentation for functions using nanosleep (#14948) 2026-07-21 13:59:10 +02:00
parsing Fix mislabeled Pmty_extension in printast dump 2026-06-25 07:56:00 +02:00
release-info Changes, News and calendar update 2026-06-22 10:55:38 +02:00
runtime fix: add missing GC root registrations for caml_sys_filepath_exists 2026-07-30 22:19:00 +02:00
stdlib check-typo 2026-08-21 08:25:31 +02:00
testsuite fix: restore 'not windows' option for file_exists.ml tests 2026-07-31 00:44:48 +02:00
tools CI on Windows: add test_in_prefix to the list of processes to clean up 2026-06-09 12:09:54 +02:00
toplevel Merge pull request #14939 from dra27/obj-hash-variant 2026-07-21 18:08:29 +01:00
typing No occurs check for generalizable variables when instantiating types (#14913) 2026-07-30 09:16:59 +09:00
utils No occurs check for generalizable variables when instantiating types (#14913) 2026-07-30 09:16:59 +09:00
yacc Use the C compiler -Wformat-signedness warning if available (#14694) 2026-04-23 10:57:47 +02:00
.depend Merge pull request #14939 from dra27/obj-hash-variant 2026-07-21 18:08:29 +01:00
.depend.menhir Add attr tracking mechanism, but don't whitelist any attrs yet 2023-10-31 13:52:44 -04:00
.editorconfig Add a .editorconfig file 2025-01-22 15:50:57 +01:00
.gitattributes unit tests for Misc.Utf8_lexeme 2026-03-06 13:05:21 +01:00
.gitignore Remove the fake ocamlyacc.opt (#14833) 2026-05-29 23:32:11 +02:00
.gitmodules Disable winpthreads compilation and remove the winpthreads submodule 2025-12-18 10:39:40 +01:00
.mailmap Merge pull request #14781 from hyphenrf/hazem/seq-perf 2026-05-01 18:02:55 +02:00
.ocp-indent Adding an ocp-indent customization file for the project. 2013-09-11 14:13:58 +00:00
aclocal.m4 Idiomatic use of LN_S in configure and Makefiles 2026-06-04 08:48:23 +02:00
AI.md Address comments 2 2026-01-21 14:46:15 +01:00
appveyor.yml Cleaner placement of AppVeyor env variable 2026-05-22 11:27:59 +02:00
BOOTSTRAP.adoc AsciiDoc: source code highlighting 2025-12-05 14:11:54 +01:00
Changes chore: update Changes entry 2026-08-21 06:14:41 +02:00
CODE_OF_CONDUCT.md Allow long lines in .md files 2022-11-28 19:40:42 +01:00
configure Overhaul locale setting for mingw/msvc 2026-07-21 07:44:34 +01:00
configure.ac Overhaul locale setting for mingw/msvc 2026-07-21 07:44:34 +01:00
CONTRIBUTING.md CONTRIBUTING.md: add MisterDA as a maintainer 2026-05-28 14:00:02 +02:00
dune Add Typing Recovery (#14241) 2026-05-20 15:45:59 +02:00
dune-project dune: continue fixing the dune build system (#14513) 2026-02-04 13:01:01 +01:00
HACKING.adoc Pin Ubuntu version in HACKING.adoc to 24.04 (#14926) 2026-07-10 11:51:12 +02:00
INSTALL.adoc install.adoc: minor edits around 'common problems' section (#14567) 2026-02-21 18:51:04 +01:00
LICENSE Update the LICENSE file to reflect new licensing conditions (LGPLv2.1) 2016-05-14 13:04:54 +02:00
Makefile Quote the variables passed to FLEXLINK_BUILD_ENV 2026-06-18 10:15:33 +02:00
Makefile.best_binaries Merge ocamldoc/Makefile.best_ocamldoc into Makefile.best_binaries 2023-10-19 19:46:39 +02:00
Makefile.build_config.in Factor selection of C compiler used to build FlexDLL 2026-06-18 10:15:33 +02:00
Makefile.common Ignore OCAMLTOP_INCLUDE_PATH in the build 2026-07-25 15:15:14 +01:00
Makefile.config.in Move the detection of tmpheader cflags, ldflags, libs to configure 2026-06-18 10:15:33 +02:00
Makefile.config_if_required Makefile.config_if_required: only load once 2022-05-26 12:12:21 +01:00
Makefile.cross Merge pull request #14850 from MisterDA/cross-compilation-fixes 2026-06-22 09:11:26 +02:00
Makefile.dev Makefile.dev: work around #13817 (#13818) 2025-04-02 22:05:18 +02:00
Makefile.menhir Makefile.menhir: fix the 'promote-menhir' target 2026-06-15 14:08:47 +02:00
ocaml-variants.install Add ocaml-variants.install 2024-09-19 18:26:00 +01:00
ocaml-variants.opam first commit after bumping version to 5.6 2026-01-26 16:39:16 +01:00
README.adoc update Changes and release after branching 2026-01-22 13:21:08 +01:00
README.win32.adoc Mention that clang-cl supports computed gotos, remove num mentions 2025-12-05 14:11:54 +01:00
VERSION first commit after bumping version to 5.6 2026-01-26 16:39:16 +01:00

= Release notes for 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 (https://www.cygwin.com[https://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
| Restrictions on generated executables? | none                   | none             | yes <<tb1,(*)>>
|=====

[[tb1]]
(*):: Executables generated by the native GCC package in Cygwin are linked with
the Cygwin DLL and require this to be distributed with your programs.
Executables generated by Microsoft Visual {cpp} or the MinGW-w64 compilers (even
when run in Cygwin as `i686-w64-mingw32-gcc` or `x86_64-w64-mingw32-gcc`) are
not linked against this DLL. Prior to Cygwin 2.5.2 (the Cygwin version can be
obtained with `uname -r`) the Cygwin DLL is distributed under the GPL, requiring
any programs linked with it to be distributed under a compatible licence. Since
version 2.5.2, the Cygwin DLL is distributed under the LGPLv3 with a static
linking exception meaning that, like executables generated by Microsoft Visual
C++ or the MinGW-w64 compilers, generated executables may be distributed under
terms of your choosing.

[[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
xref:INSTALL.adoc[] for full instructions.

OCaml requires Windows 8 or later and naturally the 64-bit versions need a
64-bit edition of Windows (note that this is both to run *and* build).

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

toc::[]

== PREREQUISITES

All the Windows ports require a Unix-like build environment.  Although other
methods are available, the officially supported environment for doing this is
64-bit (x86_64) Cygwin.

Only the `make` Cygwin package is required. `diffutils` is required if you wish
to be able to run the test suite.

Unless you are also compiling the Cygwin port of OCaml, you do not need the
`gcc-core` or `flexdll` packages.

[[bmflex]]
In addition to Cygwin, FlexDLL must also be installed, which is available from
https://github.com/ocaml/flexdll. A binary distribution is available;
instructions on how to build FlexDLL from sources, including how to bootstrap
FlexDLL and OCaml are given <<seflexdll,later in this document>>.  Unless you
bootstrap FlexDLL, you will need to ensure that the directory to which you
install FlexDLL is included in your `PATH` environment variable. Note: binary
distributions of FlexDLL are compatible only with Visual Studio 2013 and
earlier; for the MSVC port of OCaml, you will need to compile the C objects from
source, or configure ocaml with the `--with-flexdll` option.

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

== Microsoft Visual C/C++ Ports

=== REQUIREMENTS

The native-code compiler (`ocamlopt`) and static linking of OCaml bytecode with
C code (`ocamlc -custom`) require a Microsoft Visual C/C++ Compiler and the
`flexlink` tool (see <<bmflex,above>>).

The OCaml runtime requires C11 atomics, which are available in
Visual Studio 2022 (starting from release 17.8). Earlier versions (either of
Visual Studio 2022 17.7 and earlier or Visual Studio 2019 and earlier) cannot
be used to compile OCaml. In addition to the paid versions of Visual Studio,
OCaml can be compiled with either Visual Studio 2022 Community or Build Tools
for Visual Studio 2022. The following components are needed (the precise version
numbers may differ, but this should not matter):

 - MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) _for compiling with cl_
 - C++ Clang Compiler for Windows (16.0.5) _for compiling with clang-cl_
 - C++/CLI support for v143 build tools (Latest)
 - Windows 11 SDK (10.0.22621.0)


=== COMPILATION FROM THE SOURCES

The command-line tools must be compiled from the Unix source distribution
(`ocaml-X.YY.Z.tar.gz`), which also contains the files modified for Windows.
(Note: you should use cygwin's `tar` command to unpack this archive. If you
use WinZip, you will need to deselect "TAR file smart CR/LF conversion" in
the WinZip Options Window.)

Microsoft Visual C/C++ is designed to be used from special developer mode
Command Prompts which set the environment variables for the required compiler.
The easiest way to access these is via the "Visual Studio 2022" group added to
the Start Menu by the installer, for example using the
"x64 Native Tools Command Prompt for VS 2022" shortcut.

Once you have started a Command Prompt, you can verify that you have the
compiler you are expecting simply by running:

[source,console]
----
> cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33133 for x64
...
----

You then need to start Cygwin from this Command Prompt.  Assuming you have
installed it to its default location of `C:\cygwin64`, simply run:

[source,bat]
----
C:\cygwin64\bin\mintty -
----

(note the space and hyphen at the end of the command).

This should open a terminal window and start bash.  You should be able to run
`cl` from this.  You can now change to the top-level directory of the directory
of the OCaml distribution.

The Microsoft Linker is provided by a command called `link` which unfortunately
conflicts with a Cygwin command of the same name.  It is therefore necessary to
ensure that the directory containing the Microsoft C/C++ Compiler appears at
the beginning of `PATH`, before Cygwin's `/usr/bin`.  You can automate this from
the top-level of the OCaml distribution by running:

[source,sh]
----
eval $(tools/msvs-promote-path)
----

If you forget to do this, `make` will fail relatively
quickly as it will be unable to link `ocamlrun`.

For 64-bit, now run:

[source,sh]
----
./configure --build=x86_64-pc-cygwin --host=x86_64-pc-windows
----

or, for 32-bit:

[source,sh]
----
./configure --build=x86_64-pc-cygwin --host=i686-pc-windows
----

If you wish to compile with Clang, add `CC=clang-cl`.

Finally, use `make` to build the system, e.g.

[source,sh]
----
make
make install
----

After installing, it is not necessary to keep the Cygwin installation (although
you may require it to build additional third party libraries and tools).  You
will need to use `ocamlopt` (or `ocamlc -custom`) from the same Visual Studio or
Windows SDK Command Prompt as you compiled OCaml from, or `ocamlopt` will not
be able to find `cl`.

If you wish to use `ocamlopt` from Cygwin's bash on a regular basis, you may
like to copy the `tools/msvs-promote-path` script and add the `eval` line to
your `~/.bashrc` file.

* The Microsoft Visual C/C++ compiler does not implement "computed gotos" (also
  known as "labels as values"), and therefore generates inefficient code for the
  bytecode interpreter in `runtime/interp.c`.  Consequently, the performance of
  bytecode programs is about 2/3 of that obtained under Unix/GCC, Cygwin or
  MinGW-w64 on similar hardware. The clang-cl compiler supports the "computed
  gotos" extension.

* Libraries available in this port: `dynlink`, `str`, `threads`, 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.

== MinGW-w64 Ports

=== REQUIREMENTS

The native-code compiler (`ocamlopt`) and static linking of OCaml bytecode with
C code (`ocamlc -custom`) require the appropriate MinGW-w64 gcc and the
`flexlink` tool (see <<bmflex,above>>). MinGW-w64 gcc is provided by the
`mingw64-i686-gcc-core` package for 32-bit and the `mingw64-x86_64-gcc-core`
package for 64-bit.

  - The Cygwin version of flexdll does not work with this port.

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

=== COMPILATION FROM THE SOURCES

The command-line tools must be compiled from the Unix source distribution
(`ocaml-X.YY.Z.tar.gz`), which also contains the files modified for Windows.
(Note: you should use cygwin's `tar` command to unpack this archive. If you
use WinZip, you will need to deselect "TAR file smart CR/LF conversion" in
the WinZip Options Window.)

For 64-bit, now run:

[source,sh]
----
./configure --build=x86_64-pc-cygwin --host=x86_64-w64-mingw32
----

or, for 32-bit:

[source,sh]
----
./configure --build=x86_64-pc-cygwin --host=i686-w64-mingw32
----

Finally, use `make` to build the system, e.g.

[source,sh]
----
make
make install
----

After installing, you will need to ensure that `ocamlopt` (or `ocamlc -custom`)
can access the C compiler.  You can do this either by using OCaml from Cygwin's
bash or by adding Cygwin's bin directory (e.g. `C:\cygwin64\bin`) to your
`PATH`.

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

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

[[seflexdll]]
== FlexDLL
Although the core of FlexDLL is necessarily written in C, the `flexlink` program
is, naturally, written in OCaml.  This creates a circular dependency if you wish
to build entirely from sources.  Since OCaml 4.03 and FlexDLL 0.35, it is now
possible to bootstrap the two programs simultaneously.  The process is identical
for both ports.  If you choose to compile this way, it is not necessary to
install FlexDLL separately.

You must extract the FlexDLL sources for Version 0.35 or later in the directory
`flexdll/` at the top-level directory of the OCaml distribution.  This can be
done in one of three ways:

 * Extracting the sources from a tarball from
   https://github.com/ocaml/flexdll/releases
 * Cloning the git repository by running:
+
[source,sh]
----
git clone https://github.com/ocaml/flexdll.git
----

 * If you are compiling from a git clone of the OCaml repository, instead of
   using a sources tarball, you can run:
+
[source,sh]
----
git submodule update --init
----

OCaml is then compiled normally for the port you require.

[source,sh]
----
make
make install
----

 * `make install` will install FlexDLL by placing `flexlink.exe`
   (and the default manifest file for the Microsoft port) in `bin/` and the
   FlexDLL object files in `lib/`.
 * If you have populated `flexdll/`, the build will always use it, ignoring
   any externally installed FlexDLL. You can override this behaviour by either
   erasing the contents of `flexdll/` or passing the `--without-flexdll` option
   to `configure`.

== Unicode support

Prior to version 4.06, all filenames on the OCaml side were assumed
to be encoded using the current 8-bit code page of the system.  Some
Unicode filenames could thus not be represented.  Since version 4.06,
OCaml adds to this legacy mode a new "Unicode" mode, where filenames
are UTF-8 encoded strings.  In addition to filenames,
this applies to environment variables and command-line arguments.

The mode must be decided before building the system, by tweaking the
`WINDOWS_UNICODE_MODE` environment variable when calling `configure`.
The default, or a value of `compatible`, enables the new "Unicode"
mode, while a value of `ansi` maintains the legacy mode.

Technically, both modes use the Windows "wide" API, where filenames
and other strings are made of 16-bit entities, usually interpreted as
UTF-16 encoded strings.

Some more details about the two modes:

 * Unicode mode: OCaml strings are interpreted as being UTF-8 encoded
   and translated to UTF-16 when calling Windows; strings returned by
   Windows are interpreted as UTF-16 and translated to UTF-8 on their
   way back to OCaml.  Additionally, an OCaml string which is not
   valid UTF-8 will be interpreted as being in the current 8-bit code
   page.  This fallback works well in practice, since the chances of
   non-ASCII string encoded in the a 8-bit code page to be a valid
   UTF-8 string are tiny.  This means that filenames
   obtained from e.g. a 8-bit UI or database layer would continue to
   work fine.  Application written for the legacy mode or older
   versions of OCaml might still break if strings returned by
   Windows (e.g. for `Sys.readdir`) are sent to components expecting
   strings encoded in the current code page.

 * Legacy mode: this mode emulates closely the behavior of OCaml <
   4.06 and is thus the safest choice in terms of backward
   compatibility.  In this mode, OCaml programs can only work with
   filenames that can be encoded in the current code page, and the
   same applies to ocaml tools themselves (ocamlc, ocamlopt, etc).

The legacy mode will be deprecated and then removed in future versions
of OCaml.  Users are thus strongly encouraged to use the Unicode mode
and adapt their existing code bases accordingly.

Note: in order for ocaml tools to support Unicode pathnames, it is
necessary to use a version of FlexDLL which has itself been compiled
with OCaml >= 4.06 in Unicode mode.  This is the case for binary distributions
of FlexDLL starting from version 0.37 and above.

== Trademarks

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