Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on Windows #4

Open
norswap opened this issue Jun 3, 2012 · 2 comments
Open

Building on Windows #4

norswap opened this issue Jun 3, 2012 · 2 comments

Comments

@norswap
Copy link

norswap commented Jun 3, 2012

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

  • The identifier outp in cpp\cpp.c clashes with the Windows function of the same name. Renaming it the something else makes the problem go away. (It is only used in the cpp folder, from memory this includes :cpp.h, cpp.c, macro.c, include.c and maybe some other I forgot).
  • libc.lib no longer ships with Visual Studio. It should be replaced with libcmt.lib in etc\win32.src, which is apparently the multi-threaded version.
  • The compile output is littered with "ignoring unknown option -MLd" warnings.
  • I made it up to here, but then the test (make ... test) described in the installation guide fails because the file limits.s is generated nearly empty. The triple test (make ... triple) hangs forever.

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
Copy link

alexfru commented Jul 16, 2016

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:

  • Compile lburg
  • Run lburg on src\*.md to produce architecture-specific .c files (in reality I just did it for mips.md and removed other architectures (alpha, sparc, x86*) from src\bind.c; I also stumbled upon the missing check() function, which I defined as empty, however that's most likely wrong as it should come from dagcheck.md)
  • Compile src\*.c

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants