beluga
is a standard C compiler being developed based on
lcc
. It supports
C90 (to be precise,
ISO/IEC 9899:1990)
as its ancestor does and is planned to extend the coverage to
C99
(and
C11
finally).
Compared to its parent, it carefully implements the language standard and thus
provides production-quality diagnostics. The generated code is not highly
optimized, but satisfactory enough to use beluga
in daily programming. (This
is a hobby project; never easy for me alone to catch up production compilers
like gcc and clang+llvm.)
beluga
currently produces assembly output for
x86 only (and uses an assembler from the
target system). Thanks to its origin, however, it can be readily retargeted to
other platforms. Support for 64-bit machines (like
x86-64) requires new significant
features to be implemented and is one of most important goals of this project.
Also I'm redesigning each part of the compiler aiming for better structure and have a plan to completely replace the back-end interface and implementation to ease adoptation of more ambitious optimization techniques mainly based on a CFG.
An accompanying standard C preprocessor sea-canary
is carefully designed and
implemented from scratch to support beluga
. It is
fairly fast, is correct enough
to pass many complicated
test cases, produces
highly compact output and has rich diagnostics. For example, it catches code
that subtly depends on an unspecified evaluation order of the ##
operator
like this:
#define concat(x, y, z) x ## y ## z
concat(3.14e, -, f) /* non-portable */
and cleverly keeps track of macro expansions whose recursiveness is determined by an implementation rather than by the standard:
#define f(a) a*g
#define g(a) f(a)
f(2)(9) /* non-portable */
(see the defect report
#017 for the
latter example). The current version of sea-canary
supports C90, thus some
features like variadic macros
introduced in C99 and widely used now are not supported yet.
You can try them out on the beluga
's
web page.
INSTALL.md
explains how to build and install the libraries. For the copyright
issues, see the accompanying LICENSE.md
file.
If you have a question or suggestion, do not hesitate to contact me via email (woong.jun at gmail.com) or web (http://code.woong.org/).