From owner-freebsd-current Sat Jan 15 10:10:49 2000 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 698DF14E02 for ; Sat, 15 Jan 2000 10:10:45 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (beefcake.zeta.org.au [203.26.10.12]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id FAA18109; Sun, 16 Jan 2000 05:10:21 +1100 Date: Sun, 16 Jan 2000 05:10:18 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Peter Wemm Cc: John Polstra , current@FreeBSD.ORG Subject: Re: RFC: buildworld breakage due to cross-tools/libc/mktemp. In-Reply-To: <20000115092129.7A7171C03@overcee.netplex.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sat, 15 Jan 2000, Peter Wemm wrote: > Bruce Evans wrote: > > ... and there is a linker > > bug that breaks elf static linkage (library functions can only be > > replaced by functions of the same size?). > No, that's not the problem. The problem is that libc.a has several But it is (was). It used to break static linkage of at least ctm_dequeue too, because ctm_dequeue has its own err() which needs to override the standard one. The problem has mysteriously vanished. It was present from approx. last August until recently. It still occurs if ctm_dequeue.c is broken by adding a call to one of the other functions in the library err.o conglomeration: # cc -O -pipe -Wall -I/usr/src/usr.sbin/ctm/ctm_dequeue/../ctm_rmail -static -o ctm_dequeue ctm_dequeue.o error.o # /usr/lib/libc.a(err.o): In function `err': # err.o(.text+0x30): multiple definition of `err' # error.o(.text+0x70): first defined here # /usr/libexec/elf/ld: Warning: size of symbol `err' changed from 232 to 30 in err.o # *** Error code 1 > functions, including mktemp, mkstemp, tmpnam etc, all in the one .o file. > gcc (g++ at least) uses mktemp() from that .o file in libc.a. That .o file > also provides mkstemps on newer builds. Now, if you try and do this with a > function that refers to mktemps: > > cc -o foo uses_mkstemps.o uses_mktemp.o -lmymkstemps -lc > > then you end up with mkstemps coming from the first library and then > mktemp causing the mktemp+mkstemp+mkstemps+etc.o file to come from libc.a > leading to a conflict... we have two mkstemps()'s in the file now and hence > the problem. Indeed. At least cc/cc has this problem when it links to a private copy of mkstemps(), because it uses other functions in the library mktemp.o conglomeration. I thought that this had been fixed. Static linkage should work the same as shared linkage here. Since the library organisation is clearly broken, the bug must be in shared linkage :-). This problem is currently handled by putting a copy of the entire library mktemp.o (rebuilt from current sources) in a private library. It has to provide private versions for all the functions in the host mktemp.o that it uses. There is some potential for getting it wrong, because it needs to satisfy some of the functionality of the host mktemp.o but it uses the target sources. E.g., when we break up mktemp.c, the private library copy of mktemp.o will no longer contain mkstemps, and piecing together current sources to create an object enough like the old mktemp.o will be difficult. > The solution is to break up all the multi-function files in libc as we > should have done ages ago. Not only does this work out more efficient for Not a solution for bootstrapping cc, since it will have no effect on linking cc to an old host library. Given that old libraries are broken, cc should consider that mkstemps() is library magic and use a different name for its version of of it. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message