Import of lcc-4.1: retargetable ANSI C compiler

This commit is contained in:
gmcgarry 2001-07-21 02:51:35 +00:00
parent 68eec7a070
commit 973a0de16a
11 changed files with 1666 additions and 0 deletions

43
devel/lcc/Makefile Normal file
View file

@ -0,0 +1,43 @@
# $NetBSD: Makefile,v 1.1.1.1 2001/07/21 02:51:35 gmcgarry Exp $
DISTNAME= lcc-4.1
CATEGORIES= devel lang
MASTER_SITES= ftp://ftp.cs.princeton.edu/pub/lcc/
MAINTAINER= packages@netbsd.org
HOMEPAGE= http://www.research.microsoft.com/~cwfraser/
MAKE_ENV+= BUILDDIR=${WRKSRC}/bin HOSTFILE=etc/netbsd.c
.include "../../mk/bsd.prefs.mk"
BUILDDIR= ${WRKSRC}/src
MAKEFILE= makefile
post-extract:
${CP} ${FILESDIR}/x86bsd.md ${WRKSRC}/src/
${CP} ${FILESDIR}/netbsd.c ${WRKSRC}/etc/
pre-build:
${MKDIR} ${WRKSRC}/bin
cd ${WRKSRC}/etc ; \
[ -f netbsd.c.bak ] || ${MV} netbsd.c netbsd.c.bak ; \
${SED} \
-e 's|@PREFIX@|${PREFIX}|g' < netbsd.c.bak > netbsd.c
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/bin/bprint ${PREFIX}/libexec
${INSTALL_PROGRAM} ${WRKSRC}/bin/cpp ${PREFIX}/libexec
${INSTALL_PROGRAM} ${WRKSRC}/bin/lburg ${PREFIX}/libexec
${INSTALL_PROGRAM} ${WRKSRC}/bin/lcc ${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/bin/rcc ${PREFIX}/libexec
${INSTALL_DATA_DIR} ${PREFIX}/share/lcc/include
${INSTALL_DATA_DIR} ${PREFIX}/share/lcc/include/sys
${INSTALL_DATA} ${WRKSRC}/include/x86/linux/stdarg.h \
${PREFIX}/share/lcc/include
${INSTALL_DATA} ${FILESDIR}/cdefs.h \
${PREFIX}/share/lcc/include/sys
${INSTALL_MAN} ${WRKSRC}/doc/lcc.1 ${PREFIX}/man/man1
${INSTALL_MAN} ${WRKSRC}/doc/bprint.1 ${PREFIX}/man/man1
.include "../../mk/bsd.pkg.mk"

7
devel/lcc/distinfo Normal file
View file

@ -0,0 +1,7 @@
$NetBSD: distinfo,v 1.1.1.1 2001/07/21 02:51:35 gmcgarry Exp $
SHA1 (lcc-4.1.tar.gz) = aa5a0dd3c5317a8aa176e50d4c8c8799ae61fe8c
Size (lcc-4.1.tar.gz) = 664562 bytes
SHA1 (patch-aa) = d8ccdc999f0afe95154037762890bcce129943b7
SHA1 (patch-ab) = 516d8aa8e48e080b673f1e1a4b6c847ae1906dd4
SHA1 (patch-ac) = ce17a2edf165276869e1ecedd243f331d7420cbb

64
devel/lcc/files/cdefs.h Normal file
View file

@ -0,0 +1,64 @@
/* $NetBSD: cdefs.h,v 1.1.1.1 2001/07/21 02:51:35 gmcgarry Exp $ */
/*
* cdefs.h compatibility file to compile NetBSD with lcc 4.1
*/
#ifndef _SYS_CDEFS_H_
#define _SYS_CDEFS_H_
#define __asm__(x)
#define __attribute__(x)
/*
* The rest of this is based on:
*
* NetBSD: cdefs.h,v 1.36 2000/05/27 12:22:24 kleink Exp
*/
#include <machine/cdefs.h>
#ifdef __ELF__
#include <sys/cdefs_elf.h>
#else
#include <sys/cdefs_aout.h>
#endif
#define __BEGIN_DECLS
#define __END_DECLS
#define ___STRING(x) __STRING(x)
#define ___CONCAT(x,y) __CONCAT(x,y)
#define __P(protos) protos /* full-blown ANSI C */
#define __CONCAT(x,y) x ## y
#define __STRING(x) #x
#define __const const /* define reserved names to standard */
#define __signed signed
#define __volatile volatile
#define __inline /* delete GCC keyword */
#define __kprintf_attribute__(a)
#define __extension__ /* delete __extension__ if non-gcc or gcc1 */
#define __dead
#define __pure
#define __RENAME(x)
#define __GNUC_PREREQ__(x, y) 0
#ifdef __AUDIT__
#define __aconst __const
#else
#define __aconst
#endif
#if defined(_KERNEL)
#if defined(NO_KERNEL_RCSIDS)
#undef __KERNEL_RCSID
#define __KERNEL_RCSID(_n, _s) /* nothing */
#endif /* NO_KERNEL_RCSIDS */
#endif /* _KERNEL */
#endif

112
devel/lcc/files/netbsd.c Normal file
View file

@ -0,0 +1,112 @@
/*
* $NetBSD: netbsd.c,v 1.1.1.1 2001/07/21 02:51:35 gmcgarry Exp $
*
* i386 netbsd (GNU as, GNU ld)
*/
#include <string.h>
#define LCC_LIBPATH "@PREFIX@/libexec/"
#define LCC_INCPATH "@PREFIX@/share/lcc/include"
char *suffixes[] = { ".c", ".i", ".s", ".o", ".out", 0 };
char inputs[256] = "";
char *cpp[] = {
LCC_LIBPATH "cpp",
"-D__STDC__=1",
#ifdef __ELF__
"-D__ELF__",
#else
"",
#endif
"-Di386",
"-D__NetBSD__",
"-D__KPRINTF_ATTRIBUTE__",
"-D__STRICT_ANSI__",
"", /* _POSIX_SOURCE */
"$1",
"$2",
"$3",
0
};
char *include[] = {
"-I" LCC_INCPATH,
"-I/usr/include",
0
};
char *com[] = {
LCC_LIBPATH "rcc",
#ifdef __ELF__
"-target=x86/netbsdelf",
#else
"-target=x86/netbsd",
#endif
"$1",
"$2",
"$3",
0
};
char *as[] = {
"/usr/bin/as",
"-o",
"$3",
"$1",
"$2",
0
};
char *ld[] = {
"/usr/bin/ld",
"-m",
#ifdef __ELF__
"elf_i386",
#else
"i386nbsd",
#endif
"-dynamic-linker",
#ifdef __ELF__
"/usr/libexec/ld.elf_so",
#else
"/usr/libexec/ld.aout_so",
#endif
"-o",
"$3",
"$1",
"/usr/lib/crt0.o",
"/usr/lib/crtbegin.o",
"$2",
"", /* -b */
"-lc",
"/usr/lib/crtend.o",
0
};
static char *bbexit = LCC_LIBPATH "bbexit.o";
extern char *concat(char *, char *);
extern int access(const char *, int);
int option(char *arg) {
if (strncmp(arg, "-lccdir=", 8) == 0) {
cpp[0] = concat(&arg[8], "/cpp");
include[0] = concat("-I", concat(&arg[8], "/include"));
com[0] = concat(&arg[8], "/rcc");
bbexit = concat(&arg[8], "/bbexit.o");
} else if (strncmp(arg, "-posix",6) == 0) {
cpp[7] = "-D_POSIX_SOURCE";
} else if (strcmp(arg, "-g") == 0)
;
else if (strcmp(arg, "-b") == 0 && access(bbexit, 4) == 0)
ld[11] = bbexit;
else if (strcmp(arg, "-p") == 0) {
ld[8] = "/usr/lib/gcrt0.o";
ld[14] = "-lc_p";
}
else if (strcmp(arg, "-static") == 0) {
ld[3] = "-static";
ld[4] = "";
}
else
return 0;
return 1;
}

1313
devel/lcc/files/x86bsd.md Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,46 @@
$NetBSD: patch-aa,v 1.1.1.1 2001/07/21 02:51:36 gmcgarry Exp $
--- makefile.orig Tue Jun 5 19:16:00 2001
+++ makefile Tue Jun 5 19:18:07 2001
@@ -65,7 +65,8 @@
$Bsparc$O \
$Bstab$O \
$Bx86$O \
- $Bx86linux$O
+ $Bx86linux$O \
+ $Bx86bsd$O
$Brcc$E:: $Bmain$O $Blibrcc$A $(EXTRAOBJS)
$(LD) $(LDFLAGS) -o $@ $Bmain$O $(EXTRAOBJS) $Blibrcc$A $(EXTRALIBS)
@@ -111,6 +112,7 @@
$Bsparc$O: $Bsparc.c; $(CC) $(CFLAGS) -c -Isrc -o $@ $Bsparc.c
$Bx86$O: $Bx86.c; $(CC) $(CFLAGS) -c -Isrc -o $@ $Bx86.c
$Bx86linux$O: $Bx86linux.c; $(CC) $(CFLAGS) -c -Isrc -o $@ $Bx86linux.c
+$Bx86bsd$O: $Bx86bsd.c; $(CC) $(CFLAGS) -c -Isrc -o $@ $Bx86bsd.c
$Bdagcheck.c: $Blburg$E src/dagcheck.md; $Blburg src/dagcheck.md $@
$Balpha.c: $Blburg$E src/alpha.md; $Blburg src/alpha.md $@
@@ -118,6 +120,7 @@
$Bsparc.c: $Blburg$E src/sparc.md; $Blburg src/sparc.md $@
$Bx86.c: $Blburg$E src/x86.md; $Blburg src/x86.md $@
$Bx86linux.c: $Blburg$E src/x86linux.md; $Blburg src/x86linux.md $@
+$Bx86bsd.c: $Blburg$E src/x86bsd.md; $Blburg src/x86bsd.md $@
$Brcc.h: src/rcc.asdl; $(ASDL_HOME)/bin/asdlGen --c -d $B src/rcc.asdl
$Brcc$O: $Brcc.h; $(CC) $(CFLAGS) -c -Isrc -I$B -I$(ASDL_HOME)/include/asdlGen -o $@ $Brcc.c
@@ -231,7 +234,7 @@
clean:: testclean
$(RM) $B*$O
- $(RM) $Bdagcheck.c $Balpha.c $Bmips.c $Bx86.c $Bsparc.c $Bx86linux.c $Bgram.c
+ $(RM) $Bdagcheck.c $Balpha.c $Bmips.c $Bx86.c $Bsparc.c $Bx86linux.c $Bx86bsd.c $Bgram.c
$(RM) $Brcc.c $Brcc.h
$(RM) $Brcc1$E $Brcc1$E $B1rcc$E $B2rcc$E
$(RM) $B*.ilk
@@ -274,6 +277,7 @@
$Bmips.c \
$Bsparc.c \
$Bx86linux.c \
+ $Bx86bsd.c \
$Bx86.c
C=$Blcc -A -d0.6 -Wo-lccdir=$(BUILDDIR) -Isrc -I$(BUILDDIR)

View file

@ -0,0 +1,21 @@
$NetBSD: patch-ab,v 1.1.1.1 2001/07/21 02:51:36 gmcgarry Exp $
--- src/bind.c.orig Tue Sep 22 06:34:26 1998
+++ src/bind.c Thu Jun 7 19:41:37 2001
@@ -2,7 +2,7 @@
extern Interface alphaIR;
extern Interface mipsebIR, mipselIR;
extern Interface sparcIR, solarisIR;
-extern Interface x86IR, x86linuxIR;
+extern Interface x86IR, x86linuxIR, x86bsdIR, x86bsdelfIR;
extern Interface symbolicIR, symbolic64IR;
extern Interface nullIR;
extern Interface bytecodeIR;
@@ -14,6 +14,8 @@
"sparc/solaris", &solarisIR,
"x86/win32", &x86IR,
"x86/linux", &x86linuxIR,
+ "x86/netbsd", &x86bsdIR,
+ "x86/netbsdelf", &x86bsdelfIR,
"symbolic/osf", &symbolic64IR,
"symbolic/irix", &symbolicIR,
"symbolic", &symbolicIR,

View file

@ -0,0 +1,46 @@
$NetBSD: patch-ac,v 1.1.1.1 2001/07/21 02:51:36 gmcgarry Exp $
--- etc/lcc.c.orig Tue Aug 22 19:56:56 2000
+++ etc/lcc.c Tue Aug 22 21:24:43 2000
@@ -552,6 +552,20 @@
exit(n = 100);
}
+/* parse -W[alp] argument, splitting at commas, a la gcc */
+static List wappend (char *warg, List lst) {
+ if (*warg != ',') return append (warg, lst);
+ warg++;
+ do {
+ char *s = warg;
+ for (; *warg && *warg != ','; warg++)
+ ;
+ if (*warg) *warg++= '\0';
+ if (*s) lst = append (s, lst);
+ } while (*warg);
+ return lst;
+}
+
/* opt - process option in arg */
static void opt(char *arg) {
switch (arg[1]) { /* multi-character options */
@@ -563,7 +577,7 @@
return;
break;
case 'p':
- plist = append(&arg[3], plist);
+ plist = wappend(&arg[3], plist);
return;
case 'f':
if (strcmp(&arg[3], "-C") || option("-b")) {
@@ -572,10 +586,10 @@
}
break; /* and fall thru */
case 'a':
- alist = append(&arg[3], alist);
+ alist = wappend(&arg[3], alist);
return;
case 'l':
- llist[0] = append(&arg[3], llist[0]);
+ llist[0] = wappend(&arg[3], llist[0]);
return;
}
fprintf(stderr, "%s: %s ignored\n", progname, arg);

1
devel/lcc/pkg/COMMENT Normal file
View file

@ -0,0 +1 @@
lcc is a local ANSI C compiler for a variety of platforms.

3
devel/lcc/pkg/DESCR Normal file
View file

@ -0,0 +1,3 @@
This hierarchy is the distribution for lcc, the retargetable compiler
for ANSI C described in the book `A Retargetable C Compiler: Design and
Implementation' (Addison-Wesley, 1995, ISBN 0-8053-1670-1).

10
devel/lcc/pkg/PLIST Normal file
View file

@ -0,0 +1,10 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2001/07/21 02:51:35 gmcgarry Exp $
bin/lcc
libexec/bprint
libexec/cpp
libexec/lburg
libexec/rcc
share/lcc/include/stdarg.h
share/lcc/include/sys/cdefs.h
man/man1/lcc.1
man/man1/bprint.1