tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PCC in build.sh



The build system currently doesn't provide itself with hooks for an alternative compiler. Here's what I did for PCC:

- HAVE_GCC and HAVE_PCC variables control which compiler will be used. defaults to HAVE_GCC = 4
- MKPCC variable controls whether PCC is compiled during the build

For build.sh:

- PCC compiles the do-gnu-lib-crtstuff4 target, although this code actually appears to be NetBSD code, not GNU code. - there are no c++ nor objc compilers in PCC, so these host tools use false(1)
- a directory tools/pcc is created to build a host tool

It seems to work reasonably well. Is there a fundamental problem with this approach?


Index: Makefile
===================================================================
RCS file: /cvsroot/src/Makefile,v
retrieving revision 1.255
diff -u -r1.255 Makefile
--- Makefile    29 Jul 2008 13:17:40 -0000      1.255
+++ Makefile    13 Aug 2008 23:02:20 -0000
@@ -84,6 +84,8 @@
 #   do-libgcc:       builds and installs prerequisites from
 #                    gnu/lib/crtstuff${LIBGCC_EXT} (if necessary) and
 #                    gnu/lib/libgcc${LIBGCC_EXT}.
+#   do-libpcc:       builds and install prerequisites from
+#                    ??? (if necessary) and ???.
 #   do-lib-libc:     builds and installs prerequisites from lib/libc.
 #   do-lib:          builds and installs prerequisites from lib.
 #   do-gnu-lib:      builds and installs prerequisites from gnu/lib.
@@ -179,11 +181,13 @@
 #
 # Targets (in order!) called by "make build".
 #
-.if ${HAVE_GCC} == "3"
+.if defined(HAVE_GCC)
+.if (${HAVE_GCC} == "3")
 LIBGCC_EXT=3
 .else
 LIBGCC_EXT=4
 .endif
+.endif

 BUILDTARGETS+= check-tools
 .if ${MKUPDATE} == "no" && !defined(NOCLEANDIR)
@@ -206,8 +210,15 @@
 .if ${MKGCC} != "no"
 BUILDTARGETS+= do-libgcc
 .endif
+.if ${MKPCC} != "no"
+BUILDTARGET+=  do-libpcc
+.endif
 BUILDTARGETS+= do-lib-libc
-BUILDTARGETS+= do-lib do-gnu-lib do-external-lib
+BUILDTARGETS+= do-lib
+.if defined(HAVE_GCC)
+BUILDTARGETS+= do-gnu-lib
+.endif
+BUILDTARGETS+= do-external-lib
 BUILDTARGETS+= do-sys-rump-fs-lib
 BUILDTARGETS+= do-ld.so
 BUILDTARGETS+= do-build
@@ -358,20 +369,48 @@
        @true
 .endfor

