besm6 / lcc

The lcc retargetable ANSI C compiler

Home Page:http://sites.google.com/site/lccretargetablecompiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

The lcc retargetable ANSI C compiler

http://sites.google.com/site/lccretargetablecompiler


Languages

Language:C 87.1%Language:Roff 11.5%Language:Yacc 0.5%Language:CMake 0.4%Language:Python 0.4%Language:Shell 0.2%