Cmajor compiler with C++ backend

The Cmajor compiler with C++ backend, cppcmc, is a command-line compiler for Windows, Linux and Windows subsystem for Linux. It compiles Cmajor code to very primitive C++ and then launches the configured C++ compiler to compile to native machine code. The compiler also generates a debug information file, x.cmdb, associated with the executable x. The cmdb file is read by the Cmajor command-line debugger, cmdb. The compiler and the debugger are integrated in Cmajor Code, a graphical editor and development environment.

Table of contents

1 Requirements
2 Installing the requirements
    2.1 Windows
          2.1.1 Installing the GNU C++ compiler and tools on Windows
          2.1.2 Installing Cmajor on Windows
          2.1.3 Compiling Cmajor system libraries using cppcmc on Windows
    2.2 Linux
          2.2.1 GNU C++ compiler and tools on Linux
          2.2.2 Boost libraries on Linux
          2.2.3 Installing Cmajor on Linux
          2.2.4 Building static versions of the Cmajor runtime libraries using gcc on Linux
          2.2.5 Compiling Cmajor system libraries using cppcmc on Linux
3 Compiling and running a Hello world program
4 Command-line arguments
5 Known bugs and limitations

1. Requirements

  1. GNU C++ compiler and tools installed.
  2. Cmajor installed.
  3. Cmajor system libraries compiled using cppcmc

2. Installing the requirements

2.1 Windows

2.1.1 Installing the GNU C++ compiler and tools on Windows

2.1.2 Installing Cmajor on Windows

The Cmajor installation is described in this document.

2.1.3. Compiling Cmajor system libraries using cppcmc on Windows

  1. Debug configuration: Change to C:\cmajor\system\platform\windows directory and enter the following command:
                C:\cmajor\system\platform\windows>cppcmc -u -v System.cms
                
    The -u flag tells the compiler to rebuild everything, strictly not necessary. The -v flag tells the compiler to be verbose, so you will see what's going on. If everything went fine, the last lines will say:
                System libraries installed.
                Solution 'System' built successfully.
                
    The debug-mode libraries are installed to C:\cmajor\system\lib\cpp\gcc\debug directory.
  2. Release configuration: Enter the following command:
                C:\cmajor\system\platform\windows>cppcmc -u -v -c=release System.cms
                
    The -c=release option tells the compiler to build for release configuration (optimizations enabled). Again the last lines should say:
                System libraries installed.
                Solution 'System' built successfully.
                
    The release-mode libraries are installed to C:\cmajor\system\lib\cpp\gcc\release directory.

2.2 Linux/WSL

2.2.1 GNU C++ compiler and tools on Linux

2.2.2 Boost libraries on Linux

2.2.3 Installing Cmajor on Linux

2.2.4 Building static versions of the Cmajor runtime libraries using gcc on Linux

2.2.5. Compiling Cmajor system libraries using cppcmc on Linux

  1. Debug configuration: Change to cmajor/system/platform/linux directory and enter the following command:
                slaakko@pluto:~/cmajor-3.6.0-src/cmajor/system/platform/linux$ cppcmc -u -v System.cms
                
    The -u flag tells the compiler to rebuild everything, strictly not necessary. The -v flag tells the compiler to be verbose, so you will see what's going on. If everything went fine, the last lines will say:
                System libraries installed.
                Solution 'System' built successfully.
                
    The debug-mode libraries are installed to cmajor/system/lib/cpp/gcc/debug directory.
  2. Release configuration: Enter the following command:
                slaakko@pluto:~/cmajor-3.6.0-src/cmajor/system/platform/linux$ cppcmc -u -v -c=release System.cms
                
    The -c=release option tells the compiler to build for release configuration (optimizations enabled). Again the last lines should say:
                System libraries installed.
                Solution 'System' built successfully.
                
    The release-mode libraries are installed to cmajor/system/lib/cpp/gcc/release directory.

3. Compiling and running a Hello world program

To test that the system basically works, you may now compile a Hello world program using cppcmc:

4. Command-line arguments

Usage: cppcmc [options] { project.cmp | solution.cms }

Long option Short option Description
--help -h Print help and exit.
--verbose -v Be verbose.
--quiet -q Be quiet, only return exit code.
--config=CONFIG -c=CONFIG Build usig CONFIG configuration. CONFIG can be "debug" or "release". Default optimization level for debug build is 0 and for release build is 2.
‑‑optimization‑level=LEVEL -O=LEVEL Set optimization level to LEVEL (0-3).
--clean -e Clean given projects and solutions.
‑‑tool‑chain=TOOL_CHAIN ‑tc=TOOL_CHAIN Use tool chain TOOL_CHAIN. Default is 'gcc'. Tool chains:
  • 'vs' for Visual Studio on Windows
  • 'gcc' for GNU C++ on Windows, Linux and WSL.
  • 'clang' for Clang++ on Windows, Linux and WSL.
--strict-nothrow -s Treat a nothrow violation as an error.
--emit-asm -f Emit assembly code to .asm files while compiling.
--gen-debug-info -g Generate debug info (on by default on debug configuration)
--no-debug-info -n Don't generate debug info even for debug build
--build-threads=N -bt=N Use N threads for building a solution. Default is 2 x C, where C is the number of cores.
--disable-module-cache -dm Do not cache recently built modules.
--single-threaded-compile -st Compile source files in a project using a single thread.
--disable-codegen -dg Disable code generation. On by default for 'vs' tool-chain.
--just-my-code -j Enable Just My Code debugging. Effective for 'vs' tool-chain.
--all -a Build all dependencies.
--repository -rp Build repository project.

5. Known bugs and limitations