ACHTUNG: This is a seriously pre-pre-alpha software package. Nothing is set in stone. Everything is buggy. I'll refactor almost all of it by lunchtime tomorrow. That sort of spiel.
A framework for automatically compiling a superset/subset of MATLAB into C.
This project spawned out of my growing curiosity about compiler design. The goal is to produce a compiled open-source language with the syntax, weak dynamic typing, and objects of MATLAB. Honestly, it's just a toy project that deviates from bona fide MATLAB behavior whenever I feel like it. :P
The matte framework consists of three key elements:
- The runtime library
- The compiler
- The REPL (not yet!)
The last two members of the above list depend on the first, because the scanner, parser, syntax tree, etc. are components of the runtime library.
The matte compiler transforms MATLAB into C source code, or optionally to native machine code using the system's C compiler. The C source code written by the compiler will be linked against the runtime library, which provides types and builtins similar to the MATLAB base types and built-in functions.
The matte REPL is a primitive shell that dynamically compiles MATLAB code fragments input by the user into shared objects, and loads them into the program to be executed.
The matte runtime library depends on the C API's to LAPACK and BLAS provided by ATLAS. On OSX El Capitan, this is a nightmare. Long story short, dump clang.
I successfully compiled ATLAS 3.10.2 using GCC 5.3.0 from homebrew-core, with LAPACK 3.6.0, using the following commands:
brew install gcc --with-fortran
cd /usr/local/bin
sudo ln -sv gcc-5 gcc
cd ~/ATLAS
mkdir osx
cd osx
../configure -b 64 -O 12 -A 28 -V 480 --prefix=/usr/local/atlas \
--shared --with-netlib-lapack-tarfile=../../lapack-3.6.0.tar \
-C alg gcc-5 -C if gfortran-5 \
-Fa acg '-Xassembler -q'
make build
make check
make ptcheck
make time
sudo make install
The above sequence also works for GCC 6.1.0 from homebrew-core.
The matte compiler and runtime library are released under the MIT license. See the LICENSE.md file for the complete license terms.