lcc-win32 Windows C compiler

"jacob navia" <jacob@jacob.remcomp.fr>
17 Mar 2002 23:13:34 -0500

          From comp.compilers

Related articles
lcc-win32 Windows C compiler jacob@jacob.remcomp.fr (jacob navia) (2002-03-17)
| List of all articles for this month |

From: "jacob navia" <jacob@jacob.remcomp.fr>
Newsgroups: comp.compilers
Date: 17 Mar 2002 23:13:34 -0500
Organization: Wanadoo, l'internet avec France Telecom
Keywords: Windows, lcc, available
Posted-Date: 17 Mar 2002 23:13:34 EST

You use windows?
You would like a free C compiler?
Download lcc-win32, a free compiler for the windows system (all brands:
95/98/2000/NT/XP/ME/98-SE/ you name it)


The base system makes 3.2MB compressed, and probably some 20MB on
disk. Installation is fast and simple. The program comes with a
wizard for generating code for skeleton windows applications, and
compiles very fast.


The speed of the generated code is 10-20% slower than the best
compilers in the world in benchmarks. In normal programs the speed
difference is unnoticeable.


Compared with gcc the difference shrinks to 3-4% sometimes, sometimes
more, depending on the bugs/corrections of each of their versions. I
was really happy, I am ashamed to confess, that they started aligning
doubles at addresses multiples of 16, and slowed down the generated
code even for integer calculations to the same speed of lcc-win32 or
less... but helas! it didn't last long, they corrected the bug fairly
quickly. :-)


The integrated environment features an IDE with syntax highlighting,
windowed debugger, project management, versioning system, resource
editor and compiler, software metrics, profiler, all a compiler needs.


Evidently, a preprocessor, a compiler and a linker are
provided. Dennis Ritchie wrote the preprocessor, and I haven't
modified it a lot, just added some C99 constructs and increased fixed
capacity tables.


There, is the heart of a C compiler. The preprocessor translates all
the input, passing it to the front end, that was written by Dave
Hanson. Dave constructs trees out of the characters in the input text,
and passes those trees to the back-end designed by Chris Fraser.


Chris outputs assembler mnemonics, that I feed into the peephole
optimizer, then to the assembler, both programs I wrote. I have hacked
a lot in the front end, the back-end, and elsewhere, and I started by
writing that assembler, that takes those mnemonics of Chris and
outputs an object file (COFF obj).


Lcc-win32 reads its input, and it will not touch the disk until the
end, when writing the object file. This makes it so fast.


The object file is then fed to my linker, that builds an executable
(or dll if the user wishes) using the specifications for executables
published by Microsoft for windows systems (PE format).


The executable can be debugged by the IDE, that loads it, reads the
debug info generated by the compiler (NB09 standard) and stops
execution in WinMain (for windows applications) or main, for console
applications.


You can single step, set/unset breakpoints, etc. Using the debug
registers of the x86 architecture, the debugger allows you to set up
to 4 breakpoints at an arbitrary address. The machine runs at full
speed, but it will stop when a certain address is accessed. This is
useful for catching the moment a variable is changing value.


A resource editor is provided, that allows you to design your dialog
boxes in the screen, and generates several files that can be compiled
by the resource compiler to be included in the executable by the
linker. The linker understands that resource files are special, and
transforms them into standard COFF files before proceeding.


The profiler is a statistical one, that interrupts the program approx
1000 times per second and figures out where the program is. It assumes
that the functions where you spend most of the time will be found more
often than the others. It is not VERY sensible, but it can give you an
idea where to look for optimizations.


Code optimization is directed mainly at avoiding redundant
loads/stores with the peephole, and some simple transformations like
constant folding. The compiler will automatically allocate ESI, EBX
and EDI for register variables if possible.


The run time is the standard C runtime provided by Microsoft for
windows: crtdll.dll. Since the C runtime hasn't been updated for C99,
lcc-win32 provides a complementary standard library with the missing
functions that the C99 standard specifies. All import libraries for
the system dlls are provided (119 import libs!) ranging from directx8
support or COM support and many others. Extensive header files for all
those windows interfaces are included in the system too: 6MB of header
files after decompression.


bool, dynamic arrays, and many other C99 specifications are already
done. But I am missing some still.


Extensions to the C language are:
generic functions,
operator overloading,
references,
default arguments,


and some more. All of them C++ compatible.


I enjoyed writing it, this system, and I give it away at no cost in:


http://www.cs.virginia.edu/~lcc-win32


jacob



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.