Installation

Mopsa is developed under Linux. It has been known to compile under Ubuntu, Debian, Gentoo. It also compiles on Windows 10 with WSL2 (Windows Subsystem for Linux), and possibly on other platforms.

Downloading Mopsa

The source code of Mopsa can be found at https://gitlab.com/mopsa/mopsa-analyzer. Use Git to get access to the latest version:

$ git clone https://gitlab.com/mopsa/mopsa-analyzer.git
$ cd mopsa-analyzer

Dependencies

To build Mopsa, first make sure you have the following dependencies:

The OCaml dependencies can be installed with the following command using opam:

$ opam install --deps-only --with-doc --with-test .

If you are using Ubuntu 20.04, you can use the following commands to install the dependencies:

$ sudo apt install opam llvm clang llvm-dev libclang-dev libclang-cpp10-dev libgmp-dev libmpfr-dev autoconf pkg-config zlib1g-dev
$ opam init --compiler 4.12.0
$ eval $(opam env)
$ opam install --deps-only --with-doc --with-test .

For Ubuntu 22.04, you can use:

$ sudo apt install opam llvm clang llvm-dev libclang-dev libclang-cpp13-dev libgmp-dev libmpfr-dev pkg-config zlib1g-dev
$ opam init
$ eval $(opam env)
$ opam install --deps-only --with-doc --with-test .

Building

To compile Mopsa, issue the classic commands:

$ ./configure
$ make

The binaries will be available in the bin/ sub-directory.

You can install Mopsa in the active opam switch with:

$ make install

You can test your installation by running mopsa -v. If this succeeds, you can jump to using Mopsa.

Note

When configure cannot find LLVM/Clang in your system, it outputs the following warning:

configure: WARNING: llvm-config not found. C analyzer will not be compiled.

If you want to use Mopsa for analyzing Python only, you can ignore this warning and continue the build process. Otherwise, if you want to analyze C code, make sure to install a correct version of LLVM/Clang.

If LLVM/Clang is installed in a non-standard location or you want to use a different version, you can set the LLVMCONFIG environment to the location of the llvm-config script before calling ./configure. For instance:

$./configure LLVMCONFIG=/usr/bin/llvm-config-10

Advanced Build Options

The configure script accepts some options:

--disable-c

disable the C analysis

--disable-python

disable the Python analysis

--enable-byte

enable the compilation of bytecode binaries (in addition to native code binaries, which are always built)

In addition, several environment variables can be set before calling configure to alter how Mopsa is built:

LLVMCONFIG

full path to the llvm-config script installed with LLVM/Clang

and the usual configure variables configuring the C compiler (CC, CFLAGS), the C++ compiler (CXX, CXXFLAGS), the preprocessor (CPPFLAGS), and the linker (LDFLAGS, LIBS).