Subject: libgcc (take #2)
To: None <tech-toolchain@netbsd.org>
From: Nick Hudson <skrll@netbsd.org>
List: tech-toolchain
Date: 02/12/2004 22:09:36
--Boundary-00=_gm/KA7lakwYOtyf
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I've made some updates to my libgcc patch and unless anyone can give me a good 
reason not to I'm going to commit this on Sunday.

LIBGCC_SPEC is a bit complex because I didn't want libgcc_s.so linked into 
every shared library. I think it should only be linked in where required 
using --shared-libgcc.

Nick

--Boundary-00=_gm/KA7lakwYOtyf
Content-Type: text/x-diff;
  charset="us-ascii";
  name="libgcc.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="libgcc.diff"

Index: Makefile
===================================================================
RCS file: /cvsroot/src/Makefile,v
retrieving revision 1.230
diff -u -r1.230 Makefile
--- Makefile	6 Feb 2004 23:12:56 -0000	1.230
+++ Makefile	12 Feb 2004 22:05:07 -0000
@@ -185,6 +185,7 @@
 BUILDTARGETS+=	includes
 .endif
 BUILDTARGETS+=	do-tools-compat
+BUILDTARGETS+=	do-lib-csu
 .if ${MKGCC} != "no"
 BUILDTARGETS+=	do-gnu-lib-libgcc${LIBGCC_EXT}
 .endif
Index: distrib/sets/lists/comp/gcc.shl
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/comp/gcc.shl,v
retrieving revision 1.5
diff -u -r1.5 gcc.shl
--- distrib/sets/lists/comp/gcc.shl	11 Jan 2004 10:13:42 -0000	1.5
+++ distrib/sets/lists/comp/gcc.shl	12 Feb 2004 22:05:07 -0000
@@ -5,7 +5,13 @@
 ./usr/lib/libg2c.so.2				comp-fortran-shlib
 ./usr/lib/libg2c.so.2.0				comp-fortran-shlib
 ./usr/lib/libg2c_pic.a				comp-fortran-lib
+./usr/lib/libgcc_eh.a				comp-c-lib
+./usr/lib/libgcc_eh_p.a				comp-c-proflib		profile
+./usr/lib/libgcc_eh_pic.a			comp-c-piclib
 ./usr/lib/libgcc_pic.a				comp-c-piclib
+./usr/lib/libgcc_s.so				comp-c-lib
+./usr/lib/libgcc_s.so.1				comp-c-shlib
+./usr/lib/libgcc_s.so.1.0			comp-c-shlib
 ./usr/lib/libobjc.so				comp-objc-lib
 ./usr/lib/libobjc_pic.a				comp-objc-piclib
 ./usr/lib/libopcodes.so.1			comp-c-shlib		bfd
Index: gnu/dist/gcc/gcc/gcc.c
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/gcc/gcc.c,v
retrieving revision 1.6
diff -u -r1.6 gcc.c
--- gnu/dist/gcc/gcc/gcc.c	11 Feb 2004 16:01:48 -0000	1.6
+++ gnu/dist/gcc/gcc/gcc.c	12 Feb 2004 22:05:14 -0000
@@ -1466,14 +1466,28 @@
 {
   char *buf;
 
-  buf = concat ("%{static|static-libgcc:", static_name, " ", eh_name,
+  buf = concat ("%{static",
+#ifdef LIBGCC_PICSUFFIX
+		": ", static_name, " ", eh_name, "}",
+		"%{static-libgcc: ",
+		"%{!shared:", static_name, " ", eh_name, "}",
+		"%{shared:", static_name, LIBGCC_PICSUFFIX, " ",
+		eh_name, LIBGCC_PICSUFFIX, "}",
+#else
+		"|static-libgcc:", static_name, " ", eh_name, 
+#endif
 		"}%{!static:%{!static-libgcc:",
 		"%{!shared:%{!shared-libgcc:", static_name, " ",
 		eh_name, "}%{shared-libgcc:", shared_name, " ",
 		static_name, "}}%{shared:",
-#ifdef LINK_EH_SPEC
+/* XXX NH XXX */
+#if defined(LINK_EH_SPEC) || 1
 		"%{shared-libgcc:", shared_name,
-		"}%{!shared-libgcc:", static_name, "}",
+		"}%{!shared-libgcc:", static_name, 
+#ifdef LIBGCC_PICSUFFIX
+		LIBGCC_PICSUFFIX ,
+#endif
+		"}",
 #else
 		shared_name,
 #endif
Index: gnu/dist/gcc/gcc/config/netbsd.h
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/gcc/config/netbsd.h,v
retrieving revision 1.5
diff -u -r1.5 netbsd.h
--- gnu/dist/gcc/gcc/config/netbsd.h	13 Oct 2003 13:19:41 -0000	1.5
+++ gnu/dist/gcc/gcc/config/netbsd.h	12 Feb 2004 22:05:15 -0000
@@ -138,24 +138,13 @@
 #undef LIB_SPEC
 #define LIB_SPEC NETBSD_LIB_SPEC
 
-/* Provide a LIBGCC_SPEC appropriate for NetBSD.  We also want to exclude
-   libgcc with -symbolic.  */
+/* Don't provide a LIBGCC_SPEC for NetBSD as the default
+   is correct. In the --disabled-shared case -lgcc is perfect.  */
 
-#ifdef NETBSD_NATIVE
-#define NETBSD_LIBGCC_SPEC	\
-  "%{!symbolic:			\
-     %{!shared:			\
-       %{!p:			\
-	 %{!pg: -lgcc}}}	\
-     %{p: -lgcc_p}		\
-     %{pg: -lgcc_p}}"
-#else
-#define NETBSD_LIBGCC_SPEC "%{!shared:%{!symbolic: -lgcc}}"
+#if defined(NETBSD_TOOLS) || defined(NETBSD_NATIVE)
+#define	LIBGCC_PICSUFFIX	"_pic"
 #endif
 
-#undef LIBGCC_SPEC
-#define LIBGCC_SPEC NETBSD_LIBGCC_SPEC
-
 /* When building shared libraries, the initialization and finalization 
    functions for the library are .init and .fini respectively.  */
 
Index: gnu/lib/libgcc3/Makefile
===================================================================
RCS file: /cvsroot/src/gnu/lib/libgcc3/Makefile,v
retrieving revision 1.20
diff -u -r1.20 Makefile
--- gnu/lib/libgcc3/Makefile	11 Feb 2004 16:22:51 -0000	1.20
+++ gnu/lib/libgcc3/Makefile	12 Feb 2004 22:05:15 -0000
@@ -1,105 +1,11 @@
 #	$NetBSD: Makefile,v 1.20 2004/02/11 16:22:51 mrg Exp $
 
-REQUIRETOOLS=	yes
-NOLINT=		# defined
+SUBDIR+=	libgcc
 
 .include <bsd.own.mk>
 
-LIB=		gcc
-
-.cc: # disable .cc->NULL transform
-
-.if exists(${.CURDIR}/arch/${MACHINE_ARCH}.mk) && ${MKGCC} != "no"
-.include "${.CURDIR}/arch/${MACHINE_ARCH}.mk"
-
-DIST=		${NETBSDSRCDIR}/gnu/dist/gcc
-GNUHOSTDIST=	${DIST}
-GCCARCH=	${NETBSDSRCDIR}/gnu/usr.bin/gcc3/arch/${MACHINE_ARCH}
-GCCARCHXX=	${NETBSDSRCDIR}/gnu/lib/libstdc++-v3/arch/${MACHINE_ARCH}
-
-GCPPFLAGS=	${G_LIBGCC2_CFLAGS} ${G_USE_COLLECT2} ${G_INCLUDES}
-CPPFLAGS+=	-I${.CURDIR}
-CPPFLAGS+=	-I${GCCARCH} ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*}
-#CPPFLAGS+=	-I${G_EXTRA_HEADERS:H:u}
-CPPFLAGS+=	-I${DIST}/gcc/cp -I${GCCARCHXX} -I.
-
-LIB2FUNCS=	${G_LIB2FUNCS_1:=.c} ${G_LIB2FUNCS_2:=.c} ${G_LIB2FUNCS_ST:=.c}
-LIB2DIVMOD=	${G_LIB2_DIVMOD_FUNCS:=.c}
-LIB2_EH=	${G_LIB2ADDEH:M*.c:T}
-.if !empty(G_LIB1ASMFUNCS)
-LIB1ASMFUNCS=	${G_LIB1ASMFUNCS:=.S}
-.endif
-
-SRCS+=		${LIB2FUNCS} ${LIB2DIVMOD} ${LIB2_EH} \
-		${G_LIB2ADD:T:S/.asm/.S/} ${LIB1ASMFUNCS} \
-		${G_LIB2FUNCS_EXTRA}
-
-DPSRCS+=	${.CURDIR}/arch/${MACHINE_ARCH}.mk tconfig.h
-CLEANFILES+=	${LIB2FUNCS} ${LIB2DIVMOD} cs-tconfig.h tconfig.h
-
-# XXX
-.if ${MACHINE_ARCH} == "m68000"
-CPICFLAGS:=
-COMPILE.S=	${CC} ${AFLAGS} ${CPPFLAGS} -c
-_TRADITIONAL_CPP=
-fpgnulib.c: ${DIST}/gcc/config/m68k/fpgnulib.c
-	cp ${DIST}/gcc/config/m68k/fpgnulib.c fpgnulib.c
-xfgnulib.c: ${DIST}/gcc/config/m68k/fpgnulib.c
-	echo '#define EXTFLOAT' > xfgnulib.c
-	cat ${DIST}/gcc/config/m68k/fpgnulib.c >> xfgnulib.c
-.endif
-.if ${MACHINE_ARCH} == "powerpc"
-_TRADITIONAL_CPP=
-COMPILE.S=	${CC} ${AFLAGS} ${CPPFLAGS} -c
-.endif
-
-${LIB2FUNCS}: ${.CURDIR}/Makefile
-	${_MKTARGET_CREATE}
-	printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
-
-${LIB2DIVMOD}: ${.CURDIR}/Makefile
-	${_MKTARGET_CREATE}
-	printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
-
-.if !empty(LIB1ASMFUNCS)
-${LIB1ASMFUNCS}: ${.CURDIR}/Makefile
-	${_MKTARGET_CREATE}
-	printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET}
+.if ${MKPIC} != "no"
+SUBDIR+=	libgcc_eh libgcc_s
 .endif
 
-${G_LIB2ADD:M${GNUHOSTDIST}/*:T:S/.asm/.S/}: ${.CURDIR}/Makefile ${G_LIB2ADD}
-	@echo copying ${G_LIB2ADD}
-	for i in ${G_LIB2ADD}; do \
-		j=$${i##*/}; \
-		j=`echo $$j | sed 's/\.asm$$/\.S/'`; \
-		cp $$i $$j; \
-	done
-	@echo copying ${G_LIB2ADD} complete
-
-${LIB2_EH:.c=.o}:
-	${_MKTARGET_COMPILE}
-	${COMPILE.c} ${CPICFLAGS} -fexceptions -o ${.TARGET} ${.IMPSRC}
-
-${G_LIB2_DIVMOD_FUNCS:=.o}:
-	${_MKTARGET_COMPILE}
-	${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions -o ${.TARGET} ${.IMPSRC}
-
-dp-bit.c: ${.CURDIR}/Makefile
-	${_MKTARGET_CREATE}
-	printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET}
-
-.PATH: ${DIST}/gcc ${DIST}/gcc/cp ${DIST}/gcc/cp/inc ${DIST}/gcc/config \
-	${G_CONFIGDIR}
-
-.include <bsd.lib.mk>
-
-tconfig.h:
-	${_MKTARGET_CREATE}
-	TM_DEFINES="$(G_tm_defines)" \
-	HEADERS="$(G_xm_file)" XM_DEFINES="$(G_xm_defines)" \
-	TARGET_CPU_DEFAULT="" \
-	${HOST_SH} $(GNUHOSTDIST)/gcc/mkconfig.sh tconfig.h
-
-.else
-.include <bsd.prog.mk> # do nothing
-.endif
+.include <bsd.subdir.mk>
Index: gnu/lib/libgcc3/Makefile.inc
===================================================================
RCS file: gnu/lib/libgcc3/Makefile.inc
diff -N gnu/lib/libgcc3/Makefile.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/lib/libgcc3/Makefile.inc	12 Feb 2004 22:05:15 -0000
@@ -0,0 +1,90 @@
+#	$NetBSD$
+
+.if exists(${.CURDIR}/arch/${MACHINE_ARCH}.mk) && ${MKGCC} != "no"
+.include "${.CURDIR}/arch/${MACHINE_ARCH}.mk"
+.endif
+
+DIST=		${NETBSDSRCDIR}/gnu/dist/gcc
+GNUHOSTDIST=	${DIST}
+GCCARCH=	${NETBSDSRCDIR}/gnu/usr.bin/gcc3/arch/${MACHINE_ARCH}
+GCCARCHXX=	${NETBSDSRCDIR}/gnu/lib/libstdc++-v3/arch/${MACHINE_ARCH}
+
+GCPPFLAGS=	${G_LIBGCC2_CFLAGS} ${G_USE_COLLECT2} ${G_INCLUDES}
+CPPFLAGS+=	-I${.CURDIR}
+CPPFLAGS+=	-I${GCCARCH} ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*}
+CPPFLAGS+=	-I${G_EXTRA_HEADERS:H:u}
+CPPFLAGS+=	-I${DIST}/gcc/cp -I${GCCARCHXX} -I.
+
+LIB2FUNCS=	${G_LIB2FUNCS_1:=.c} ${G_LIB2FUNCS_2:=.c} ${G_LIB2FUNCS_ST:=.c}
+LIB2DIVMOD=	${G_LIB2_DIVMOD_FUNCS:=.c}
+LIB2_EH=	${G_LIB2ADDEH:M*.c:T}
+.if !empty(G_LIB1ASMFUNCS)
+LIB1ASMFUNCS=	${G_LIB1ASMFUNCS:=.S}
+.endif
+
+DPSRCS+=	${.CURDIR}/../arch/${MACHINE_ARCH}.mk tconfig.h
+CLEANFILES+=	${LIB2FUNCS} ${LIB2DIVMOD} cs-tconfig.h tconfig.h
+
+# XXX
+.if ${MACHINE_ARCH} == "m68000"
+CPICFLAGS:=
+COMPILE.S=	${CC} ${AFLAGS} ${CPPFLAGS} -c
+_TRADITIONAL_CPP=
+fpgnulib.c:	${DIST}/gcc/config/m68k/fpgnulib.c
+	cp ${DIST}/gcc/config/m68k/fpgnulib.c fpgnulib.c
+xfgnulib.c:	${DIST}/gcc/config/m68k/fpgnulib.c
+	echo '#define EXTFLOAT' > xfgnulib.c
+	cat ${DIST}/gcc/config/m68k/fpgnulib.c >> xfgnulib.c
+CLEANFILES+=	fpgnulib.c xfgnulib.c
+.endif
+.if ${MACHINE_ARCH} == "powerpc" || \
+    ${MACHINE_ARCH} == "sh3el" || \
+    ${MACHINE_ARCH} == "sh3eb"
+_TRADITIONAL_CPP=
+COMPILE.S=	${CC} ${AFLAGS} ${CPPFLAGS} -c
+.endif
+
+${LIB2FUNCS}: ${.CURDIR}/Makefile
+	${_MKTARGET_CREATE}
+	printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
+
+${LIB2DIVMOD}: ${.CURDIR}/Makefile
+	${_MKTARGET_CREATE}
+	printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
+
+.if !empty(LIB1ASMFUNCS)
+${LIB1ASMFUNCS}: ${.CURDIR}/Makefile
+	${_MKTARGET_CREATE}
+	printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET}
+.endif
+
+${G_LIB2ADD:M${GNUHOSTDIST}/*:T:S/.asm/.S/}: ${.CURDIR}/Makefile ${G_LIB2ADD}
+	@echo copying ${G_LIB2ADD}
+	for i in ${G_LIB2ADD}; do \
+		j=$${i##*/}; \
+		j=`echo $$j | sed 's/\.asm$$/\.S/'`; \
+		cp $$i $$j; \
+	done
+	@echo copying ${G_LIB2ADD} complete
+
+${LIB2_EH:.c=.o}:
+	${_MKTARGET_COMPILE}
+	${COMPILE.c} ${CPICFLAGS} -fexceptions -o ${.TARGET} ${.IMPSRC}
+
+${G_LIB2_DIVMOD_FUNCS:=.o}:
+	${_MKTARGET_COMPILE}
+	${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions -o ${.TARGET} ${.IMPSRC}
+
+dp-bit.c: ${.CURDIR}/Makefile
+	${_MKTARGET_CREATE}
+	printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET}
+
+.PATH: ${DIST}/gcc ${DIST}/gcc/cp ${DIST}/gcc/cp/inc ${DIST}/gcc/config \
+	${G_CONFIGDIR}
+
+tconfig.h:
+	${_MKTARGET_CREATE}
+	TM_DEFINES="$(G_tm_defines)" \
+	HEADERS="$(G_xm_file)" XM_DEFINES="$(G_xm_defines)" \
+	TARGET_CPU_DEFAULT="" \
+	${HOST_SH} $(GNUHOSTDIST)/gcc/mkconfig.sh tconfig.h
Index: gnu/lib/libgcc3/libgcc/Makefile
===================================================================
RCS file: gnu/lib/libgcc3/libgcc/Makefile
diff -N gnu/lib/libgcc3/libgcc/Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/lib/libgcc3/libgcc/Makefile	12 Feb 2004 22:05:15 -0000
@@ -0,0 +1,39 @@
+#	$NetBSD$
+
+REQUIRETOOLS=	yes
+NOLINT=		# defined
+
+LIB=		gcc
+
+.include <bsd.own.mk>
+
+.if ${MKGCC} != "no"
+
+.if exists(${.CURDIR}/../arch/${MACHINE_ARCH}.mk)
+.include "${.CURDIR}/../arch/${MACHINE_ARCH}.mk"
+.endif
+
+.cc: # disable .cc->NULL transform
+
+SRCS+=         ${LIB2FUNCS} ${LIB2DIVMOD} \
+               ${G_LIB2ADD:T:S/.asm/.S/} ${LIB1ASMFUNCS}
+.if ${MKPIC} == "no"
+SRCS+=         ${LIB2_EH}
+.endif
+
+.include <bsd.lib.mk>
+
+.c.so:
+	${_MKTARGET_COMPILE}
+	${COMPILE.c} ${CSHLIBFLAGS} ${.IMPSRC} -o ${.TARGET}.tmp
+	${NM} -pg ${.TARGET}.tmp | ${AWK} 'NF == 3 { print "\t.hidden", $$3 }' | ${CC} -Wl,-x -r -nostdinc -nostdlib -o ${.TARGET} ${.TARGET}.tmp -xassembler -
+	rm -f ${.TARGET}.tmp
+
+.S.so .s.so:
+	${COMPILE.S} ${CAPICFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.tmp
+	${NM} -pg ${.TARGET}.tmp | ${AWK} 'NF == 3 { print "\t.hidden", $$3 }' | ${CC} -Wl,-x -r -nostdinc -nostdlib -o ${.TARGET} ${.TARGET}.tmp -xassembler -
+	rm -f ${.TARGET}.tmp
+
+.else
+.include <bsd.prog.mk> # do nothing
+.endif
Index: gnu/lib/libgcc3/libgcc_eh/Makefile
===================================================================
RCS file: gnu/lib/libgcc3/libgcc_eh/Makefile
diff -N gnu/lib/libgcc3/libgcc_eh/Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/lib/libgcc3/libgcc_eh/Makefile	12 Feb 2004 22:05:15 -0000
@@ -0,0 +1,23 @@
+#	$NetBSD$
+
+REQUIRETOOLS=	yes
+NOLINT=		# defined
+
+LIB=		gcc_eh
+
+.include <bsd.own.mk>
+
+.if ${MKGCC} != "no"
+.if exists(${.CURDIR}/../arch/${MACHINE_ARCH}.mk)
+.include "${.CURDIR}/../arch/${MACHINE_ARCH}.mk"
+.endif
+
+.cc: # disable .cc->NULL transform
+
+SRCS+=         ${LIB2_EH}
+
+.include <bsd.lib.mk>
+
+.else
+.include <bsd.prog.mk> # do nothing
+.endif
Index: gnu/lib/libgcc3/libgcc_s/Makefile
===================================================================
RCS file: gnu/lib/libgcc3/libgcc_s/Makefile
diff -N gnu/lib/libgcc3/libgcc_s/Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/lib/libgcc3/libgcc_s/Makefile	12 Feb 2004 22:05:15 -0000
@@ -0,0 +1,33 @@
+#	$NetBSD$
+
+REQUIRETOOLS=	yes
+NOLINT=		# defined
+
+LIB=		gcc_s
+NOSTATICLIB=	# defined
+NOPROFILE=	# defined
+NOPICINSTALL=	# defined
+
+.include <bsd.own.mk>
+
+.if ${MKGCC} != "no"
+.if exists(${.CURDIR}/../arch/${MACHINE_ARCH}.mk)
+.include "${.CURDIR}/../arch/${MACHINE_ARCH}.mk"
+.endif
+
+.cc: # disable .cc->NULL transform
+
+SHLIB_MAJOR=    1
+SHLIB_MINOR=    0
+
+LDFLAGS+=	-nostdlib
+#LDFLAGS+=	-Wl,--version-script=${DIST}/libgcc/libgcc.map
+
+SRCS+=		${LIB2FUNCS} ${LIB2DIVMOD} ${LIB2_EH} \
+		${G_LIB2ADD:T:S/.asm/.S/} ${LIB1ASMFUNCS}
+
+.include <bsd.lib.mk>
+
+.else
+.include <bsd.prog.mk> # do nothing
+.endif
Index: gnu/lib/libobjc3/Makefile
===================================================================
RCS file: /cvsroot/src/gnu/lib/libobjc3/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- gnu/lib/libobjc3/Makefile	21 Oct 2003 10:01:20 -0000	1.9
+++ gnu/lib/libobjc3/Makefile	12 Feb 2004 22:05:15 -0000
@@ -15,7 +15,7 @@
 # Machine-independent definitions (include file names).
 .include "${.CURDIR}/defs.mk"
 
-LIBGCCOBJ!=    cd ${.CURDIR}/../libgcc3 && ${PRINTOBJDIR}
+LIBGCCOBJ!=    cd ${.CURDIR}/../libgcc3/libgcc && ${PRINTOBJDIR}
 
 DIST=		${NETBSDSRCDIR}/gnu/dist/gcc
 GNUHOSTDIST=	${NETBSDSRCDIR}/gnu/dist/gcc
Index: gnu/usr.bin/gcc3/Makefile.inc
===================================================================
RCS file: /cvsroot/src/gnu/usr.bin/gcc3/Makefile.inc,v
retrieving revision 1.2
diff -u -r1.2 Makefile.inc
--- gnu/usr.bin/gcc3/Makefile.inc	25 Jul 2003 17:19:22 -0000	1.2
+++ gnu/usr.bin/gcc3/Makefile.inc	12 Feb 2004 22:05:15 -0000
@@ -27,3 +27,11 @@
 HOSTLIBIBERTY=		${HOSTLIBIBERTYOBJ}/libiberty/libiberty.a
 
 .include "${GCCARCH}/defs.mk"
+
+.if ${G_ENABLE_SHARED} == "yes" && ${G_SHLIB_LINK} != ""
+CPPFLAGS+=	-DENABLE_SHARED_LIBGCC
+.endif
+
+.if ${G_SHLIB_MULTILIB} != ""
+CPPFLAGS+=	-DNO_SHARED_LIBGCC_MULTILIB
+.endif
Index: gnu/usr.bin/groff/Makefile.inc
===================================================================
RCS file: /cvsroot/src/gnu/usr.bin/groff/Makefile.inc,v
retrieving revision 1.12
diff -u -r1.12 Makefile.inc
--- gnu/usr.bin/groff/Makefile.inc	27 Jan 2004 01:00:09 -0000	1.12
+++ gnu/usr.bin/groff/Makefile.inc	12 Feb 2004 22:05:15 -0000
@@ -95,9 +95,9 @@
 CXXFLAGS+=	-fno-rtti -fno-exceptions
 
 # If we're using GCC3, we only need -lsupc++
-.if ${HAVE_GCC3} == "yes"
-USE_LIBSTDCXX=	no
-.endif
+#.if ${HAVE_GCC3} == "yes"
+#USE_LIBSTDCXX=	no
+#.endif
 
 
 .ifdef GROFFYSRCS
Index: share/mk/bsd.lib.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
retrieving revision 1.248
diff -u -r1.248 bsd.lib.mk
--- share/mk/bsd.lib.mk	9 Feb 2004 06:35:18 -0000	1.248
+++ share/mk/bsd.lib.mk	12 Feb 2004 22:05:16 -0000
@@ -133,9 +133,6 @@
 CPPPICFLAGS?= -DPIC
 CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
 APICFLAGS?= -k
-# XXX libraries often need the millicode functions in libgcc.a,
-# so we have to work around the -nostdlib:
-LDADD+= -L${_GCC_LIBGCCDIR} -lgcc_pic
 
 .elif ${MACHINE_ARCH} == "ns32k"
 
Index: share/mk/bsd.prog.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v
retrieving revision 1.197
diff -u -r1.197 bsd.prog.mk
--- share/mk/bsd.prog.mk	29 Jan 2004 01:48:45 -0000	1.197
+++ share/mk/bsd.prog.mk	12 Feb 2004 22:05:16 -0000
@@ -174,7 +174,11 @@
 .if !commands(${PROG})
 	${_MKTARGET_LINK}
 .if defined(DESTDIR)
-	${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
+	${_CCLINK} -Wl,-nostdlib \
+	    ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} \
+	    -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/  \
+	    ${OBJS} ${LDADD} \
+	    -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib
 .else
 	${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
 .endif	# defined(DESTDIR)
Index: tools/Makefile.gnuhost
===================================================================
RCS file: /cvsroot/src/tools/Makefile.gnuhost,v
retrieving revision 1.24
diff -u -r1.24 Makefile.gnuhost
--- tools/Makefile.gnuhost	26 Oct 2003 07:25:38 -0000	1.24
+++ tools/Makefile.gnuhost	12 Feb 2004 22:05:16 -0000
@@ -55,7 +55,7 @@
 		PATH="${TOOLDIR}/bin:$$PATH" \
 		YACC=${YACC:Q}
 
-CONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
+CONFIGURE_ARGS+=--prefix=${TOOLDIR}
 
 .ifndef _NOWRAPPER
 # Some systems have a small ARG_MAX.  On such systems, prevent Make
Index: tools/gcc/Makefile
===================================================================
RCS file: /cvsroot/src/tools/gcc/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- tools/gcc/Makefile	10 Feb 2004 09:37:58 -0000	1.12
+++ tools/gcc/Makefile	12 Feb 2004 22:05:16 -0000
@@ -13,7 +13,7 @@
 
 MAKE_ARGS=	MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q} \
 		LIBGCC= LIBGCC1= LIBGCC1_TEST= LIBGCC2= INSTALL_LIBGCC= \
-		EXTRA_PARTS=
+		EXTRA_PARTS= CPPFLAGS=-DNETBSD_TOOLS
 
 ALL_TARGET=	all-gcc
 INSTALL_TARGET=	install-gcc

--Boundary-00=_gm/KA7lakwYOtyf--