Building under windows with MingW/Msys

Building under windows with MingW/Msys

Post by Josh Schol » Tue, 17 Oct 2006 14:30:10


fter playing around with Building under Visual C 8.0 - and seeing the
lcc go into an infinite loop (I hit break after 30 minutes), I decided
to try building under MSys/Mingw32.

Since I'm not all that familiar with MSys or Unix, I'm surprised I got
as far as I did.

The first thing I did was make a host file "etc/mingw.c" that's a
mixture of "etc/win32.c" and "etc/linux.c". I think the libraries
should be wrong, and I'm not sure what defines like ""-Dwin32"/
"-D__linux__" do.

Here's what mingw.c looks like by the way (I'm sure it's not quite
right):
/* x86s running MS Windows NT 4.0 */

#include <string.h>

static char rcsid[] = "$Id: win32.c,v 1.19 2001/07/09 18:00:13 drh Exp
$";

#ifndef LCCDIR
#define LCCDIR "\\progra~1\\lcc\\4.2\\bin\\"
#endif

char *suffixes[] = { ".c", ".i", ".s", ".o", ".out", 0 };
char inputs[256] = "";
char *cpp[] = { LCCDIR "cpp",
"-U__GNUC__", "-D_POSIX_SOURCE", "-D__STDC__=1", "-D__STRICT_ANSI__",
"-Dwin32", "-D_WIN32", "-D_M_IX86","-D__signed__=signed",
"$1", "$2", "$3", 0 };
char *include[] = {"-I" LCCDIR "include", "-I" LCCDIR "gcc/include",
"-I/usr/include", 0 };
char *com[] = { LCCDIR "rcc", "-target=x86/win32", "$1", "$2", "$3", 0
};
char *as[] = { "/usr/bin/as", "-o", "$3", "$1", "$2", 0 };
char *ld[] = {
/* 0 */ "/usr/bin/ld", "-m", "elf_i386", "-dynamic-linker",
/* 4 */ "/lib/ld-linux.so.2", "-o", "$3",
/* 7 */ "/usr/lib/crt1.o", "/usr/lib/crti.o",
/* 9 */ LCCDIR "/gcc/crtbegin.o",
"$1", "$2",
/* 12 */ "-L" LCCDIR,
/* 13 */ "-llcc",
/* 14 */ "-L" LCCDIR "/gcc", "-lgcc", "-lc", "-lm",
/* 18 */ "",
/* 19 */ LCCDIR "/gcc/crtend.o", "/usr/lib/crtn.o",
0 };

extern char *concat(char *, char *);
extern char *replace(const char *, int, int);

int option(char *arg) {
if (strncmp(arg, "-lccdir=", 8) == 0) {
cpp[0] = concat(&arg[8], "/gcc/cpp");
include[0] = concat("-I", concat(&arg[8], "/include"));
include[1] = concat("-I", concat(&arg[8], "/gcc/include"));
ld[9] = concat(&arg[8], "/gcc/crtbegin.o");
ld[12] = concat("-L", &arg[8]);
ld[14] = concat("-L", concat(&arg[8], "/gcc"));
ld[19] = concat(&arg[8], "/gcc/crtend.o");
com[0] = concat(&arg[8], "/rcc");
} else if (strcmp(arg, "-p") == 0 || strcmp(arg, "-pg") == 0) {
ld[7] = "/usr/lib/gcrt1.o";
ld[18] = "-lgmon";
} else if (strcmp(arg, "-b") == 0)
;
else if (strcmp(arg, "-g") == 0)
;
else if (strncmp(arg, "-ld=", 4) == 0)
ld[0] = &arg[4];
else if (strcmp(arg, "-static") == 0) {
ld[3] = "-static";
ld[4] = "";
} else
return 0;
return 1;
}

Anyway I took a stab at it to see how far I could get, and to my shock,
it actually built and linked everything under "make all" (I had already
made a "cc" that aliased to "gcc.exe" and a "make" that aliased to
"mingw-32-make.exe").

But running "make target=x86/linux test" it stopped at a strange place:

