From owner-freebsd-hackers Fri Feb 8 1:17:28 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from alcatraz.iptelecom.net.ua (alcatraz.iptelecom.net.ua [212.9.224.15]) by hub.freebsd.org (Postfix) with ESMTP id 24DE637B494; Fri, 8 Feb 2002 01:17:11 -0800 (PST) Received: from ipcard.iptcom.net (ipcard.iptcom.net [212.9.224.5]) by alcatraz.iptelecom.net.ua (8.9.3/8.9.3) with ESMTP id LAA65316; Fri, 8 Feb 2002 11:17:01 +0200 (EET) (envelope-from sobomax@FreeBSD.org) Received: from vega.vega.com (h8.234.dialup.iptcom.net [212.9.234.8]) by ipcard.iptcom.net (8.9.3/8.9.3) with ESMTP id LAA50085; Fri, 8 Feb 2002 11:16:59 +0200 (EET) (envelope-from sobomax@FreeBSD.org) Received: from FreeBSD.org (big_brother.vega.com [192.168.1.1]) by vega.vega.com (8.11.6/8.11.3) with ESMTP id g189FRd67801; Fri, 8 Feb 2002 11:15:27 +0200 (EET) (envelope-from sobomax@FreeBSD.org) Message-ID: <3C63973F.111CF6D1@FreeBSD.org> Date: Fri, 08 Feb 2002 11:15:43 +0200 From: Maxim Sobolev Organization: Vega International Capital X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) X-Accept-Language: en,uk,ru MIME-Version: 1.0 To: Terry Lambert Cc: 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 References: <1013147180.73417.2.camel@notebook> <3C637097.13B8C35A@mindspring.com> Content-Type: text/plain; charset=x-user-defined Content-Transfer-Encoding: 7bit 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 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. -Maxim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message