lcc 4.2 compiling problems on Windows + using lcc for C analysis

lcc 4.2 compiling problems on Windows + using lcc for C analysis

Post by elibe » Wed, 14 Nov 2007 02:51:47


Hello,

I downloaded the lcc 4.2 release and tried to follow the directions in
the documentation to compile it on my Windows XP machine, with the
command line compiler of MS Visual Studio 2005. I managed to compile
the driver and "nmake all" - many warnings, but all the executables
were created. Now, when I run "nmake test" - lcc fails with the error
that it can't link "libc.lib".

Where should libc.lib come from, and why doesn't it ?

Furthermore, when I run the triple test, it gets stuck at the first
compilation line. I must add that it seems that "cpp" and "rcc" (at
least for target=symbolic) are working.
Which brings me to the question - my goal in installing lcc is to use
it as a front-end for a C analysis program. What is the best way to go
about it ? The output of target=symbolic doesn't look too friendly.

Thanks in advance
Eli
 
 
 

lcc 4.2 compiling problems on Windows + using lcc for C analysis

Post by Uncle Noa » Wed, 14 Nov 2007 18:58:49

I use to run LCC on Cygwin, however i usually don't use the official
release (from the Princeton site). It is difficult to maintain (no GNU
configure script).

There is another version out there that uses GNU configure. AFAIR it
is written by Nelson Beebe. The last version i checked was lcc-4.1-10
or something. It is well worth the try on Cygwin/x86.

I'm not sure the configure script can recognize a true Win32
environment (and your proprietary compiler).

Nikolaos Kavvadias

 
 
 

lcc 4.2 compiling problems on Windows + using lcc for C analysis

Post by Antoine Le » Thu, 15 Nov 2007 02:41:43


eliben va escriure:

libc.lib is the standard C library. It is required to be linked with (or an
equivalent) for any non-toy C program.


Logically, you should use the one that comes with your base C compiler (here
VC), along with the corresponding include files. If VC2005 is spartiate
enough to not include the statically linked library (only the dynamically
linked MSVCRTxx), you'll have to seek a replacement; I guess newlib (in the
Cygwin project or near it) should work.


Well, the first step is compiling LCC with your host compiler, so this
should work (you're reporting rcc indeed works). The second step is to
compile LCC with this very compiler just created, and here you need a C
library adapted to your LCC compiler to link with after the translation
step; this is where you are stuck.


Antoine
 
 
 

lcc 4.2 compiling problems on Windows + using lcc for C analysis

Post by elibe » Thu, 15 Nov 2007 12:54:41

Hello,

I resolved the problem I had. For record, the solution is: replace
"libc.lib" by "libcmt.lib" in etc/win32.c
MS Visual Studio 2005 doesn't include libc.lib - only its multi-
threaded version, libcmt.lib
I suppose this should be reflected in the "windows installation" docs,
since VS 2005 Express is the current free compiler version distributed
by Microsoft.


As for analyzing the C source, after digging some I reached the
conclusion that lcc is probably not the right tool, since it compiles
the code into an internal "pseudo-assembly" representation and not an
AST. For example, branches are compiled into labels with appropriate
comparisons and jumps. This makes lcc very suitable for retargeting
the backend to new architectures, but unsuitable for AST-level source
analysis. Please correct me if I'm wrong.

Eli