| 1 |
= http://mlton.org[MLton] |
| 2 |
|
| 3 |
ifdef::env-github[] |
| 4 |
image:https://github.com/MLton/mlton/actions/workflows/ci.yml/badge.svg[CI, link = https://github.com/MLton/mlton/actions/workflows/ci.yml] |
| 5 |
endif::[] |
| 6 |
|
| 7 |
**** |
| 8 |
MLton is a whole-program optimizing compiler for the Standard{nbsp}ML |
| 9 |
programming language. MLton generates small executables with |
| 10 |
excellent runtime performance, utilizing untagged and unboxed native |
| 11 |
integers, reals, and words, unboxed native arrays, fast |
| 12 |
arbitrary-precision arithmetic based on GMP, and multiple code |
| 13 |
generation and garbage collection strategies. In addition, MLton |
| 14 |
provides a feature rich Standard{nbsp}ML programming environment, with |
| 15 |
full support for SML97 as given in The Definition of Standard{nbsp}ML |
| 16 |
(Revised), a number of useful language extensions, a complete |
| 17 |
implementation of the Standard ML Basis Library, various useful |
| 18 |
libraries, a simple and fast C foreign function interface, the ML |
| 19 |
Basis system for programming with source libraries, and tools such as |
| 20 |
a lexer generator, a parser generator, and a profiler. |
| 21 |
**** |
| 22 |
|
| 23 |
|
| 24 |
== Features |
| 25 |
|
| 26 |
* Robustness. |
| 27 |
|
| 28 |
- Supports the full SML{nbsp}97 language as given in The Definition of Standard{nbsp}ML (Revised). |
| 29 |
- A complete implementation of the http://sml-family.org/Basis/[Basis Library]. |
| 30 |
- Generates standalone executables. |
| 31 |
- Compiles large programs. |
| 32 |
- Support for large amounts of memory (up to 4G on 32-bit systems; |
| 33 |
more on 64-bit systems). |
| 34 |
- Support for large array lengths (up to 2^31^ - 1 on 32-bit systems; |
| 35 |
up to 2^63^-1 on 64-bit systems). |
| 36 |
- Support for large files, using 64-bit file positions. |
| 37 |
|
| 38 |
* Performance. |
| 39 |
|
| 40 |
- Executables have excellent runtime performance. |
| 41 |
- Generates small executables. |
| 42 |
- Untagged and unboxed native integers, reals, and words. |
| 43 |
- Unboxed native arrays. |
| 44 |
- Multiple garbage collection strategies. |
| 45 |
- Fast arbitrary-precision arithmetic based on https://gmplib.org[GMP]. |
| 46 |
|
| 47 |
* Tools. |
| 48 |
|
| 49 |
- Source-level http://mlton.org/Profiling[profiling] for both time and allocation. |
| 50 |
- MLLex lexer generator. |
| 51 |
- MLYacc parser generator. |
| 52 |
- MLNLFFIGEN foreign-function-interface generator. |
| 53 |
|
| 54 |
* Extensions. |
| 55 |
|
| 56 |
- The http://mlton.org/MLBasis[ML Basis system] for programming with source libraries. |
| 57 |
- A number of useful http://mlton.org/SuccessorML[language extensions]. |
| 58 |
- A simple and fast http://mlton.org/ForeignFunctionInterface[C FFI] that supports calling from SML to C and from C to SML. |
| 59 |
- Libraries for http://mlton.org/MLtonWeak[weak pointers] and http://mlton.org/MLtonFinalizable[finalization], http://mlton.org/MLtonThread[threads], http://mlton.org/MLtonCont[continuations], http://mlton.org/MLtonItimer[interval timers] and http://mlton.org/MLtonSignal[signal handlers], http://mlton.org/MLtonWorld[world save and restore], and http://mlton.org/MLtonStructure[more]. |
| 60 |
|
| 61 |
* Portability. |
| 62 |
|
| 63 |
- Runs on a wide variety of platforms. |
| 64 |
|
| 65 |
|
| 66 |
== Build and Install (from source) |
| 67 |
|
| 68 |
=== Requirements |
| 69 |
|
| 70 |
==== Software |
| 71 |
|
| 72 |
* http://gcc.gnu.org/[GCC] or http://clang.llvm.org[Clang] (The C compiler must support `-std=gnu11`.) |
| 73 |
* http://gmplib.org[GMP] (GNU Multiple Precision arithmetic library) |
| 74 |
* http://savannah.gnu.org/projects/make[GNU Make] |
| 75 |
* http://www.gnu.org/software/bash/[GNU Bash] |
| 76 |
* binutils (`ar`, `ranlib`, `strip`, ...) |
| 77 |
* miscellaneous Unix utilities (`diff`, `find`, `grep`, `gzip`, `patch`, `sed`, `tar`, ...) |
| 78 |
* Standard{nbsp}ML compiler to bootstrap: |
| 79 |
- http://mlton.org[MLton] (`mlton`) recommended. Pre-built binary packages for MLton can be installed via an OS package manager or (for select platforms) obtained from `http://mlton.org`. |
| 80 |
- http://www.smlnj.org[SML/NJ] (`sml`) supported, but not recommended. |
| 81 |
- https://polyml.org[Poly/ML] (`polyc`) supported, but not recommended. |
| 82 |
- https://elsman.com/mlkit[MLKit] (`mlkit`) supported, but not recommended. |
| 83 |
* (optional, for documentation only) https://ctan.org/tex/[TeX], http://asciidoctor.org/[AsciiDoctor], http://rouge.jneen.net/[Rouge], http://www.graphicsmagick.org/[GraphicsMagick] or https://www.imagemagick.org/[ImageMagick], ... |
| 84 |
|
| 85 |
==== Hardware |
| 86 |
|
| 87 |
* ≥ 1GB RAM (for 32-bit platforms) or ≥ 2GB RAM (for 64-bit platforms) |
| 88 |
|
| 89 |
=== Build Instructions |
| 90 |
|
| 91 |
On typical platforms, building MLton requires no configuration and can be |
| 92 |
accomplished via: |
| 93 |
|
| 94 |
[source,shell] |
| 95 |
---- |
| 96 |
$ make all |
| 97 |
---- |
| 98 |
|
| 99 |
A small set of `Makefile` variables can be used to customize the build: |
| 100 |
|
| 101 |
* `CC`: Specify C compiler. Can be used for alternative tools (e.g., |
| 102 |
`CC=clang` or `CC=gcc-7`). |
| 103 |
* `WITH_GMP_DIR`, `WITH_GMP_INC_DIR`, `WITH_GMP_LIB_DIR`: Specify GMP include |
| 104 |
and library paths, if not on default search paths. (If `WITH_GMP_DIR` is |
| 105 |
set, then `WITH_GMP_INC_DIR` defaults to `$(WITH_GMP_DIR)/include` and |
| 106 |
`WITH_GMP_LIB_DIR` defaults to `$(WITH_GMP_DIR)/lib`.) |
| 107 |
* `MLTON_RUNTIME_ARGS`, `MLTON_COMPILE_ARGS`: Specify runtime and compile |
| 108 |
arguments given to (the to-be-built) `mlton` when compiling distributed |
| 109 |
executables ((self-compiled) `mlton`, `mllex`, `mlyacc`, `mlprof`, and |
| 110 |
`mlnlffigen`). Can be used for testing (e.g., `MLTON_COMPILE_ARGS="-codegen |
| 111 |
c"`) or for downstream packaging. |
| 112 |
* `OLD_MLTON_RUNTIME_ARGS`, `OLD_MLTON_COMPILE_ARGS`: Specify runtime and |
| 113 |
compile arguments given to "old" `mlton` when compiling "new" `mlton`. Can be |
| 114 |
used to work around bugs in "old" `mlton` when compiling "new" `mlton`. |
| 115 |
|
| 116 |
For example: |
| 117 |
|
| 118 |
[source,shell] |
| 119 |
---- |
| 120 |
$ make CC=clang WITH_GMP_DIR=/opt/gmp MLTON_COMPILE_ARGS="-codegen c" all |
| 121 |
---- |
| 122 |
|
| 123 |
The build artifacts are located under `./build`. The just-built `mlton` can be |
| 124 |
executed via `./build/bin/mlton`. |
| 125 |
|
| 126 |
Building documentation can be accomplished via: |
| 127 |
|
| 128 |
[source,shell] |
| 129 |
---- |
| 130 |
$ make docs |
| 131 |
---- |
| 132 |
|
| 133 |
=== Install Instructions |
| 134 |
|
| 135 |
On typical platforms, installing MLton (after performing `make all` and, |
| 136 |
optionally, `make docs`) to `/usr/local` can be accomplished via: |
| 137 |
|
| 138 |
[source,shell] |
| 139 |
---- |
| 140 |
$ make install |
| 141 |
---- |
| 142 |
|
| 143 |
A small set of `Makefile` variables can be used to customize the installation: |
| 144 |
|
| 145 |
* `PREFIX`: Specify the installation prefix. |
| 146 |
|
| 147 |
For example: |
| 148 |
|
| 149 |
[source,shell] |
| 150 |
---- |
| 151 |
$ make PREFIX=/opt/mlton install |
| 152 |
---- |
| 153 |
|
| 154 |
|
| 155 |
== Install (from binary package) |
| 156 |
|
| 157 |
=== Requirements |
| 158 |
|
| 159 |
==== Software |
| 160 |
|
| 161 |
* http://gcc.gnu.org/[GCC] or http://clang.llvm.org[Clang] (The C compiler must support `-std=gnu11`.) |
| 162 |
* http://gmplib.org[GMP] (GNU Multiple Precision arithmetic library) |
| 163 |
* http://savannah.gnu.org/projects/make[GNU Make] |
| 164 |
* miscellaneous Unix utilities (`bzip2`, `gzip`, `sed`, `tar`, ...) |
| 165 |
|
| 166 |
=== Binary Package |
| 167 |
|
| 168 |
A `.tgz` or `.tbz` binary package can be extracted at any location, yielding |
| 169 |
`README.adoc` (this file), `CHANGELOG.adoc`, `LICENSE`, `Makefile`, `bin/`, |
| 170 |
`lib/`, and `share/`. The compiler and tools can be executed in-place (e.g., |
| 171 |
`./bin/mlton`). |
| 172 |
|
| 173 |
A small set of `Makefile` variables can be used to customize the binary package |
| 174 |
via `make update`: |
| 175 |
|
| 176 |
* `CC`: Specify C compiler. Can be used for alternative tools (e.g., |
| 177 |
`CC=clang` or `CC=gcc-7`). |
| 178 |
* `WITH_GMP_DIR`, `WITH_GMP_INC_DIR`, `WITH_GMP_LIB_DIR`: Specify GMP include |
| 179 |
and library paths, if not on default search paths. (If `WITH_GMP_DIR` is |
| 180 |
set, then `WITH_GMP_INC_DIR` defaults to `$(WITH_GMP_DIR)/include` and |
| 181 |
`WITH_GMP_LIB_DIR` defaults to `$(WITH_GMP_DIR)/lib`.) |
| 182 |
|
| 183 |
For example: |
| 184 |
|
| 185 |
[source,shell] |
| 186 |
---- |
| 187 |
$ make CC=clang WITH_GMP_DIR=/opt/gmp update |
| 188 |
---- |
| 189 |
|
| 190 |
=== Install Instructions |
| 191 |
|
| 192 |
On typical platforms, installing MLton (after optionally performing |
| 193 |
`make update`) to `/usr/local` can be accomplished via: |
| 194 |
|
| 195 |
[source,shell] |
| 196 |
---- |
| 197 |
$ make install |
| 198 |
---- |
| 199 |
|
| 200 |
A small set of `Makefile` variables can be used to customize the installation: |
| 201 |
|
| 202 |
* `PREFIX`: Specify the installation prefix. |
| 203 |
|
| 204 |
For example: |
| 205 |
|
| 206 |
[source,shell] |
| 207 |
---- |
| 208 |
$ make PREFIX=/opt/mlton install |
| 209 |
---- |
| 210 |
|
| 211 |
|
| 212 |
== Resources |
| 213 |
|
| 214 |
* `http://mlton.org` |
| 215 |
* Development |
| 216 |
- `https://github.com/MLton/mlton` |
| 217 |
- https://github.com/MLton/mlton/pulls[pull requests] |
| 218 |
- https://github.com/MLton/mlton/issues[issue tracker] |
| 219 |
* Mailing lists |
| 220 |
- `[email protected]` -- MLton developers |
| 221 |
(https://sourceforge.net/mailarchive/forum.php?forum_name=mlton-devel[archive], |
| 222 |
https://lists.sourceforge.net/lists/listinfo/mlton-devel[subscribe]) |
| 223 |
- `[email protected]` -- MLton user community |
| 224 |
(https://sourceforge.net/mailarchive/forum.php?forum_name=mlton-user[archive], |
| 225 |
https://lists.sourceforge.net/lists/listinfo/mlton-user[subscribe]) |
| 226 |
|
| 227 |
|
| 228 |
== Support and Contributing |
| 229 |
|
| 230 |
To report bugs or suggest new features, use the |
| 231 |
https://github.com/MLton/mlton/issues[issue tracker] or ask on the |
| 232 |
mailto:[email protected][mailing list]. |
| 233 |
|
| 234 |
https://github.com/MLton/mlton/pulls[Pull requests] with bug fixes or |
| 235 |
changes are welcome. |