From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 19 16:10:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 492561065675; Fri, 19 Dec 2008 16:10:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 276688FC18; Fri, 19 Dec 2008 16:10:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mBJGA1mT024244; Fri, 19 Dec 2008 16:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mBJGA1Aa024243; Fri, 19 Dec 2008 16:10:01 GMT (envelope-from gnats) Resent-Date: Fri, 19 Dec 2008 16:10:01 GMT Resent-Message-Id: <200812191610.mBJGA1Aa024243@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@freebsd.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Cc: luigi@freebsd.org Resent-Reply-To: FreeBSD-gnats-submit@freebsd.org, Eygene Ryabinkin Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 247C71065674 for ; Fri, 19 Dec 2008 16:02:52 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id D053E8FC08 for ; Fri, 19 Dec 2008 16:02:51 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from shadow.codelabs.ru (shadow.codelabs.ru [144.206.177.8]) by 0.mx.codelabs.ru with esmtps (TLSv1:CAMELLIA256-SHA:256) id 1LDhoQ-000ACc-La for FreeBSD-gnats-submit@freebsd.org; Fri, 19 Dec 2008 19:02:50 +0300 Received: by shadow.codelabs.ru (Postfix, from userid 1001) id 7294917119; Fri, 19 Dec 2008 19:02:50 +0300 (MSK) Message-Id: <20081219160250.7294917119@shadow.codelabs.ru> Date: Fri, 19 Dec 2008 19:02:50 +0300 (MSK) From: Eygene Ryabinkin To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: luigi@freebsd.org Cc: Subject: bin/129764: [patch] unbreak sbin/newfs build for the 8-CURRENT X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eygene Ryabinkin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2008 16:10:01 -0000 >Number: 129764 >Category: bin >Synopsis: [patch] unbreak sbin/newfs build for the 8-CURRENT >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Dec 19 16:10:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Eygene Ryabinkin >Release: FreeBSD 8.0-CURRENT-200812 amd64 >Organization: Code Labs >Environment: System: FreeBSD 8.0-CURRENT-200812 amd64 >Description: After the src/sbin/newfs/newfs.c version 1.87 (SVN rev 185588) builds with NO_DYNAMICROOT (strictly speaking, with NO_SHARED) are broken: ld(1) cries that the symbol bwrite is defined multiple times. >How-To-Repeat: Set NO_DYNAMICROOT, go to /usr/src/sbin/newfs, issue 'make clean && make' and watch for the error messages. >Fix: The following patch fixes the things, although it is a pure hack. May be there is a better way to do it -- I don't currently know. --- Makefile.diff begins here --- --- Makefile.orig 2008-12-19 21:09:35.000000000 +0300 +++ Makefile 2008-12-19 21:47:36.000000000 +0300 @@ -13,6 +13,27 @@ .include +# XXX: pure hack. +# +# We overriding bwrite from libufs, so for the static linkage +# we should tell ld(1) to inhibit error saying about multiple +# definitions of a symbol. +# +# Also, we should include -lufs prior to the newfs objects, +# because ld(1) takes the last encountered symbol. So we're +# modifying OBJS and LDADD for this. We _do_ depend on the +# current order of flags in bsd.prog.mk: LDFLAGS, OBJS and LDADD. +# +# XXX: should be done after bsd.prog.mk -- NO_SHARED and OBJS +# XXX: are defined there. + +.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") +LDFLAGS+= -Xlinker -z -Xlinker muldefs +OBJS_EXP= ${OBJS:Nnewfs.o} +OBJS:= ${OBJS_EXP} +LDADD+= newfs.o +.endif + test: ${PROG} sh ${.CURDIR}/runtest01.sh sh ${.CURDIR}/runtest00.sh | tee _.test --- Makefile.diff ends here --- OBJS manipulations are needed because ld(1) takes the last symbol. Man page near the description of '-z muldefs' says about the first one, but the below transcript shows that this is incorrect (0x23 is 35 in decimal): ----- # make [...] cc -O2 -pipe -march=nocona -fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -static -Xlinker -z -Xlinker muldefs -o newfs mkfs.o geom_bsd_enc.o -lufs newfs.o /usr/bin/ld: Warning: size of symbol `bwrite' changed from 377 in /usr/lib/libufs.a(block.o) to 35 in newfs.o gzip -cn /usr/src/sbin/newfs/newfs.8 > newfs.8.gz # nm --print-size /usr/obj/usr/src/sbin/newfs/newfs | grep bwrite 00000000004039d0 0000000000000023 T bwrite 0000000000403710 000000000000010a T sbwrite ----- >Release-Note: >Audit-Trail: >Unformatted: