From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 30 12:27:27 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C8E51065677; Wed, 30 Mar 2011 12:27:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 35E438FC13; Wed, 30 Mar 2011 12:27:27 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 6D40946B49; Wed, 30 Mar 2011 08:27:26 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 00EA58A01B; Wed, 30 Mar 2011 08:27:25 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Wed, 30 Mar 2011 08:00:11 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103300800.11548.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 08:27:26 -0400 (EDT) Cc: mdf@freebsd.org Subject: Re: Include file search path X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 12:27:27 -0000 On Tuesday, March 29, 2011 5:20:30 pm mdf@freebsd.org wrote: > I thought I knew something about how the compiler looks for include > files, but now I think maybe I don't know much. :-) > > So here's what I'm pondering. When I build a library, like e.g. libc, > where do the include files get pulled from? They can't (shouldn't) be > the ones in /usr/include, but I don't see a -nostdinc like for the > kernel. There are -I directives in the Makefile for > -I${.CURDIR}/include -I${.CURDIR}/../../include, etc., but that won't > remove /usr/include from the search path. > > I see in the gcc documentation that -I paths are searched before the > standards paths. But isn't the lack of -nostdinc a bug (not just for > libc, but for any library in /usr/src/lib)? It somewhat feels to me > that all of the libraries and binaries in the source distribution > should use -nostdinc and include only from the source distribution > itself. This isn't always an issue, but for source upgrades it seems > crucial, and for a hacker it saves difficulties with having to install > headers before re-building. > > Is that the intent, and it's not fully implemented? How badly would > things break if -nostdinc was included in e.g. bsd.lib.mk? (This would > break non-base libraries, yes? But as a thought experiment for the > base, how far off are we?) If you are building a library by hand you do want to use the includes from /usr/include. I am not sure how we accomplish during buildworld (but we do). I think we actually build the compiler in the cross-tools stage such that it uses the /usr/include directory under {WORLDTMP} in place of /usr/include in the default search path. Some other folks might be able to verify that (perhaps ru@?). -- John Baldwin