From rea-fbsd@codelabs.ru  Fri Dec 19 16:02:52 2008
Return-Path: <rea-fbsd@codelabs.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 247C71065674
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <rea-fbsd@codelabs.ru>
Reply-To: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] unbreak sbin/newfs build for the 8-CURRENT
X-Send-Pr-Version: 3.113
X-GNATS-Notify: luigi@freebsd.org

>Number:         129764
>Category:       bin
>Synopsis:       [patch] unbreak sbin/newfs(8) build for 8-CURRENT
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 19 16:10:00 UTC 2008
>Closed-Date:    Mon Sep 13 14:03:04 UTC 2010
>Last-Modified:  Mon Sep 13 14:03:04 UTC 2010
>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 <bsd.prog.mk>
 
+# 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:

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: "Eygene Ryabinkin" <rea-fbsd@codelabs.ru>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/129764: [patch] unbreak sbin/newfs build for the 8-CURRENT
Date: Mon, 22 Dec 2008 16:15:45 -0800

 Eygene,
     Is this honestly the only area where you had an issue? Seems like
 you should have had more potentially...
     Did you start off with a clean tree (NO_CLEAN=0 or unset)?
 -Garrett

From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To: Garrett Cooper <yanefbsd@gmail.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/129764: [patch] unbreak sbin/newfs build for the 8-CURRENT
Date: Tue, 23 Dec 2008 09:48:40 +0300

 --wlFCko3yyTbBmKK8
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Garret, good day.
 
 Mon, Dec 22, 2008 at 04:15:45PM -0800, Garrett Cooper wrote:
 > Is this honestly the only area where you had an issue?
 
 For now (-CURRENT from Dec 19th) -- yes, it is the only one.
 
 > Seems like you should have had more potentially...
 
 May be, but I am building the system with some parts disabled, so
 potential bugs could be unable to transform to the "kinetic" ones ;))
 If you have an idea about where another breakages can happen --
 I am all ears.
 
 > Did you start off with a clean tree (NO_CLEAN=3D0 or unset)?
 
 Yes, the tree was clean and the previous tree was never used for builds:
 it was just the virgin installation of December's snapshot followed by
 the full CVSup and build.
 --=20
 Eygene
  _                ___       _.--.   #
  \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
  /  ' `         ,       __.--'      #  to read the on-line manual  =20
  )/' _/     \   `-_,   /            #  while single-stepping the kernel.
  `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
      _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook=20
     {_.-``-'         {_/            #
 
 --wlFCko3yyTbBmKK8
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.9 (FreeBSD)
 
 iEYEARECAAYFAklQicgACgkQthUKNsbL7Yj34QCgssTVbFnwTOQyBFdeM1ypmdWs
 1q4AoKENmO2yb4ZWYuSBRx0rpdtc1f8D
 =DO34
 -----END PGP SIGNATURE-----
 
 --wlFCko3yyTbBmKK8--

From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To: Garrett Cooper <yanefbsd@gmail.com>
Cc: freebsd-bugs@freebsd.org, bug-followup@freebsd.org
Subject: Re: bin/129764: [patch] unbreak sbin/newfs build for the 8-CURRENT
Date: Sat, 27 Dec 2008 14:15:31 +0300

 Garrett, good day.
 
 Fri, Dec 26, 2008 at 07:27:05PM -0800, Garrett Cooper wrote:
 > On Tue, Dec 23, 2008 at 3:14 AM, Eygene Ryabinkin <rea-fbsd@codelabs.ru> wrote:
 > > Tue, Dec 23, 2008 at 02:21:25AM -0800, Garrett Cooper wrote:
 > >> Unfortunately I won't be able to verify this until the 31st (my
 > >> Macbook doesn't have Internet connectivity and my server is 2 states
 > >> away right now off :)..). Is that ok?
 > >
 > > No problems.  But if you have an idea where to search -- I can do
 > > it myself, at least I think so ;))
 > 
 > I really don't have a defined method. I'll take a look at it sometime
 > in the next couple days to see if I can help unbreak it for you ;).
 
 Hmm, the patch that was attached to the PR unbreaks the things for me
 (and should unbreak them for others).  I was just asking about the other
 places you mentioned when you said "there should be another places that
 will be broken with NO_DYNAMICROOT/NO_SHARED".  Did I understand you
 correctly?
 -- 
 Eygene
  _                ___       _.--.   #
  \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
  /  ' `         ,       __.--'      #  to read the on-line manual
  )/' _/     \   `-_,   /            #  while single-stepping the kernel.
  `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
      _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
     {_.-``-'         {_/            #
State-Changed-From-To: open->feedback 
State-Changed-By: arundel 
State-Changed-When: Mon Sep 13 13:28:11 UTC 2010 
State-Changed-Why:  
I'm not able to repeat this issue under a very recent HEAD (amd64). 
Could somebody please verify that this PR is still an issue? 
Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129764 
State-Changed-From-To: feedback->closed 
State-Changed-By: arundel 
State-Changed-When: Mon Sep 13 14:02:06 UTC 2010 
State-Changed-Why:  
Originator confirmed that this issue has been fixed. 
Thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129764 
>Unformatted:
