Skip to content

besm6/lcc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Retargetable C Compiler

This repo is a development of LCC compiler. We started from version 4.2, as released by Chris Fraser and Dr. David Hanson at github.com/drh/lcc. A goal is to adapt the compiler to unusual architectures like BESM-6.

Build

To build LCC from sources, you need to have C compiler, Git and CMake available on your system. For example, on Ubuntu the required packages can be installed by command:

sudo apt install build-essential git cmake

To build LCC, run:

git clone https://github.com/sergev/lcc.git
cd lcc
cmake -B build
make -C build

The following binaries will be created in the build directory:

  • rcc - backend of the C compiler
  • lcc - frontend to invoke the compiler from command line
  • cpp - C preprocessor

Testing

Unit tests help to make sure the compiler is working as expected. You need to install pytest first:

pip3 install pytest

Run all unit tests:

cd lcc
pytest

Expected output:

=================== test session starts ====================
...
collected 36 items

tst/test_rcc.py .................................... [100%]

==================== 36 passed in 0.39s ====================

Every test case consists of several files. For example, for cq test::

  • tst/cq.c - source C file
  • tst/cq.0 - input file for the test (stdin), optional
  • tst/TARGET/cq.sbk - expected assembly code, per platform
  • tst/TARGET/cq.1bk - expected output from the test (stdout), optional
  • tst/TARGET/cq.2bk - expected warnings from the compiler (stderr)

Packages

 
 
 

Languages

  • C 87.0%
  • Roff 11.5%
  • Other 1.5%