bin/129764: [patch] unbreak sbin/newfs build for the 8-CURRENT

Eygene Ryabinkin rea-fbsd at codelabs.ru
Fri Dec 19 08:10:01 PST 2008


>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 <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:
>Unformatted:


More information about the freebsd-bugs mailing list