Subject: pkg/12154: lang/gcc does not make shared libstdc++
To: None <gnats-bugs@gnats.netbsd.org>
From: Olaf Seibert <rhialto@polderland.nl>
List: netbsd-bugs
Date: 02/08/2001 05:35:23
>Number:         12154
>Category:       pkg
>Synopsis:       lang/gcc does not make shared libstdc++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 08 05:38:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Olaf Seibert
>Release:        NetBSD/i386 1.4.2 with current pkgsrc
>Organization:
	
>Environment:
System: NetBSD klei.intern.polderland.nl 1.4.2 NetBSD 1.4.2 (KIELDRECHT) #11: Wed Jul 19 14:00:31 CEST 2000 root@kieldrecht:/usr/src/sys/arch/i386/compile/KIELDRECHT i386


>Description:
	cd pkgsrc/lang/gcc &&
	make install &&
	ls /usr/pkg/gcc-2.95.2/lib/libstdc++*

	and notice libstdc++.so.2.10 is missing.
>How-To-Repeat:
	see above.
>Fix:
	I used something like the patch below. This also includes my
	patch for pr pkg/12153. I don't know if other architectures than
	i386/a.out suffer from this but this is easily changed.

	There is a target in the Makefile in
	${WRKDIR}/objdir/${MACHINE_GCC_PLATFORM}/libstdc++ for making
	libstdc++.so.2.10.0 (note extra .0) but that seems to call gcc
	in an incorrect manner that produces lots of warnings like

	ld: /usr/tmp/lang/gcc/work/objdir/gcc/libgcc.a(new.o): RRS text
	relocation at 0x2b2fa for "___get_eh_context"

	so I chose not to use it. Adding the option -nostdlib avoided
	this, but the result still had a slightly different size.

Index: Makefile
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/lang/gcc/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- Makefile	2001/01/29 11:34:29	1.12
+++ Makefile	2001/02/08 13:35:50
@@ -22,10 +22,19 @@
 MACHINE_GCC_PLATFORM=	${MACHINE_GNU_PLATFORM}
 .endif
 
+.if (${MACHINE_ARCH} == "i386") && (${OBJECT_FMT} == "a.out")
+# For some architectures, the gcc build process does not make
+# a shared libstdc++. Arrange to build it separately.
+LIBSTDCXX_SO=		libstdc++.so.2.10
+.endif
+
 USE_GMAKE=		YES
 HAS_CONFIGURE=		YES
 CONFIGURE_ARGS=		--host=${MACHINE_GCC_PLATFORM} \
 			--prefix=${GCC_PREFIX}
+.ifdef LIBSTDCXX_SO
+CONFIGURE_ARGS+=	--enable-shared
+.endif
 CONFIGURE_SCRIPT=	${SRCDIR}/configure
 
 GCC_VERSION=		${PKGNAME:C/.*-//}
@@ -57,19 +66,27 @@
 
 .if (${OPSYS} != SunOS)
 post-build:
-	for FILE in ${FILESDIR}/gcc.mk do \
+	for FILE in ${FILESDIR}/gcc.mk; do \
 	  ${SED} -e 's#@@MAKE@@#${MAKE}#g' \
 		 -e 's#@@PKGNAME@@#${PKGNAME}#g' \
 		 -e 's#@@PREFIX@@#${PREFIX}#g' \
 	   <$$FILE >${WRKDIR}/`basename $$FILE`; \
 	done
+.ifdef LIBSTDCXX_SO
+	cd ${WRKDIR}/objdir/${MACHINE_GCC_PLATFORM}/libstdc++ && \
+	${MAKE} piclist && \
+	${LD} -Bshareable -o ${LIBSTDCXX_SO} `cat piclist`
 .endif
+.endif
 
 .if (${OPSYS} != SunOS)
 post-install:
 	${LN} -s gcc ${PREFIX}/${PKGNAME}/bin/cc
 	${RM} -f ${GCC_PREFIX}/lib/gcc-lib/${MACHINE_GCC_PLATFORM}/${GCC_VERSION}/include/curses.h
 	${INSTALL_DATA} ${WRKDIR}/gcc.mk ${PREFIX}/etc/${PKGNAME}.mk
+.ifdef LIBSTDCXX_SO
+	${INSTALL_DATA} ${WRKDIR}/objdir/${MACHINE_GCC_PLATFORM}/libstdc++/${LIBSTDCXX_SO} ${PREFIX}/${PKGNAME}/lib
+.endif
 .endif
 
 .include "../../mk/bsd.pkg.mk"


Index: pkg/PLIST
===================================================================
RCS file: /pub/NetBSD-CVS/pkgsrc/lang/gcc/pkg/PLIST,v
retrieving revision 1.3
diff -u -r1.3 PLIST
--- PLIST	2000/09/15 23:58:49	1.3
+++ PLIST	2001/02/08 13:35:51
@@ -288,6 +288,7 @@
 ${PKGNAME}/lib/gcc-lib/${MACHINE_GCC_PLATFORM}/${GCC_VERSION}/include/README
 ${PKGNAME}/lib/libiberty.a
 ${PKGNAME}/lib/libstdc++.a.2.10.0
+${PKGNAME}/lib/libstdc++.so.2.10
 ${PKGNAME}/man/man1/g++.1
 ${PKGNAME}/man/man1/g77.1
 ${PKGNAME}/man/man1/gcc.1
>Release-Note:
>Audit-Trail:
>Unformatted: