Subject: lib/7283: shared library builds use old dependent libraries when DESTDIR set
To: None <gnats-bugs@gnats.netbsd.org>
From: Erik E. Fair <fair@digital.clock.org>
List: netbsd-bugs
Date: 03/29/1999 12:05:04
>Number:         7283
>Category:       lib
>Synopsis:       shared library builds use old dependent libraries when DESTDIR set
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 29 12:20:01 1999
>Last-Modified:
>Originator:     Erik E. Fair
>Organization:
International Organization of Internet Clock Watchers
>Release:        NetBSD-current 19990329
>Environment:
	
System: NetBSD digital.clock.org 1.3 NetBSD 1.3 (DIGITAL) #1: Mon May 25 14:16:49 PDT 1998 fair@digital.clock.org:/usr/src/sys/arch/sparc/compile/DIGITAL sparc


>Description:
	When building the system, shared libraries which depend on
	other libraries still search /usr/lib when DESTDIR is set;
	this causes the new library to be dependent on an old
	installed shared library, instead of one just built and
	installed in ${DESTDIR}${LIBDIR}

>How-To-Repeat:
	Install a snapshot from outside the USA (i.e. without "domestic").

	Attempt to build the whole system (including "domestic")
	with DESTDIR set to /altroot.

	Discover that since you don't have the domestic libraries
	already installed in /usr/lib (!!), shared libkrb won't
	load because it can't find libcom_err.

>Fix:

	Please double check this patch. I don't feel sufficiently
	versed in the complete vagaries of the build/make system
	to apply it myself (i.e. I don't wanna get flamed into
	the ground if it's the wrong thing for some case I'm
	unfamiliar with even though this worked for me for the
	specific case I found). In particular, will this have any
	deleterious effects on libraries for packages?


*** src/share/mk/bsd.lib.mk.orig	Mon Mar 29 11:30:36 1999
--- src/share/mk/bsd.lib.mk	Mon Mar 29 11:41:00 1999
***************
*** 242,251 ****
--- 242,260 ----
      ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
  	@echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
  	@rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
+ .if defined(DESTDIR)
+ 	$(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
+ 	    ${SHLIB_LDSTARTFILE} \
+ 	    --whole-archive lib${LIB}_pic.a \
+ 	    -nostdlib -L${DESTDIR}${LIBDIR} -R${LIBDIR} \
+ 	    --no-whole-archive ${LDADD} \
+ 	    ${SHLIB_LDENDFILE}
+ .else
  	$(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
  	    ${SHLIB_LDSTARTFILE} \
  	    --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
  	    ${SHLIB_LDENDFILE}
+ .endif
  .if ${OBJECT_FMT} == "ELF"
  	rm -f lib${LIB}.so.${SHLIB_MAJOR}
  	ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \

>Audit-Trail:
>Unformatted: