The GNU Modula-2 front end to GCC


Why do you need to specify @code{--enable-languages=c,c++,gm2}?

GNU Modula-2 uses the C++ compiler to compile the underlying main function which consists of a try catch clause. The try clause calls each module in order and the catch clause calls the default exception handler. It needs the C compiler during the initial bootstrap.

Why use the C++ exception mechanism in GCC, rather than a bespoke Modula-2 mechanism?

The C++ mechanism is tried and tested, it also provides GNU Modula-2 with the ability to link with C++ modules and via swig it can raise Python exceptions.

Why not copy the C++ exception handing code into the Modula-2 runtime thus saving the necessity to build the C++ compiler?

The C++ compiler is needed to compile the underlying main() function.

There appear to be differing versions of the exception handling code (we are using v3) and it would be expensive to maintain the gm2 version and keep it in sync with the particular version of gcc which is being used.

It would also mean a duplication of code and this creates an obstacle to placing GNU Modula-2 into the main GCC tree.

The gcc libbackend.a is being reimplemented in C++ and therefore in future releases it will be necessary to build -lstdc++ anyway.