SML# Document Version 4.0.0
5 Installing SML#

5.8 Building from the source

For Linux and other systems, you need to build from the SML# source distribution. To do this, the following tools and libraries are required:

  1. 1.

    GNU binutils(GNU Binary Utilities),

  2. 2.

    C and C++ compiler (gcc or clang),

  3. 3.

    make (GNU make is recommended),

  4. 4.

    MassiveThreads and GMP library and their header files, and

  5. 5.

    LLVM 3.9.1 (or above) library, its header files, and commands

If these have been already installed, you can build and install SML# in the following popular three steps: ./configure && make && make install.

If your OS does not provide them, you need to build them from the source. See those official documents for details of this procedure.

For your information, we roughly present how to compile MassiveThreads and LLVM 11.1.0 the time when we write this document.

MassiveThreads

Obtain the source code of MassiveThreads 1.00 named massivethreads-1.00.tar.gz from MassiveThreads web site https://github.com/massivethreads/massivethreads. After expanding the tar archive, do ./configure && make && make install.

LLVM 11.1.0

Obtain the source code of LLVM 11.1.0 named llvm-11.1.0.tar.xz from LLVM web site http://llvm.org/. After expanding the tar archive, do the following five commands:

mkdir build
cd build
cmake -G "Unix Makefiles" \
     -DCMAKE_INSTALL_PREFIX=/where/llvm/is \
     -DCMAKE_BUILD_TYPE=Release \
     -DLLVM_BUILD_LLVM_DYLIB=On \
     -DLLVM_ENABLE_BINDINGS=Off
make
make install

The above options specified to configure are optional but suggested. -DCMAKE_INSTALL_PREFIX option should be specified to avoid conflict with other installation of LLVM. -DCMAKE_BUILD_TYPE=Release option enforces compiling LLVM libraries by an optimizing compiler. -DLLVM_BUILD_LLVM_DYLIB=On option enforces building the LLVM shared library. -DLLVM_ENABLE_BINDINGS=Off option avoids to build modules unnecessary for SML#.

With these preparation, SML# can be build in the following steps.

  1. 1.

    Download the source distribution from: https://github.com/smlsharp/smlsharp/releases/download/v4.0.0/smlsharp-4.0.0.tar.gz. The latest version of the source package is also available from https://smlsharp.github.io/ja/downloads/.

  2. 2.

    Select an SML# source directory and extract the tar archive there. Note for non-English users: the source directory must not include non-ASCII characters, otherwise the build process will fail.

  3. 3.

    Select an SML# installation destination directory. Let prefix be the path to the directory.

  4. 4.

    In the SML# source directory, execute configure script.

    $ ./configure --prefix=prefix --with-llvm=/where/llvm/is

    You can specify --prefix=prefix option to specify the destination directory. If --prefix option is omitted, /usr/local is used as the destination directory. If --with-llvm option is omitted, the configure script searches for LLVM libraries and commands from the standard directories such as /usr/bin.

  5. 5.

    Do make command.

    $ make

    After make is finished, you can launch the SML# compiler without installing it by the following commands.

    $ src/compiler/smlsharp -Bsrc

  6. 6.

    (Optional) The following commands build the SML# compiler by the SML# compiler you built in the previous step.

    $ make stage
    $ make

  7. 7.

    Do make install command.

    $ make install

    If you want to put files to be installed in a directory prefix different from prefix, specify DESTDIR=prefix option to make install command.

The following files are installed by the above procedure.

  1. 1.

    smlsharp command at prefix/bin/smlsharp

  2. 2.

    smlformat command at prefix/bin/smlformat

  3. 3.

    smllex command at prefix/bin/smllex

  4. 4.

    smlyacc command at prefix/bin/smlyacc

  5. 5.

    library files in the prefix/lib/smlsharp/ directory.

If successful, you can invoke SML# by typing:

$ prefix/bin/smlsharp

Some hints:

  • This process compiles all the source files including those of tools, which takes some time. If you have a CPU with n cores and use GNU make, then try to give -jm (mn) switch to make command for parallel processing, where m indicate the degree of parallelism.