From owner-freebsd-current@FreeBSD.ORG Wed Sep 11 21:48:09 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C4B3961D; Wed, 11 Sep 2013 21:48:09 +0000 (UTC) (envelope-from jmg@h2.funkthat.com) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 714072AE5; Wed, 11 Sep 2013 21:48:09 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id r8BLm77T085044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Sep 2013 14:48:08 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id r8BLm7dS085043; Wed, 11 Sep 2013 14:48:07 -0700 (PDT) (envelope-from jmg) Date: Wed, 11 Sep 2013 14:48:07 -0700 From: John-Mark Gurney To: Lev Serebryakov Subject: Re: Chicken and egg problem when building (third-party) kernel modules with -- how to solve? Message-ID: <20130911214807.GE68682@funkthat.com> Mail-Followup-To: Lev Serebryakov , freebsd-current@freebsd.org References: <1510067821.20130911173716@serebryakov.spb.ru> <20130911165346.GA68682@funkthat.com> <899884661.20130912011755@serebryakov.spb.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <899884661.20130912011755@serebryakov.spb.ru> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Wed, 11 Sep 2013 14:48:08 -0700 (PDT) Cc: freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Sep 2013 21:48:09 -0000 Lev Serebryakov wrote this message on Thu, Sep 12, 2013 at 01:17 +0400: > Hello, John-Mark. > You wrote 11 ???????????????? 2013 ??., 20:53:46: > > >> It is good idea to set KERNBUILDDIR when build module. But to set it you > >> need to know ${.OBJDIR} from ${SYSDIR} and ${SYSDIR} is set in bsd.kmod.mk, > >> which should be included last (after defining KERNBUILDDIR). > >> > >> How this loop could be broken? > > JMG> If you need to build it stand alone, you still need the opt_*.h files > I'm speaking about making port with kernel module, but this port is using > bsd.*.mk infrastructure by itself. > > JMG> from the kernel you are going to run it with, and that directory is > JMG> what you need to set KERNBUILDDIR... > KERNBUILDDIR could be set automagically with: > > KERNBUILDROOT!= make -C ${SYSDIR} -V .OBJDIR > KERNNAME!= uname -i > .if exists(${KERNBUILDROOT}/${KERNNAME}/opt_global.h) && !defined(KERNBUILDDIR) > KERNBUILDDIR:=${KERNBUILDROOT}/${KERNNAME} > .endif > > But here is problem, which I'm speaking about: it should go BEFORE > but it needs to use ${SYSDIR}. After a brief discussion w/ imp, we have the idea of pulling this information from the current running kernel. It isn't hard to put this information into an elf section and then extract it at module build time... For people releasing kernel modules for others, we'll need a better way to handle this... Plus, we might be able to identify a few macros that are KBI changing, and finally get close to being able to prevent loading kernels that would cause a crash due to KBI differences... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."