From owner-freebsd-stable@FreeBSD.ORG Fri Mar 25 02:28:27 2005 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5B45F16A4CE; Fri, 25 Mar 2005 02:28:27 +0000 (GMT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7C7F43D31; Fri, 25 Mar 2005 02:28:26 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86])j2P2SIHn019703; Fri, 25 Mar 2005 13:28:18 +1100 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) j2P2SES5017665; Fri, 25 Mar 2005 13:28:15 +1100 Date: Fri, 25 Mar 2005 13:28:13 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Nick Barnes In-Reply-To: <90609.1111660565@thrush.ravenbrook.com> Message-ID: <20050325131358.T215@delplex.bde.org> References: <90609.1111660565@thrush.ravenbrook.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: freebsd-stable@freebsd.org cc: Vinod Kashyap cc: freebsd-amd64@freebsd.org Subject: Re: undefined reference to `memset' X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2005 02:28:27 -0000 On Thu, 24 Mar 2005, Nick Barnes wrote: > At 2005-03-24 08:31:14+0000, Bruce Evans writes: > >> what is gcc to do when -fno-builtin tells it to turn off its >> builtins and -ffreestanding tells it that the relevant interfaces >> might not exist in the library? > > Plainly, GCC should generate code which fills the array with zeroes. > It's not obliged to generate code which calls memset (either builtin > or in a library). If it knows that it can do so, then fine. > Otherwise it must do it the Old Fashioned Way. So this is surely a > bug in GCC. > > Nick B, who used to write compilers for a living But the compiler can require the Old Fashioned Way to be in the library. libgcc.a is probably part of gcc even in the freestanding case. The current implementation of libgcc.a won't all work in the freestanding case, since parts of it call stdio, but some parts of it are needed and work (e.g., __divdi3() on i386's at least). The kernel doesn't use libgcc.a, but it knows that __divdi3() and friends are needed and implements them in its libkern. Strictly, it should do something similar for memset(). I think the only bugs in gcc here are that the function it calls is in the application namespace in the freestanding case, and that the requirements for freestanding implementations are not all documented. The requirement for memset() and friends _is_ documented (in gcc.info), but the requirement for __divdi3() and friends are only documented indirectly by the presence of these functions in libgcc.a. Bruce