From owner-freebsd-arch@FreeBSD.ORG Thu Mar 5 16:32:28 2009 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C910B10656BE for ; Thu, 5 Mar 2009 16:32:28 +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 8181E8FC19 for ; Thu, 5 Mar 2009 16:32:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 0146D46B03 for ; Thu, 5 Mar 2009 11:32:27 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n25GWMto005108 for ; Thu, 5 Mar 2009 11:32:22 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: arch@freebsd.org Date: Thu, 5 Mar 2009 10:41:10 -0500 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903051041.10678.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 05 Mar 2009 11:32:22 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/9074/Thu Mar 5 10:21:02 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Subject: [PATCH] Set SYSDIR for modules built with kernel X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2009 16:32:29 -0000 One of the things each kernel module build has to do is figure out where the source tree it belongs to lives. /usr/share/mk/bsd.kmod.mk uses a heuristic where it walks up N levels of the tree looking for a kernel source directory. If that fails it falls back to /sys or /usr/src/sys. One side effect of this (besides lots of directory lookups during a build as each kernel module build stage has to do this) is that if CURRENT adds an even deeper level of nesting (such as with the recent ata chipset modules) then you can't build a kernel with those modules until /usr/share/mk/bsd.kmod.mk on your build machine has been updated. This means you can't build an 8.0 kernel on 7.0 simply because ata chipset modules don't find the right headers. However, the SYSDIR is already known during a kernel build (we depend on this to make modules built in ports DTRT when they are rebuilt via buildkernel). I just changed the kernel build Makefile to always set SYSDIR. With this change, I was able to build an 8.0 kernel + modules on a 7.1-ish machine with an unpatched /usr/share/mk/bsd.kmod.mk. This should also have the side effect of reducing the number of pathname lookup operations done during a kernel build with modules. Thoughts? --- //depot/projects/smpng/sys/conf/kern.post.mk 2009/01/15 22:41:24 +++ //depot/user/jhb/lock/conf/kern.post.mk 2009/03/04 21:25:21 @@ -12,7 +12,8 @@ .if defined(DESTDIR) MKMODULESENV+= DESTDIR="${DESTDIR}" .endif -MKMODULESENV+= KERNBUILDDIR="${.CURDIR}" +SYSDIR?= ${S:C;^[^/];${.CURDIR}/&;} +MKMODULESENV+= KERNBUILDDIR="${.CURDIR}" SYSDIR="${SYSDIR}" .MAIN: all @@ -29,7 +30,6 @@ # Handle out of tree ports .if !defined(NO_MODULES) && defined(PORTS_MODULES) -SYSDIR?= ${S:C;^[^/];${.CURDIR}/&;} PORTSMODULESENV=SYSDIR=${SYSDIR} .for __target in all install reinstall clean ${__target}: ports-${__target} -- John Baldwin