Using the Mathemagix compiler

1.Introduction

The basic procedure for compiling and running a Mathemagix program toto.mmx is very simple: first compile the program using

mmc toto.mmx

This will create a binary toto which can be run using

./toto

This method still works if the program toto.mmx depends on many other files. In that case Mathemagix will automatically determine and compile all dependencies. Moreover, on modern computers the compiler will automatically compile as many of the dependencies as possible in parallel. Furthermore, if you modify one of the dependencies and recompile toto.mmx, then only those dependencies which were affected by your change will be recompiled. In order to monitor this process more precisely and get a rough idea about what the compiler is doing, you may compile toto.mmx using the option –verbose:

mmc --verbose toto.mmx

Whenever the user develops another program booh.mmx with an overlapping set of dependencies with toto.mmx, then compiling both programs toto.mmx and booh.mmx will compile the overlapping dependencies only once (or at most once, in case of recompilations).

In order to avoid unnecessary recompilations, the compiler uses a cache, which is stored by default in the directory ~/.mathemagix/mmc or ~/.mathemagix/mmc-version. Sometimes, you may wish to clean the cache and recompile all dependencies from scratch. This can be done using

mmc --clean-cache

This kind of cleaning may also be necessary whenever you replace your compiler by a newer development version.

2.Compiler flags

The compiler only supports few global flags to influence the compilation process. On the one hand, this is important in order to take optimal advantage out of the compiler cache, and thus make the compilation process as fast as possible. On the other hand this is part of the general design philosophy of Mathemagix, in which control is delegated to the programs themselves rather than to an external build system.

General purpose compiler flags are the following:

–optimize

This flag is used for the generation of optimized (but possibly larger) code.

–gdb

This flag should be used in order to generate code which can be debugged using Gdb.

–static

This flag should be used for the creation of static binaries.

3.Other compiler options

The compiler supports a few other general purpose options:

–color

This option will print messages issued by the compiler using colors.

–progressive

Disable parallelism for the compilation process.

–test-compile files

Test the compilation of a list of files.

–test-run files

Both compile and run a list of files.

–threads max

Compile using at most max threads or processes.

For debugging purposes, it is sometimes useful to inspect the contents of intermediate files which are generated by the compiler. This can be done using the following options:

–keep-mmh

Keep all public interfaces of the Mathemagix files.

–keep-cpp

Keep all intermediate C++ files generated by the compiler.

–keep-o

Keep all intermediate object files generated by the compiler.

Any C++ files which are kept in this way may be edited by the user. In order to resume the compilation process from these modified versions, you may use the option –from-cpp.

Hackers may also want to experiment with various debugging options for the compiler itself. These options are all of the form –debug-feature. Currently supported debugging options are:

–debug-apply, –debug-build, –debug-categories, –debug-coerce, –debug-compile, –debug-compiled, –debug-convert, –debug-cpp, –debug-cse, –debug-csed, –debug-declare, –debug-exe, –debug-flat-control, –debug-flattened-control, –debug-globals, –debug-glue, –debug-implicit, –debug-inline, –debug-inlined, –debug-instantiate, –debug-instantiated, –debug-new, –debug-new-categories, –debug-phase, –debug-trace, –debug-uncurried, –debug-uncurry, –debug-unnest, –debug-unnested.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.