From owner-freebsd-hackers Fri Feb 8 5:56:41 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id 37C6A37B41E; Fri, 8 Feb 2002 05:56:37 -0800 (PST) Received: from localhost (eischen@localhost) by mail.pcnet.com (8.12.1/8.12.1) with ESMTP id g18Duaf8028675; Fri, 8 Feb 2002 08:56:36 -0500 (EST) Date: Fri, 8 Feb 2002 08:56:36 -0500 (EST) From: Daniel Eischen To: Maxim Sobolev Cc: Terry Lambert , jdp@FreeBSD.org, deischen@FreeBSD.org, jasone@FreeBSD.org, hackers@FreeBSD.org, jlemon@FreeBSD.org Subject: Re: Linking libc before libc_r into application causes weird problems In-Reply-To: <3C63973F.111CF6D1@FreeBSD.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 8 Feb 2002, Maxim Sobolev wrote: > Terry Lambert wrote: > > > > Maxim Sobolev wrote: > > > $ cc test.c -o test -lc -lc_r > > > > > > When either of -lc or -lc_r is omitted, or their order is reversed the > > > problem disappears. The problem doesn't exist on 4-STABLE. > > > > > > Any ideas, comments and suggestions are welcome. > > > > Symbols are resolved from libraries in the order in which > > they are specified to the linker. > > > > So the fix is obvious: specify them in the right order. > > > > Linux doesn't see this because libc_r is just there for > > the reentrant calls, and their threading uses processes, > > instead of a user space ("quantum conservation") scheduler. > > All not as easy as it seems to be. -lc could come not from the command > line, but from one of the other libraries the binary being linked > with. Therefore, in real life resolving this problem could be a little > more tricky, especially with large applications (e.g. Evolution), that > uses code from 30+ shared libraries. I think that ld(1) should be > smart enough to reorder libc/libc_r so that libc_r is always linked > before libc. As you've found out, you have to link libc_r first. You shouldn't even specify -lc because the linker will automatically pull that in correctly. I don't think we should even try to support linking libc before libc_r or libpthread. The linker is working the way it is suppose to. Get the Evolution guys to fix the way it is built... -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message