-.for dir in tools tools/compat lib/csu gnu/lib/crtstuff${LIBGCC_EXT} gnu/lib/libgcc${LIBGCC_EXT} lib/libc lib/libdes lib gnu/lib external/ lib sys/rump/fs/lib +.for dir in tools tools/compat lib/csu lib/libc lib/libdes lib external/lib sys/rump/fs/lib
 do-${dir:S/\//-/g}: .PHONY .MAKE
 .for targ in dependall install
        ${MAKEDIRTARGET} ${dir} ${targ}
 .endfor
 .endfor

+.if defined(HAVE_GCC)
+.for dir in gnu/lib/crtstuff${LIBGCC_EXT} gnu/lib/libgcc$ {LIBGCC_EXT} gnu/lib
+do-${dir:S/\//-/g}: .PHONY .MAKE
+.for targ in dependall install
+       ${MAKEDIRTARGET} ${dir} ${targ}
+.endfor
+.endfor
+.endif
+
+.if defined(HAVE_PCC)
+.for dir in gnu/lib/crtstuff4 dist/pcc-libs
+do-${dir:S/\//-/g}: .PHONY .MAKE
+.for targ in dependall install
+       ${MAKEDIRTARGET} ${dir} ${targ}
+.endfor
+.endfor
+.endif
+
 do-libgcc: .PHONY .MAKE
+.if defined(HAVE_GCC)
 .if ${MKGCC} != "no"
-.if (${HAVE_GCC} == "3" || ${HAVE_GCC} == "4")
+.if defined(HAVE_GCC) && (${HAVE_GCC} == "3" || ${HAVE_GCC} == "4")
        ${MAKEDIRTARGET} . do-gnu-lib-crtstuff${LIBGCC_EXT}
 .endif
        ${MAKEDIRTARGET} . do-gnu-lib-libgcc${LIBGCC_EXT}
 .endif
+.endif
+
+do-libpcc: .PHONY .MAKE
+.if defined(HAVE_PCC)
+.if ${MKPCC} != "no"
+       ${MAKEDIRTARGET} . do-gnu-lib-crtstuff4
+       ${MAKEDIRTARGET} . do-pcc-lib-libpcc
+.endif
+.endif

 do-ld.so: .PHONY .MAKE
 .for targ in dependall install
Index: share/mk/bsd.own.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.own.mk,v
retrieving revision 1.518
diff -u -r1.518 bsd.own.mk
--- share/mk/bsd.own.mk 2 Aug 2008 06:59:24 -0000       1.518
+++ share/mk/bsd.own.mk 13 Aug 2008 23:03:51 -0000
@@ -41,17 +41,21 @@
 TOOLCHAIN_MISSING?=    no

 # default to GCC4
-HAVE_GCC?=     4
+.if !defined(HAVE_GCC) && !defined(HAVE_PCC)
+HAVE_GCC=      4
+.endif

 # default to GDB6
 HAVE_GDB?=     6

 CPPFLAG_ISYSTEM=       -isystem
+.if defined(HAVE_GCC)
 .if ${HAVE_GCC} == 3
 CPPFLAG_ISYSTEMXX=     -isystem-cxx
 .else  # GCC 4
 CPPFLAG_ISYSTEMXX=     -cxx-isystem
 .endif
+.endif

 .if empty(.MAKEFLAGS:M-V*)
 .if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
@@ -175,13 +179,22 @@
 STRIP=         ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
 .endif                                                                 #  }

-.if ${USETOOLS_GCC:Uyes} == "yes"                                    #  {
+.if defined(HAVE_GCC) && ${USETOOLS_GCC:Uyes} == "yes"                       # 
 {
 CC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
 CPP=           ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
 CXX=           ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
 FC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77
 OBJC=          ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
 .endif                                                                 #  }
+
+.if defined(HAVE_PCC) && ${USETOOLS_PCC:Uyes} == "yes"
+CC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
+CPP=           ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp
+CXX=           false
+FC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77
+OBJC=          false
+.endif
+
 .endif # EXTERNAL_TOOLCHAIN                                            # }

 HOST_MKDEP=    ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep
@@ -412,7 +425,7 @@
 MKISCSI=       no
 # XXX GCC 4 outputs mcount() calling sequences that try to load values
 # from over 64KB away and this fails to assemble.
-.if ${HAVE_GCC} == 4
+.if defined(HAVE_GCC) && (${HAVE_GCC} == 4)
 NOPROFILE=     # defined
 .endif
 .endif
@@ -557,7 +570,9 @@
        MKMAN \
        MKNLS MKNVI \
        MKOBJ \
-       MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
+       MKPAM \
+       MKPCC MKPCCCMDS \
+       MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
        MKSHARE MKSKEY MKSTATICLIB \
        MKYP
 ${var}?=       yes
@@ -569,7 +584,6 @@
 .for var in \
        MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \
        MKMANZ MKMODULAR MKOBJDIRS \
-       MKPCC MKPCCCMDS \
        MKPUFFS MKSOFTFLOAT \
        MKUNPRIVED MKUPDATE MKX11 MKXORG
 ${var}?=no
Index: tools/Makefile
===================================================================
RCS file: /cvsroot/src/tools/Makefile,v
retrieving revision 1.117
diff -u -r1.117 Makefile
--- tools/Makefile      26 May 2008 12:45:50 -0000      1.117
+++ tools/Makefile      13 Aug 2008 23:04:43 -0000
@@ -1,8 +1,9 @@

 .include <bsd.own.mk>

+.if defined(HAVE_GCC)
 .if ${HAVE_GCC} == "4"
 TOOLCHAIN_BITS= gmake .WAIT
 .endif
 .if ${TOOLCHAIN_MISSING} == "no"
 TOOLCHAIN_BITS+= binutils .WAIT
@@ -15,6 +16,16 @@
 # XXX Eventually, we want to be able to build dbsym and mdsetimage
 # XXX if EXTERNAL_TOOLCHAIN is set.
 .endif
+.endif
+
+.if defined(HAVE_PCC)
+TOOLCHAIN_BITS= gmake .WAIT
+.if ${TOOLCHAIN_MISSING} == "no"
+TOOLCHAIN_BITS+= binutils .WAIT
+TOOLCHAIN_BITS+= pcc
+.endif
+TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
+.endif

 LINT_BITS=
 .if ${MKLINT} != "no"



Home | Main Index | Thread Index | Old Index