Kefir: A C17/C23 Compiler

fanf21 pts0 comments

~jprotopopov/kefir -

Independent C17/C23 compiler -

sourcehut git

~jprotopopov/kefir

summary

tree

log

refs

Independent C17/C23 compiler

15dfd84a

J. Protopopovs

a month ago

Update PKGBUILDs

a0a2f774

J. Protopopovs

a month ago

Bump Kefir version to 0.5.1

fc294292

J. Protopopovs

a month ago

Update other Dockerfiles

refs

master

browse

log

v0.5.1

release notes

clone

read-only<br>https://git.sr.ht/~jprotopopov/kefir<br>read/write<br>git@git.sr.ht:~jprotopopov/kefir

Clone repo to your account

You can also use your local clone with<br>git send-email.

#Kefir C17/C23 compiler

Kefir is an independent compiler for the C17/C23 programming language, developed<br>by Jevgenij Protopopov. Kefir has been validated<br>with a test suite of 100 software projects, among which are GNU core- and<br>binutils, Curl, Nginx, OpenSSL, Perl, Postgresql, Tcl and many others. The<br>compiler targets x86_64 architecture and System-V AMD64 ABI, supporting Linux,<br>FreeBSD, NetBSD, OpenBSD and DragonflyBSD. The project intends to provide a<br>well-rounded, compatible and compliant compiler, including SSA-based<br>optimization pipeline, debug information generation, position-independent code<br>support, and bit-identical bootstrap. Kefir integrates with the rest of system<br>toolchain --- assembler, linker and shared library.

#At a glance

Kefir:

Supports the C17 standard -- including complex and imaginary numbers, atomics,<br>variable-length arrays, etc. (see Implementation quirks).

Supports the C23 standard -- including bit-precise integers and _Decimal<br>floating-point support (see Implementation quirks).

Supports some of widespread GNU C built-ins, certain extensions, inline<br>assembly, 128 bit integers.

Is written in C11 -- runtime dependencies are limited to the standard library,<br>bits of POSIX and the shell.

Targets x86_64 and System-V ABI -- primarily Linux (both glibc and musl libc),<br>secondarily FreeBSD, NetBSD, OpenBSD and DragonflyBSD (see Supported<br>environments).

Is extensively validated on real-world open source software test suites --<br>including dozens of well-known projects (see Testing and validation).

Implements SSA-based optimization pipeline with two SSA phases -- primarily<br>targetting local scalars: local variable promotion to registers, dead code<br>elimination, constant folding, global value numbering, loop-invariant code<br>motion, function inlining, tail-call optimization, but also providing<br>conservative global memory access optimization, as well as target-specific<br>optimizations (see Optimization and codegen).

Supports DWARF5 debug information, position-independent code, AT&T and Intel<br>syntaxes of GNU As and has limited support for Yasm.

Implements bit-identical bootstrap -- within fixed environment, Kefir produces<br>identical copies of itself.

Is able to generate freestanding assembly code -- with the exception for<br>thread-local storage (might require external calls per ABI), _Decimal<br>floating-point numbers, and atomic operations of non-platform native sizes,<br>which require libatomic-compatible library.

Provides cc-compatible command line interface.

Is able to output internal representations (tokens, abstract syntax tree,<br>intermediate representation) in machine-readable JSON form.

Provides auditable logs and all build artifacts for pre-release testing of the<br>most recent release.

Licensed under GNU GPLv3 (only) terms for the compiler, and BSD-3 terms for<br>runtime includes (see License).

Is written by a single developer.

Is named after fermented milk drink --<br>no other connotations are meant or intended .

Important note: as the project is developed and maintained by a single<br>person, unfunded and in spare time, the author warns that uses of Kefir in<br>production settings might be undesirable due to insufficient level of support<br>the author can provide.

Important note #2: to the best of author's knowledge, all of the claims<br>above are true (and many are reproducibly demonstrated by the test suite). Yet<br>even with full rigour, many bugs, unintended omissions, inconsistencies and<br>misunderstandings may slip through. The author intends to faithfully represent<br>capabilities of the project, and is especially sensitive to any overstatements<br>in this regard. If you have any doubts, objections or otherwise disagree with<br>the above, please do not hesitate contact the author (see Author and contacts)<br>-- corrections will be issued immediately after identifying the deficiency.

#Installation and usage

On supported platforms, Kefir is built and tested as follows:

make test all # Linux glibc<br>make test all USE_SHARED=no CC=musl-gcc KEFIR_TEST_USE_MUSL=yes # Linux musl<br>gmake test all CC=clang # FreeBSD<br>gmake test all CC=clang AS=gas # OpenBSD<br>gmake test all CC=gcc AS=gas # NetBSD<br>gmake test all LD=/usr/local/bin/ld AS=/usr/local/bin/as # DragonflyBSD

The installation is done via (g)make install prefix=.... The default prefix is<br>/opt/kefir.

Kefir build time dependencies are:

C11 compiler -- tested with gcc and clang.

Bash

GNU Make

GNU...

kefir compiler test local author independent

Related Articles