Booting CM3 5.1 with PM3 or SRC M3

The CM3 5.1 compiler may be compiled with the PM3 Modula-3 compiler or the older SRC version. As there have been changes in the standard libraries (Text interface) and the language (WIDECHARs), a bootstrapping process is necessary. This bootstrapping contains the following steps:

  1. Apply the m3-boot-diffs using the popular patch program to the cm3/m3-sys directory.
  2. Make sure that the compiler contains the necessary platform support. Inspect the following files:
    cm3/m3-sys/m3middle/src/Target.m3
    cm3/m3-sys/cm3/src/config/${TARGET}
  3. Create the file compat.quake at the root of the source tree with this content:
    % Determine whether we are using the PM3 release of Modula-3.
    if not defined("PM3")
      % The procedure "build_standalone" exists only in SRC Modula-3.
      if not defined("build_standalone")
        PM3 = "T"
      end
    end
    if defined("PM3")
      proc build_standalone() is
        option("standalone", "T")
      end
    end
  4. Compile and link the CM3 compiler using the libraries of the PM3 system. You can do this with the the script cm3/scripts/boot-cm3-with-m3.sh. Have a look at the script to see what packages are needed if you prefer to do it without shell's help.
  5. Set up a CM3 directory skeleton (usually at /usr/local/cm3). You can use the script cm3/scripts/create-skel.sh.
  6. Install the compiler frontend (cm3), backend (cm3g)(if needed), and mklib (if needed) in the recently created cm3/bin directory, along with the appropriate platform config file (cm3/m3-sys/cm3/src/config/${TARGET} --> /usr/local/cm3/bin/cm3.cfg).
  7. Carefully check all the settings in your configuration file cm3.cfg
  8. Extend your PATH to contain the CM3 bin directory.
  9. Reverse the applied patches or just unpack the original cm3/m3-sys sources.
  10. Compile the standard libraries m3core and libm3 using the new compiler. Make sure that all the platform support stuff in m3core (various ${TARGET} subdirectories) and the Unix interfaces (if needed) are up-to-date. Ship the standard libraries using the new compiler. You can use the script cm3/scripts/do-cm3-min.sh.
  11. Recompile the CM3 compiler using the new CM3 compiler. Install the resulting cm3 executable as before, but make sure not to remove the first version just in case anything went wrong. You can again use the cm3/scripts/boot-cm3-with-m3.sh script.
  12. Recompile the standard libraries again and ship them.
  13. Recompile the CM3 compiler again and link it against the latest standard libraries. Install the cm3 executable as before. The booting process should now have reached a fix-point.

If the platform for which you want to bring up the CM3 compiler hasn't been tested yet (anything except NT386, FreeBSD3, SOLgnu, and LINUXLIBC6), you may experience problems due to incompatible system interfaces and two years old runtime support. If the platform is contained in PM3, you may be able to compare all the modules and borrow patches and things needed. Be aware that it will probably not do to copy the complete PM3 runtime stuff, as CM3 and PM3 have made different and sometimes incompatible extensions to the SRC compiler. Feel free request help at m3-support{at}elego.de.

The above procedure has been successfully applied to boot the CM3 5.1 source release on NT386, FreeBSD3, SOLgnu, and LINUXLIBC6, so it is unlikely to be completely wrong. Your mileage may wary though.


m3-support{at}elego.de