lcc is the retargetable ANSI C compiler described in the book

`A Retargetable C Compiler: Design and Implementation'
(Addison-Wesley, 1995, ISBN 0-8053-1670-1).

lcc is a production compiler with a hand crafted lexical analyzer and a
hand-coded recursive decent parser.  The lexer and parser code is well
written and very easy to read (and learn from :-)).

lcc compiles much faster than FreeBSD's stock [gcc] compiler.  However, it
does not under stand FreeBSD's "long long" data type.

Contributions by:	Soren Schmidt
This commit is contained in:
David E. O'Brien 1996-12-27 11:09:49 +00:00
parent 090e1f74d4
commit a7ed5d35e0
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=5108
9 changed files with 1412 additions and 0 deletions

52
lang/lcc/Makefile Normal file
View File

@ -0,0 +1,52 @@
# ex:ts=8
# Ports collection makefile for: lcc
# Version required: 3.6
# Date created: Sat Dec 7, 1996
# Whom: David O'Brien (obrien@cs.ucdavis.edu)
#
# $Id: Makefile,v 1.1.1.1 1996/08/09 04:17:16 asami Exp $
#
DISTNAME= lcc-3.6
CATEGORIES= lang
MASTER_SITES= ftp://ftp.cs.princeton.edu/pub/packages/lcc/
MAINTAINER= obrien@FreeBSD.org
#origial [and extensive] patches by Soren Schmidt / sos@freebsd.org
MAKEFILE= makefile
MAKE_FLAGS= BUILDDIR=${LCCBUILDDIR} HOSTFILE=etc/${OPSYS}.c -f
MAN1= bprint.1 lcc.1
UNAME_M!= uname -m
LCCBUILDDIR= ${WRKDIR}/${UNAME_M}-${OPSYS}
LCCDESTDIR= lib/${DISTNAME}/${UNAME_M}-${OPSYS}
pre-configure:
@${MKDIR} ${LCCBUILDDIR}
@${CP} ${FILESDIR}/${OPSYS}.md ${WRKSRC}/src
@sed -e "s:%%PREFIX%%:${PREFIX}:g" \
-e "s:%%LCCDESTDIR%%:${LCCDESTDIR}:g" \
-e "s:%%VERSION%%:${DISTNAME}:g" \
${FILESDIR}/${OPSYS}.c.in > ${WRKSRC}/etc/${OPSYS}.c
@sed -e "s:%%LCCDESTDIR%%:${LCCDESTDIR}:g" \
${PKGDIR}/PLIST.in > ${PKGDIR}/PLIST
@sed -e "s:%%OPSYS%%:${OPSYS}:g" \
${WRKSRC}/makefile > ${WRKSRC}/makefile.configured
@/bin/mv -f ${WRKSRC}/makefile.configured ${WRKSRC}/makefile
do-install:
@(umask 022 ; ${MKDIR} ${PREFIX}/${LCCDESTDIR})
@${INSTALL_PROGRAM} ${LCCBUILDDIR}/lcc \
${LCCBUILDDIR}/rcc \
${LCCBUILDDIR}/cpp \
${LCCBUILDDIR}/bprint \
${LCCBUILDDIR}/bbexit.o \
${PREFIX}/${LCCDESTDIR}
@/bin/ln -sf ${PREFIX}/${LCCDESTDIR}/lcc ${PREFIX}/bin
@/bin/ln -sf ${PREFIX}/${LCCDESTDIR}/bprint ${PREFIX}/bin
@${INSTALL_MAN} ${WRKSRC}/doc/lcc.1 ${WRKSRC}/doc/bprint.1 \
${PREFIX}/man/man1
.include <bsd.port.mk>

1
lang/lcc/distinfo Normal file
View File

@ -0,0 +1 @@
MD5 (lcc-3.6.tar.gz) = 0085cc6019bcb10a6228bcaa71edc78d

View File

@ -0,0 +1,78 @@
/*
* freebsd.c -- lcc driver definitions for FreeBSD-2.2.x.
*
*/
#include <string.h>
static char rcsid[] = "$Id$";
#ifndef LCCDIR
#define LCCDIR "%%PREFIX%%/%%LCCDESTDIR%%/"
#endif
/* char *stock_cpp[] = { */
char *cpp[] = {
"/usr/libexec/cpp",
"-undef", "-nostdinc", "-lang-c", "-U__GNUC__",
"-D_POSIX_SOURCE", "-D__STDC__", "-D__STRICT_ANSI__",
"-Dunix", "-Di386", "-DFreeBSD",
"-D__unix__", "-D__i386__", "-D__FreeBSD__",
"$1", "$2", "$3", 0};
char *lcc_ritchey_cpp[] = {
LCCDIR "cpp",
"-D__STDC__=1", "-D__STRICT_ANSI__",
"-D_POSIX_SOURCE",
"-U__GNUC__",
"-Dunix", "-D__unix__",
"-DFreeBSD", "-D__FreeBSD__",
"-Di386", "-D__i386__",
"-Dx86", "-D__x86__",
"$1", "$2", "$3", 0
};
/* char **cpp = stock_cpp; */
char *include[] = {
"-I" LCCDIR "include",
"-I%%PREFIX%%/include/%%VERSION%%",
"-I/usr/include",
"-I%%PREFIX%%/include",
0
};
char *com[] = {
LCCDIR "rcc",
"-target=i386-FreeBSD",
"$1", "$2", "$3", 0
};
char *as[] = {"/usr/bin/as", "-o", "$3", "$1", "$2", 0};
char *ld[] = {"/usr/bin/ld", "", "-estart", "-dc", "-dp", "-o", "$3",
"/usr/lib/crt0.o", "$1", "$2", "",
"-lm", "", "-lc", "", "",
#if 0
"-lgcc",
#endif
0};
int
option(arg)
char *arg;
{
if (strcmp(arg, "-g") == 0) {}
else if (strcmp(arg, "-p") == 0) {
ld[8] = "/usr/lib/gcrt0.o";
ld[14] = "-lc_p";
}
else if (strcmp(arg, "-b") == 0 &&
access(LCCDIR "bbexit.o", 4) == 0) {
ld[11] = LCCDIR "bbexit.o";
} else {
return 0;
}
return 1;
}

1200
lang/lcc/files/FreeBSD.md Normal file

File diff suppressed because it is too large Load Diff

23
lang/lcc/files/patch-01 Normal file
View File

@ -0,0 +1,23 @@
--- makefile.orig Sat Oct 19 06:17:24 1996
+++ makefile Sun Dec 8 19:40:15 1996
@@ -40,6 +40,7 @@
$(BUILDDIR)/gen.o \
$(BUILDDIR)/mips.o \
$(BUILDDIR)/sparc.o \
+ $(BUILDDIR)/%%OPSYS%%.o \
$(BUILDDIR)/x86.o
$(BUILDDIR)/rcc: $(RCCOBJS)
@@ -76,10 +77,12 @@
$(BUILDDIR)/mips.o: $(BUILDDIR)/mips.c; $(CC) -c $(CFLAGS) -Isrc -o $@ $(BUILDDIR)/mips.c
$(BUILDDIR)/sparc.o: $(BUILDDIR)/sparc.c; $(CC) -c $(CFLAGS) -Isrc -o $@ $(BUILDDIR)/sparc.c
+$(BUILDDIR)/%%OPSYS%%.o: $(BUILDDIR)/%%OPSYS%%.c; $(CC) -c $(CFLAGS) -Isrc -o $@ $(BUILDDIR)/%%OPSYS%%.c
$(BUILDDIR)/x86.o: $(BUILDDIR)/x86.c; $(CC) -c $(CFLAGS) -Isrc -o $@ $(BUILDDIR)/x86.c
$(BUILDDIR)/mips.c: $(BUILDDIR)/lburg src/mips.md; $(BUILDDIR)/lburg <src/mips.md >$@
$(BUILDDIR)/sparc.c: $(BUILDDIR)/lburg src/sparc.md; $(BUILDDIR)/lburg <src/sparc.md >$@
+$(BUILDDIR)/%%OPSYS%%.c: $(BUILDDIR)/lburg src/%%OPSYS%%.md; $(BUILDDIR)/lburg <src/%%OPSYS%%.md >$@
$(BUILDDIR)/x86.c: $(BUILDDIR)/lburg src/x86.md; $(BUILDDIR)/lburg <src/x86.md >$@
YFLAGS=

28
lang/lcc/files/patch-02 Normal file
View File

@ -0,0 +1,28 @@
--- etc/lcc.c.orig Fri Oct 18 17:37:14 1996
+++ etc/lcc.c Sun Dec 8 19:42:38 1996
@@ -433,9 +433,9 @@
" unrecognized options are taken to be linker options\n",
"-A warn about nonANSI usage; 2nd -A warns more\n",
"-b emit expression-level profiling code; see bprint(1)\n",
-#ifdef sparc
+#if defined(sparc) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
"-Bstatic -Bdynamic specify static or dynamic libraries\n",
-#endif
+#endif
"-Bdir/ use the compiler named `dir/rcc'\n",
"-c compile only\n",
"-dn set switch statement density to `n'\n",
@@ -535,11 +535,11 @@
plist = append(arg, plist);
return;
case 'B': /* -Bdir -Bstatic -Bdynamic */
-#ifdef sun
+#if defined(sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
if (strcmp(arg, "-Bstatic") == 0 || strcmp(arg, "-Bdynamic") == 0)
llist[1] = append(arg, llist[1]);
else
-#endif
+#endif
{
static char *path;
if (path)

16
lang/lcc/files/patch-03 Normal file
View File

@ -0,0 +1,16 @@
--- src/bind.c.orig Fri Oct 18 17:38:38 1996
+++ src/bind.c Fri Dec 27 02:31:21 1996
@@ -1,10 +1,13 @@
#include "c.h"
extern Interface nullIR, symbolicIR;
+extern Interface x86freebsdIR;
extern Interface mipsebIR, mipselIR;
extern Interface sparcIR, solarisIR;
extern Interface x86IR;
+
Binding bindings[] = {
"symbolic", &symbolicIR,
+ "i386-FreeBSD", &x86freebsdIR,
"mips-irix", &mipsebIR,
"mips-ultrix", &mipselIR,
"sparc-sun", &sparcIR,

1
lang/lcc/pkg-comment Normal file
View File

@ -0,0 +1 @@
compiler from `A Retargetable C Compiler: Design and Implementation'

13
lang/lcc/pkg-descr Normal file
View File

@ -0,0 +1,13 @@
lcc is the retargetable ANSI C compiler described in the book
`A Retargetable C Compiler: Design and Implementation'
(Addison-Wesley, 1995, ISBN 0-8053-1670-1).
lcc is a production compiler with a hand crafted lexical analyzer and a
hand-coded recursive decent parser. The lexer and parser code is well
written and very easy to read (and learn from :-)).
lcc compiles much faster than FreeBSD's stock [gcc] compiler. However, it
does not under stand FreeBSD's "long long" data type.
See http://www.cs.princeton.edu/software/lcc/pkg/install.html for updates,
patches, and more information.