Subject: misc/12002: DESTDIR build uses old shared libraries
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jbernard@mines.edu>
List: netbsd-bugs
Date: 01/19/2001 07:20:18
>Number:         12002
>Category:       misc
>Synopsis:       DESTDIR build uses old shared libraries
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 19 07:23:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jim Bernard
>Release:        January 17, 2001
>Organization:
	Speaking for myself
>Environment:
System: NetBSD nool 1.5Q NetBSD 1.5Q (NOOL-$Revision: 1.16 $) #0: Wed Jan 17 15:03:26 MST 2001 jbernard@nool:/home/tmp/compile/sys/arch/i386/compile/NOOL i386
Architecture: i386
Machine: i386
>Description:
	If DESTDIR is not set, after the libraries are built and installed,
	programs used to accomplish the remainder of the build will be
	loaded with the new shared libraries.  But if DESTDIR is set, the
	old libraries in /usr/lib are still used.  This is usually not much
	of a problem, but sometimes the new libraries are needed (e.g.,
	recently mklocale was added with accompanying new functions in libc,
	and would fail to load with 'Undefined symbol "_CurrentRuneLocale"'
	if the old libc was used).  More importantly, it seems generally
	appropriate to have DESTDIR builds match non-DESTDIR builds as
	closely as possible, as well as to utilize improvements in shared
	libraries during builds when possible.

>How-To-Repeat:
	Build and install libraries in DESTDIR, then do
	  "ldd any_dynamically_linked_binary"
	and note that it (not surprisingly) references libraries
	in /usr/lib.
>Fix:
	This just changes the top-level Makefile to set LD_LIBRARY_PATH to
	DESTDIR/usr/lib for the remainder of the build after the libraries
	have been installed.  I tested it on a build in which
	/usr/bin/mklocale (which I had built by hand) would not load with
	/usr/lib/libc.so (an old library), and it worked quite nicely,
	with no need to install the new libc in /usr/lib first.

--- Makefile-dist	Thu Nov 16 08:31:58 2000
+++ Makefile	Thu Jan 18 08:35:31 2001
@@ -156,11 +156,16 @@
 	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
 	    ${MAKE} ${_M} MKSHARE=no install)
 	(cd ${.CURDIR}/gnu/lib && \
 	    ${MAKE} ${_M} ${_J} MKSHARE=no dependall && \
 	    ${MAKE} ${_M} MKSHARE=no install)
+.if defined(DESTDIR)
+	LD_LIBRARY_PATH=${DESTDIR}/usr/lib ${MAKE} ${_M} ${_J} dependall && \
+	    LD_LIBRARY_PATH=${DESTDIR}/usr/lib ${MAKE} ${_M} _BUILD= install
+.else
 	${MAKE} ${_M} ${_J} dependall && ${MAKE} ${_M} _BUILD= install
+.endif
 .if defined(DOMESTIC) && !defined(EXPORTABLE_SYSTEM)
 	(cd ${.CURDIR}/${DOMESTIC} && ${MAKE} ${_M} ${_J} _SLAVE_BUILD= build)
 .endif
 	${MAKE} ${_M} whatis.db
 	@echo -n "Build finished at: "
	
>Release-Note:
>Audit-Trail:
>Unformatted: