MLton

MLton存储库。MLton是针对标准ML编程语言的全程序优化编译器。「The MLton repository. MLton is a whole-program optimizing compiler for the Standard ML programming language.」

Github stars Tracking Chart

MLton

MLton 是一个用于标准 ML 编程语言的全程序优化编译器。MLton 利用未标记和未封装的本机整数、实数和单词、未封装的本机数组、基于 GMP 的快速任意精度算法以及多种代码生成和垃圾收集策略,生成具有卓越运行时性能的小型可执行文件。此外,MLton 提供了一个功能丰富的标准 ML 编程环境,完全支持标准 ML 定义(修订)中给出的 SML97,许多有用的语言扩展,Standard ML Basis Library 的完整实现,各种有用的库,简单、快速的 C 外部函数接口,用于使用源库进行编程的 ML Basis 系统以及诸如 lexer 生成器、解析器生成器和分析器之类的工具。

特性

  • 坚固性。
    • 支持标准 ML 的定义(修订)中给出的完整 SML 97 语言。
    • 基础库的完整实现。
    • 生成独立的可执行文件。
    • 编译大型程序。
    • 支持大量内存(在 32 位系统上最多 4G;在 64 位系统上更多)。
    • 支持大数组长度(在 32 位系统上最多 231-1;在 64 位系统上最多 263-1)。
    • 支持大文件,使用 64 位文件位置。
  • 性能。
    • 可执行文件具有出色的运行时性能。
    • 生成小型可执行文件。
    • 未标记和未装箱的本机整数,实数和单词。
    • 未装箱的本机阵列。
    • 多种垃圾收集策略。
    • 基于 GMP 的快速任意精度算法。
  • 工具。
    • 时间和分配的源代码级分析。
    • MLLex 词法分析器生成器。
    • MLYacc 解析器生成器。
    • MLNLFFIGEN 外部功能接口生成器。
    • 扩展程序。
    • 使用源库进行编程的 ML Basis 系统。
    • 许多有用的语言扩展。
    • 一个简单快速的 C FFI,支持从 SML 到 C 以及从 C 到 SML 的调用。
    • 用于弱指针和终结处理、线程、延续、间隔计时器和信号处理程序、全局保存和还原等的库。
  • 可移植性。
    • 在各种平台上运行。

构建和安装(从源代码)

要求

软件

  • GCCClang (C 编译器必须支持 -std=gnu11
  • GMP (GNU 多精度算术库)
  • GNU Make
  • GNU Bash
  • binutils (ar, ranlib, strip, …)
  • 各种Unix实用程序(diff, find, grep, gzip, patch, sed, tar, xargs, …)
  • 标准的ML编译器和引导工具:
    • 建议使用 MLtonmlton, mllex, 和 mlyacc)。可以通过 OS 软件包管理器或从 http://mlton.org 获得的(对于某些平台而言)安装 MLton 的预构建二进制软件包。
    • 支持 SML/NJsml, ml-lex, ml-yacc),但不建议这样做。
  • (可选,仅用于文档) TeX, AsciiDoc, Pygments, GraphicsMagickImageMagick, …

硬件

  • ≥ 1GB RAM (对于32位平台) 或 ≥ 2GB RAM (对于64位平台)

构建说明

在典型平台上,构建 MLton 不需要任何配置,可以通过以下方式完成:

$ make all

