drh / lcc

The lcc retargetable ANSI C compiler
https://drh.github.io/lcc/
2.03k stars 441 forks source link

Building on Windows #4

Open norswap opened 12 years ago

norswap commented 12 years ago

Building lcc on Windows is basically fubar. The instruction are way outdated.

I have not really investigated, but might it not be easier to base the Windows version on MinGW, as it is much closer to how the install works on Unix ?

Also, it would be great to offer precompiled binaries. It might at least be a temporary solution until the build system is fixed.

alexfru commented 8 years ago

FWIW, as an experiment I tried compiling lcc with my own compiler (Smaller C) for Widnows. After bumping up the sizes of the internal tables/arrays in Smaller C and massaging lcc's code to exclude the features currently unsupported by Smaller C, I got it to compile and seemingly work. What I did outside of Smaller C issues is roughly:

That was enough to make lcc compile tiny snippets of C code like the following into MIPS assembly:

int a = 4;
int inca(void) { return ++a; }

Not terribly hard.

thelink2012 commented 7 years ago

The limits tests fails because the VC headers became too complex for LCC to handle. In this case, VAARGS for macros are present.

You cannot use any standard header anymore because of that, you should define standard functions and whatsover manually.

Plus, for VC2015 onwards, which uses the new Universal CRT, your ld on etc/win32.c should look something like:

char *ld[] = { "link", "-nologo",
        "", "-subsystem:console", "-entry:mainCRTStartup",
        "$2", "-OUT:$3", "$1", "/NODEFAULTLIB", LCCDIR "liblcc.lib", "oldnames.lib", "libcmt.lib", "legacy_stdio_definitions.lib", "libucrt.lib", "kernel32.lib", 0 };

Hope this helps anyone also trying to get this to build and work on Windows.