cc -g -o c:/progra~1/lcc/4.2/bin/lburg c:/progra~1/lcc/4.2/bin/lburg.o
c:/progra~1/lcc/4.2/bin/gram.o
c:/progra~1/lcc/4.2/bin/lburg src/dagcheck.md
c:/progra~1/lcc/4.2/bin/dagcheck.c
cc -g -c -Isrc -o c:/progra~1/lcc/4.2/bin/dagcheck.o
c:/progra~1/lcc/4.2/bin/dagcheck.c
c:/progra~1/lcc/4.2/bin/lburg src/alpha.md
c:/progra~1/lcc/4.2/bin/alpha.c
cc -g -c -Isrc -o c:/progra~1/lcc/4.2/bin/alpha.o
c:/progra~1/lcc/4.2/bin/alpha.c
c:/progra~1/lcc/4.2/bin/lburg src/mips.md
c:/progra~1/lcc/4.2/bin/mips.c
cc -g -c -Isrc -o c:/progra~1/lcc/
 
 
 

Building under windows with MingW/Msys

Post by Josh Schol » Tue, 17 Oct 2006 14:39:48

y the way "make triple" gets as far as:

...
c:/progra~1/lcc/4.2/bin/lcc -A -d0.6 -Wo-lccdir=c:/progra~1/lcc/4.2/bin
-Isrc -Ic:/progra~1/lcc/4.2/bin -o c:/progra~1/lcc/4.2/bin/1rcc
-Bc:/progra~1/lcc/4.2/bin/ src/alloc.c src/bind.c src/dag.c src/decl.c
src/enode.c src/error.c src/expr.c src/event.c src/init.c src/inits.c
src/input.c src/lex.c src/list.c src/main.c src/output.c src/prof.c
src/profio.c src/simp.c src/stmt.c src/string.c src/sym.c src/trace.c
src/tree.c src/types.c src/null.c src/symbolic.c src/bytecode.c
src/gen.c src/stab.c c:/progra~1/lcc/4.2/bin/dagcheck.c
c:/progra~1/lcc/4.2/bin/alpha.c c:/progra~1/lcc/4.2/bin/mips.c
c:/progra~1/lcc/4.2/bin/sparc.c c:/progra~1/lcc/4.2/bin/x86linux.c
c:/progra~1/lcc/4.2/bin/x86.c
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
c:/progra~1/lcc/4.2/bin/gcc/cpp: No such file or directory
src/alloc.c:
c:/progra~1/lcc/4.2/bin/lcc: src/bind.c:
c:/progra~1/lcc/4.2/bin/lcc: src/dag.c:
c:/progra~1/lcc/4.2/bin/lcc: src/decl.c:
c:/progra~1/lcc/4.2/bin/lcc: src/enode.c:
c:/progra~1/lcc/4.2/bin/lcc: src/error.c:
c:/progra~1/lcc/4.2/bin/lcc: src/expr.c:
c:/progra~1/lcc/4.2/bin/lcc: src/event.c:
c:/progra~1/lcc/4.2/bin/lcc: src/init.c:
c:/progra~1/lcc/4.2/bin/lcc: src/inits.c:
c:/progra~1/lcc/4.2/bin/lcc: src/input.c:
c:/progra~1/lcc/4.2/bin/lcc: src/lex.c:
c:/progra~1/lcc/4.2/bin/lcc: src/list.c:
c:/progra~1/lcc/4.2/bin/lcc: src/main.c:
c:/progra~1/lcc/4.2/bin/lcc: src/output.c:
c:/progra~1/lcc/4.2/bin/lcc: src/prof.c
 
 
 

Building under windows with MingW/Msys

Post by Josh Schol » Tue, 17 Oct 2006 15:16:38

By the way, I just tried building with "HOSTFILE=etc/linux.c" and it
acted exactly the same.
 
 
 

Building under windows with MingW/Msys

Post by Josh Schol » Wed, 18 Oct 2006 05:59:44

Update, after fixing some directory links, the MingW version is getting
further, but there's a problem that the win32 compiler spits out intel
ordered assembly and "MingW/as" uses the other order...

Also the first attempt to build using the unix assembly output couldn't
compile... I'll look into why later.