Installation

Installation on Windows x64

Now Cminor is ready for compiling your projects.

Installation on Linux x86-64

On Linux you have to compile Cminor from sources.

Needed programs and libraries

GCC version

My gcc version is rather old, but it compiles C++11 code, so it sufficies:

> g++ --version
g++ version 4.8.4
Installing zlib

To install zlib from sources download zlib-1.2.11.tar.gz (or newer), extract it to some directory here called zlib-1.2.11 and change to zlib-1.2.11 directory. Then run make and then [sudo] make install:

> cd zlib-1.2.11
> make
> sudo make install
Installing boost

To install boost from sources download boost_1_64_0.tar.bz2 (or newer), extract it to some directory here called boost_1_64_0 and change to boost_1_64_0 directory. At minimum you will need to install filesystem, iostreams and system libraries:

> cd boost_1_64_0
> ./bootstrap.sh
> ./b2 --with-filesystem --with-iostreams --with-system
> sudo ./b2 --with-filesystem --with-iostreams --with-system install
Installing cmake

To install cmake you can either build it from sources or download a binary distribution on Linux x86_64: cmake-3.8.0-Linux-x86_64.tar.gz. To install the binary distribution, extract it to some directory here called cmake-3.8.0 and insert the cmake-3.8.0/bin directory to the PATH environment variable. Then run cmake --version to ensure it is of the right version.

> cmake --version
cmake version 3.8.0
Installing LLVM and Clang

LLVM and Clang must be built from sources because by default exceptions and RTTI needed by Cminor are not enabled in binary distributions as far as I know. Download LLVM: llvm-4.0.0.src.tar.xz (or newer), extract it to some directory here called llvm-4.0.0.src. Then download Clang: cfe-4.0.0.src.tar.xz (or newer), extract it to some directory here called cfe-4.0.0.src. Then move cfe-4.0.0.src directory under the llvm-4.0.0.src/tools directory under the name "clang".

Change to directory llvm-4.0.0.src and create a build directory under it. Then change to the build directory and run cmake command from there by giving it path to the llvm-4.0.0.src directory. Cminor uses exceptions and RTTI so we need to enable them by setting LLVM_ENABLE_EH and LLVM_ENABLE_RTTI variables to ON. By entering commands llc -version and clang --version we can ensure that the LLVM and Clang found are of the right versions.

> mv cfe-4.0.0.src llvm-4.0.0.src/tools/clang
> cd llvm-4.0.0.src
> mkdir build
> cd build
> cmake -DCMAKE_BUILD_TYPE="Release" -DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON ../
> make
> sudo make install
> llc -version
LLVM version 4.0.0
...
> clang --version
clang version 4.0.0 ...
...

Installing Cminor

To build Cminor from sources download cminor-0.2.0.tar.bz2 or cminor-0.2.0.tar.gz, and extract it to some directory here called cminor-0.2.0. Change to the cminor-0.2.0/cminor directory, run make and then [sudo] make install from there. By default executables are installed to /usr/bin and the virtual machine library to /usr/lib. You can install them to different location by setting the prefix in the install command: [sudo] make prefix=/where/to/install install.

Make a new environment variable named CMINOR_ROOT and set its value to path to the cminor-0.2.0/cminor directory. (You need to insert it to your shell script (.bashrc or equivalent) to make it permanent.) Insert /usr/lib (or your prefix/lib) directory to your LD_LIBRARY_PATH environment variable, so that the dynamic virtual machine library cminormachine.so.0.2.0 is found. Then give command "cminor" to ensure that found cminor program is of the right version.

> cd cminor-0.2.0/cminor
> make
> sudo make install
> export CMINOR_ROOT=~/cminor-0.2.0/cminor
> export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
> cminor
cminor programming language commander version 0.2.0
...
Building the system library

Now that Cminor commander is working, you need to build the system library for the debug and release configurations:

> cminor build --native system
> cminor build --native --config=release system

Now Cminor is ready for compiling your projects.