可以使用一组 Makefile 变量来定制构建:

  • CC:指定 C 编译器。可用于替代工具(例如, CC=clangCC=gcc-7)。
  • WITH_GMP_DIR, WITH_GMP_INC_DIR, WITH_GMP_LIB_DIR:指定 GMP include 和 library 路径,如果不在默认搜索路径上。(如果设置了 WITH_GMP_DIR ,则WITH_GMP_INC_DIR 缺省为 $(WITH_GMP_DIR)/include,且 WITH_GMP_LIB_DIR 缺省为 $(WITH_GMP_DIR)/lib
  • MLTON_RUNTIME_ARGS, MLTON_COMPILE_ARGS:指定运行时并编译给(待构建)的参数 mlton 编译分布式可执行文件时((自编译) mlton, mllex, mlyacc, mlprof, 和 mlnlffigen) 可用于测试(例如 MLTON_COMPILE_ARGS="-codegen c" )或用于下游包装。
  • OLD_MLTON_RUNTIME_ARGS, OLD_MLTON_COMPILE_ARGS:指定运行时,并在编译 "new" mlton 时编译指定给 "old" mlton 的参数。 可以用于在编译 "new" mlton 时解决 "old" mlton 中的错误。

例如:

$ make CC=clang WITH_GMP_DIR=/opt/gmp MLTON_COMPILE_ARGS="-codegen c" all

构建工件位于 ./build 下。 刚构建的 mlton 可以通过 ./build/bin/mlton 执行。

可以通过以下方式完成构建文档:

$ make docs

安装说明

在典型平台上,可以通过以下方式将 MLton(在执行 make all 和(可选)make docs 之后)安装到 /usr/local。

$ make install

可以使用一组 Makefile 变量来定制构建:

  • PREFIX:指定安装前缀。

例如:

$ make PREFIX=/opt/mlton install

安装(从二进制包)

要求

软件

  • GCCClang (C 编译器必须支持 -std=gnu11
  • GMP (GNU 多精度算术库)
  • GNU Make
  • GNU Bash
  • 各种Unix实用程序(bzip2, gzip, sed, tar, …)

二进制包

可以在任何位置提取 .tgz 或 .tbz 二进制软件包,从而生成 README.adoc(此文件),CHANGELOG.adoc,LICENSE,Makefile,bin/,lib/ 和 share/。编译器和工具可以就地执行(例如,./bin/mlton)。

可以使用一组 Makefile 变量通过 make update 来定制二进制包:

  • CC:指定C编译器。可用于替代工具(例如,CC=clang 或 CC=gcc-7)。
  • WITH_GMP_DIR,WITH_GMP_INC_DIR,WITH_GMP_LIB_DIR:指定 GMP include 和 library 路径(如果不在默认搜索路径上)。(如果设置了WITH_GMP_DIR,则 WITH_GMP_INC_DIR 默认为 $(WITH_GMP_DIR)/include,而 WITH_GMP_LIB_DIR 默认为 $(WITH_GMP_DIR)/lib。)

例如:

$ make CC=clang WITH_GMP_DIR=/opt/gmp update

安装说明

在典型平台上,可以通过以下方式将 MLton(可选执行 make update 后)安装到 / usr/local:

$ make install

可以使用一组 Makefile 变量来定制安装:

  • PREFIX:指定安装前缀。

例如:

$ make PREFIX=/opt/mlton install

资源

支持与贡献

要报告错误或建议新功能,请使用问题跟踪器或在邮件列表中询问。

欢迎提出带有错误修复或更改的拉请求


(The first version translated by vz on 2020.08.05)

Main metrics

Overview
Name With OwnerMLton/mlton
Primary LanguageStandard ML
Program languageMakefile (Language Count: 16)
PlatformBSD, Cygwin, Linux, Mac, Solaris, Unix-like, Windows
License:Other
所有者活动
Created At2013-03-08 20:08:27
Pushed At2025-06-24 15:21:11
Last Commit At2025-06-24 11:21:11
Release Count19
Last Release Nameon-20241230-release (Posted on 2024-12-30 15:37:19)
First Release Nameon-20011006-release (Posted on 2001-10-07 01:45:03)
用户参与
Stargazers Count1k
Watchers Count49
Fork Count130
Commits Count10.2k
Has Issues Enabled
Issues Count191
Issue Open Count24
Pull Requests Count400
Pull Requests Open Count0
Pull Requests Close Count19
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

= http://mlton.org[MLton]

ifdef::env-github[]
image:https://travis-ci.org/MLton/mlton.svg?branch=master[Build Status, link = https://travis-ci.org/MLton/mlton]
endif::[]


MLton is a whole-program optimizing compiler for the Standard{nbsp}ML
programming language. MLton generates small executables with
excellent runtime performance, utilizing untagged and unboxed native
integers, reals, and words, unboxed native arrays, fast
arbitrary-precision arithmetic based on GMP, and multiple code
generation and garbage collection strategies. In addition, MLton
provides a feature rich Standard{nbsp}ML programming environment, with
full support for SML97 as given in The Definition of Standard{nbsp}ML
(Revised), a number of useful language extensions, a complete
implementation of the Standard ML Basis Library, various useful
libraries, a simple and fast C foreign function interface, the ML
Basis system for programming with source libraries, and tools such as
a lexer generator, a parser generator, and a profiler.


== Features

== Build and Install (from source)

=== Requirements

==== Software

==== Hardware

  • ≥ 1GB RAM (for 32-bit platforms) or ≥ 2GB RAM (for 64-bit platforms)

=== Build Instructions

On typical platforms, building MLton requires no configuration and can be
accomplished via:

[source,shell]

$ make all

A small set of Makefile variables can be used to customize the build:

  • CC: Specify C compiler. Can be used for alternative tools (e.g.,
    CC=clang or CC=gcc-7).
  • WITH_GMP_DIR, WITH_GMP_INC_DIR, WITH_GMP_LIB_DIR: Specify GMP include
    and library paths, if not on default search paths. (If WITH_GMP_DIR is
    set, then WITH_GMP_INC_DIR defaults to $(WITH_GMP_DIR)/include and
    WITH_GMP_LIB_DIR defaults to $(WITH_GMP_DIR)/lib.)
  • MLTON_RUNTIME_ARGS, MLTON_COMPILE_ARGS: Specify runtime and compile
    arguments given to (the to-be-built) mlton when compiling distributed
    executables ((self-compiled) mlton, mllex, mlyacc, mlprof, and
    mlnlffigen). Can be used for testing (e.g., MLTON_COMPILE_ARGS="-codegen c") or for downstream packaging.
  • OLD_MLTON_RUNTIME_ARGS, OLD_MLTON_COMPILE_ARGS: Specify runtime and
    compile arguments given to "old" mlton when compiling "new" mlton. Can be
    used to work around bugs in "old" mlton when compiling "new" mlton.

For example:

[source,shell]

$ make CC=clang WITH_GMP_DIR=/opt/gmp MLTON_COMPILE_ARGS="-codegen c" all

The build artifacts are located under ./build. The just-built mlton can be
executed via ./build/bin/mlton.

Building documentation can be accomplished via:

[source,shell]

$ make docs

=== Install Instructions

On typical platforms, installing MLton (after performing make all and,
optionally, make docs) to /usr/local can be accomplished via:

[source,shell]

$ make install

A small set of Makefile variables can be used to customize the installation:

  • PREFIX: Specify the installation prefix.

For example:

[source,shell]

$ make PREFIX=/opt/mlton install

== Install (from binary package)

=== Requirements

==== Software

=== Binary Package

A .tgz or .tbz binary package can be extracted at any location, yielding
README.adoc (this file), CHANGELOG.adoc, LICENSE, Makefile, bin/,
lib/, and share/. The compiler and tools can be executed in-place (e.g.,
./bin/mlton).

A small set of Makefile variables can be used to customize the binary package
via make update:

  • CC: Specify C compiler. Can be used for alternative tools (e.g.,
    CC=clang or CC=gcc-7).
  • WITH_GMP_DIR, WITH_GMP_INC_DIR, WITH_GMP_LIB_DIR: Specify GMP include
    and library paths, if not on default search paths. (If WITH_GMP_DIR is
    set, then WITH_GMP_INC_DIR defaults to $(WITH_GMP_DIR)/include and
    WITH_GMP_LIB_DIR defaults to $(WITH_GMP_DIR)/lib.)

For example:

[source,shell]

$ make CC=clang WITH_GMP_DIR=/opt/gmp update

=== Install Instructions

On typical platforms, installing MLton (after optionally performing
make update) to /usr/local can be accomplished via:

[source,shell]

$ make install

A small set of Makefile variables can be used to customize the installation:

  • PREFIX: Specify the installation prefix.

For example:

[source,shell]

$ make PREFIX=/opt/mlton install

== Resources

== Support and Contributing

To report bugs or suggest new features, use the
https://github.com/MLton/mlton/issues[issue tracker] or ask on the
mailto:mlton-user@mlton.org[mailing list].

https://github.com/MLton/mlton/pulls[Pull requests] with bug fixes or
changes are welcome.