Subject: lib/3679: bsd.lib.mk doesn't generate shared libraries
To: None <gnats-bugs@gnats.netbsd.org>
From: Ted Lemon <mellon@ab.home.vix.com>
List: netbsd-bugs
Date: 05/28/1997 17:38:58
>Number:         3679
>Category:       lib
>Synopsis:       bsd.lib.mk doesn't generate shared libraries
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 28 17:50:02 1997
>Last-Modified:
>Originator:     Ted Lemon
>Organization:
Ted Lemon							 mellon@vix.com
+1 415 567 7999
>Release:        May 28, 1997
>Environment:
System: NetBSD ab.home.vix.com 1.2E NetBSD 1.2E (AB) #1: Tue May 27 18:14:41 PDT 1997 mellon@ab.home.vix.com:/usr/src/sys/arch/alpha/compile/AB alpha


>Description:
	On the Alpha, after running make in lib/libc, there is no shared
	library in the obj.alpha directory.
>How-To-Repeat:
	Try to build a shared libc on the alpha.
>Fix:
	I am not sure if this is correct for all platforms, but certainly
	on the alpha, and probably on the pmax, there is no -nostdlib
	flag to ld.   It doesn't make sense for there to be one, since
	ld takes a -n flag and a -o flag (you can see where this is leading,
	can't you?) and in any case doesn't know about any standard libraries.
	-nostdlib is a cc flag.

	Anyway, when -nostdlib is passed to ld, it thinks you mean -n, and
	then -o stdlib, and this overrides the previous -o <shared library>.
	The result is that instead of libc.so.1.12, you get stdlib.

	I believe the following patch is correct, and will apply it if
	asked:


Index: bsd.lib.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
retrieving revision 1.112
diff -c -2 -r1.112 bsd.lib.mk
*** bsd.lib.mk	1997/05/28 11:16:19	1.112
--- bsd.lib.mk	1997/05/29 00:34:29
***************
*** 218,226 ****
  .if (${SHLIB_TYPE} == "a.out")
  	$(LD) -x -Bshareable -Bforcearchive \
! 	    -o ${.TARGET} lib${LIB}_pic.a -nostdlib -L${BUILDDIR}/usr/lib ${LDADD}
  .elif (${SHLIB_TYPE} == "ELF")
  	$(LD) -x -shared -o ${.TARGET} \
  	    -soname lib${LIB}.so.${SHLIB_SOVERSION}  ${SHLIB_LDSTARTFILE} \
! 	    --whole-archive lib${LIB}_pic.a --no-whole-archive -nostdlib \
  	    -L${BUILDDIR}/usr/lib ${LDADD} ${SHLIB_LDENDFILE}
  .endif
--- 218,226 ----
  .if (${SHLIB_TYPE} == "a.out")
  	$(LD) -x -Bshareable -Bforcearchive \
! 	    -o ${.TARGET} lib${LIB}_pic.a -L${BUILDDIR}/usr/lib ${LDADD}
  .elif (${SHLIB_TYPE} == "ELF")
  	$(LD) -x -shared -o ${.TARGET} \
  	    -soname lib${LIB}.so.${SHLIB_SOVERSION}  ${SHLIB_LDSTARTFILE} \
! 	    --whole-archive lib${LIB}_pic.a --no-whole-archive \
  	    -L${BUILDDIR}/usr/lib ${LDADD} ${SHLIB_LDENDFILE}
  .endif
>Audit-Trail:
>Unformatted: