From owner-freebsd-stable@FreeBSD.ORG Fri Jan 26 17:15:53 2007 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 615A416A400 for ; Fri, 26 Jan 2007 17:15:53 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 1CC3E13C4A8 for ; Fri, 26 Jan 2007 17:15:52 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.6/8.13.8) id l0QHFqN9004651; Fri, 26 Jan 2007 11:15:52 -0600 (CST) (envelope-from dan) Date: Fri, 26 Jan 2007 11:15:52 -0600 From: Dan Nelson To: Bill Vermillion Message-ID: <20070126171552.GA24490@dan.emsphone.com> References: <20070126161022.GB29530@wjv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070126161022.GB29530@wjv.com> X-OS: FreeBSD 6.2-STABLE User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-stable@freebsd.org Subject: Re: 6.2 buildworld fails with NO_SHARED X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jan 2007 17:15:53 -0000 In the last episode (Jan 26), Bill Vermillion said: > I had wanted to build static binaries in /bin and /sbin - so > I set NO_SHARED. The man pages says "... this can be bad. If set > every utility that uses bsd.prog.mk will be linked statically." > > Here is the tail end of the output of make buildworld as I mailed > it to me from the machine I was bringing up as we start to replace > all the 4.11 servers. > > > ===> usr.sbin/gstat (all) > > cc -O2 -fno-strict-aliasing -pipe -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -c /usr/src/usr.sbin/gstat/gstat.c > > cc -O2 -fno-strict-aliasing -pipe -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -static -o gstat gstat.o -lgeom -ldevstat -lbsdxml -lcurses -ledit > > /usr/obj/usr/src/tmp/usr/lib/libgeom.a(geom_xml2tree.o)(.text+0x1c): In function `StartElement': > > : undefined reference to `sbuf_new' > > /usr/obj/usr/src/tmp/usr/lib/libdevstat.a(devstat.o)(.text+0x1538): In function `readkmem': > > : undefined reference to `kvm_read' > > /usr/obj/usr/src/tmp/usr/lib/libedit.a(editline.o)(.text+0x3938): In function `term_deletechars': > > : undefined reference to `tgoto' Looks like there are some missing/misordered library dependencies. Moving -lcurses after -ledit, and adding -lkvm and -lsbuf fixes it. The main thing you lose by statically linking is dlopen(), so nsswitch and pam modules from ports won't work. Modules built into libc.a or libpam.a (NIS and pam_unix for example) will work. Also, if you're on -current you can tell cached to do NSS lookups on behalf of static binaries. Index: Makefile =================================================================== RCS file: /home/ncvs/src/usr.sbin/gstat/Makefile,v retrieving revision 1.6.2.1 diff -u -r1.6.2.1 Makefile --- Makefile 10 Jun 2006 15:40:10 -0000 1.6.2.1 +++ Makefile 26 Jan 2007 17:00:38 -0000 @@ -3,7 +3,7 @@ PROG= gstat MAN= gstat.8 WARNS?= 5 -DPADD= ${LIBGEOM} ${LIBDEVSTAT} ${LIBBSDXML} ${LIBCURSES} ${LIBEDIT} -LDADD= -lgeom -ldevstat -lbsdxml -lcurses -ledit +DPADD= ${LIBGEOM} ${LIBDEVSTAT} ${LIBBSDXML} ${LIBEDIT} ${LIBCURSES} +LDADD= -lgeom -ldevstat -lbsdxml -ledit -lcurses -lkvm -lsbuf .include -- Dan Nelson dnelson@allantgroup.com