ABI and install tools (was Re: cvs commit: src/lib/libc/gen fts-compat.c fts-compat.h)

Yar Tikhiy yar at comp.chem.msu.su
Mon Aug 27 19:13:05 PDT 2007


[Redirecting this branch to -arch]

On Mon, Aug 27, 2007 at 05:56:54PM -0700, David O'Brien wrote:
> On Fri, Aug 24, 2007 at 09:36:15PM -0600, M. Warner Losh wrote:
> > In message: <Pine.GSO.4.64.0708242252520.15344 at sea.ntplx.net>
> >             Daniel Eischen <deischen at freebsd.org> writes:
> > : I guess the build system should be more tolerant of this, but
> > : there are bound to be problems regardless.  I don't see why
> > : the install tools can't also either have their own set of
> > : libraries (utilizing LD_LIBRARY_PATH) or be built static.
> > 
> > There's much resistance to building everything that the build system
> > might be used being build static.  It adds too much time and
> > complexity to the build system, the opponents say.
> 
> I've never heard an argument against building these bits static.
> What's the issue?

FWIW, here's a patch implementing the opposite approach: If we're
going to install world over this system (installworld with DESTDIR
unset or empty), first install the new versions of necessary tools
to a scratch directory and then switch to the new tools.  The kernel
must be capable of running the new tools with the new libraries,
which is an already existing requirement.

With the patch, the build system can tolerate ABI breakage in libc
and, according to audit(4), it runs no binaries from the old system
in the sensitive part of installworld.

For easier and safer testing, INSTALL_TESTING can be set so that
the new way is chosen even if DESTDIR is set.  Of course, make sure
that the new tools are for the same platform as the machine runs.
Usually you cannot select a different platform w/o setting DESTDIR.

Comments are welcome.  Thanks!

-- 
Yar

Index: Makefile.inc1
===================================================================
RCS file: /home/ncvs/src/Makefile.inc1,v
retrieving revision 1.584
diff -u -r1.584 Makefile.inc1
--- Makefile.inc1	10 Jul 2007 10:19:45 -0000	1.584
+++ Makefile.inc1	28 Aug 2007 01:15:28 -0000
@@ -159,7 +159,14 @@
 STRICTTMPPATH=	${BPATH}:${XPATH}
 TMPPATH=	${STRICTTMPPATH}:${PATH}
 
+#
+# Avoid running mktemp(1) unless actually needed.
+# It may not be functional, e.g., due to new ABI
+# when in the middle of installing over this system.
+#
+.if make(installworld) || make(distributeworld)
 INSTALLTMP!=	/usr/bin/mktemp -d -u -t install
+.endif
 
 #
 # Building a world goes through the following stages
@@ -265,12 +272,11 @@
 .endif
 
 # install stage
+IMAKEENV=	${CROSSENV} ${INSTALLENV}
 .if empty(.MAKEFLAGS:M-n)
-IMAKEENV=	${CROSSENV} \
-		PATH=${STRICTTMPPATH}:${INSTALLTMP}
+IMAKEENV+=	PATH=${STRICTTMPPATH}:${INSTALLTMPPATH}
 .else
-IMAKEENV=	${CROSSENV} \
-		PATH=${TMPPATH}:${INSTALLTMP}
+IMAKEENV+=	PATH=${TMPPATH}:${INSTALLTMPPATH}
 .endif
 IMAKE=		${IMAKEENV} ${MAKE} -f Makefile.inc1
 
@@ -567,6 +573,50 @@
 .endfor
 
 #
+# If installing over this system, use the newly built tools
+# to avoid such complications as the requirement of ABI compatibility
+# between the old tools and the new libraries.
+#
+.if make(installworld) && (empty(DESTDIR) || defined(INSTALL_TESTING))
+INSTALLPATH=	/sbin:/bin:/usr/sbin:/usr/bin
+INSTALLTMPPATH=	${INSTALLPATH:S/^/${INSTALLTMP}/:S/:/:${INSTALLTMP}/g}
+
+INSTALLENV=	LD_LIBRARY_PATH=${WORLDTMP}/lib:${WORLDTMP}/usr/lib
+INSTALLENV+=	__MAKE_SHELL=${INSTALLTMP}/bin/sh
+
+INSTALLTOOLS=	\
+	bin/cat \
+	bin/chflags \
+	bin/chmod \
+	bin/date \
+	bin/echo \
+	bin/ln \
+	bin/mkdir \
+	bin/mv \
+	bin/rm \
+	bin/sh \
+	bin/test \
+	gnu/usr.bin/grep \
+	gnu/usr.bin/texinfo/install-info \
+	sbin/sysctl \
+	usr.bin/awk \
+	usr.bin/cap_mkdb \
+	usr.bin/find \
+	usr.bin/lockf \
+	usr.bin/make \
+	usr.bin/sed \
+	usr.bin/true \
+	usr.bin/uname \
+	usr.bin/wc \
+	usr.sbin/chown \
+	usr.sbin/mtree \
+	usr.sbin/pwd_mkdb \
+	usr.sbin/zic/zic
+.else
+INSTALLTMPPATH=${INSTALLTMP}
+.endif
+
+#
 # distributeworld
 #
 # Distributes everything compiled by a `buildworld'.
@@ -576,6 +626,15 @@
 # Installs everything compiled by a 'buildworld'.
 #
 distributeworld installworld: installcheck
+.if make(installworld) && (empty(DESTDIR) || defined(INSTALL_TESTING))
+	mkdir -p ${INSTALLTMPPATH:S/:/ /g}
+.for _tool in ${INSTALLTOOLS}
+	cd ${.CURDIR}/${_tool}; \
+	    ${MAKE} -DWITHOUT_INFO -DWITHOUT_MAN \
+		DESTDIR=${INSTALLTMP} INSTALL="sh ${.CURDIR}/tools/install.sh" \
+		install
+.endfor
+.else
 	mkdir -p ${INSTALLTMP}
 	for prog in [ awk cap_mkdb cat chflags chmod chown \
 	    date echo egrep find grep install-info \
@@ -583,6 +642,7 @@
 	    test true uname wc zic; do \
 		cp `which $$prog` ${INSTALLTMP}; \
 	done
+.endif
 	${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
 	rm -rf ${INSTALLTMP}
 
Index: share/mk/sys.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/sys.mk,v
retrieving revision 1.92
diff -u -r1.92 sys.mk
--- share/mk/sys.mk	14 Aug 2007 13:44:08 -0000	1.92
+++ share/mk/sys.mk	27 Aug 2007 16:29:08 -0000
@@ -256,6 +256,11 @@
 .include "${__MAKE_CONF}"
 .endif
 
+.if !empty(__MAKE_SHELL)
+SHELL=	${__MAKE_SHELL}
+.SHELL: path=${__MAKE_SHELL}
+.endif
+
 # Default executable format
 # XXX hint for bsd.port.mk
 OBJFORMAT?=	elf


More information about the freebsd-arch mailing list