From owner-freebsd-current@FreeBSD.ORG Sat Dec 24 12:40:14 2011 Return-Path: Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC6D6106564A; Sat, 24 Dec 2011 12:40:13 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id 6CF2B8FC0C; Sat, 24 Dec 2011 12:40:13 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id pBOCe9TG027147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 24 Dec 2011 23:40:11 +1100 Date: Sat, 24 Dec 2011 23:40:09 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Alexander Best In-Reply-To: <20111224114714.GA29325@freebsd.org> Message-ID: <20111224225717.P2417@besplex.bde.org> References: <20111223235642.GA37495@freebsd.org> <20111224160050.T1141@besplex.bde.org> <20111224211903.I2059@besplex.bde.org> <20111224114714.GA29325@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Mailman-Approved-At: Sat, 24 Dec 2011 13:52:58 +0000 Cc: Adrian Chadd , freebsd-current@FreeBSD.ORG, Bruce Evans , freebsd-arch@FreeBSD.ORG Subject: Re: [rfc] removing -mpreferred-stack-boundary=2 flag for i386? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 24 Dec 2011 12:40:14 -0000 On Sat, 24 Dec 2011, Alexander Best wrote: > On Sat Dec 24 11, Bruce Evans wrote: >> This almost builds in -current too. I had to add the following: >> - NO_MODULES to de-bloat the compile time >> - MK_CTF=no to build -current on FreeBSD.9. The kernel .mk files are >> still broken (depend on nonstandard/new features in sys.mk). > > strange. the build(7) man page claims that: > > " > WITH_CTF If defined, the build process will run the DTrace CTF > conversion tools on built objects. Please note that > this WITH_ option is handled differently than all other > WITH_ options (there is no WITHOUT_CTF, or correspond- > ing MK_CTF in the build system). > " > > ... so setting MK_CTF to anything shouldn't have (according to the man page). MK_CTF is an implementation detail. It is normally set in bsd.own.mk (not in sys.mk line I said -- this gives another, much larger bug (*)). But when usr/share/mk is old, it doesn't know anything about MK_CTF. (For example, in FreeBSD-9, sys.mk sets NO_CTF to 1 if WITH_CTF is not defined. This corresponds to bsd.own.mk in -current setting MK_CTF to "no" if WITH_CTF is not defined. Go back to an older version of FreeBSD and /usr/share/mk/* won't know anything about any CTF variable.) So when you try to build a current kernel under an old version of FreeBSD, MK_CTF is used uninitialized and the build fails. (Of course, "you" build kernels normally and don't use the bloated buildkernel method.) The bug is in the following files: kern.post.mk:.if ${MK_CTF} != "no" kern.pre.mk:.if ${MK_CTF} != "no" kmod.mk:.if defined(MK_CTF) && ${MK_CTF} != "no" except for the last one where it has been fixed. (*) Well, not completely broken, but just annoyingly unportabile. Consider the following makefile: %%% foo: foo.c %%% Invoking this under FreeBSD-9 gives: %%% cc -O2 -pipe foo.c -o foo [ -z "ctfconvert" -o -n "1" ] || (echo ctfconvert -L VERSION foo && ctfconvert -L VERSION foo) %%% This is the old ctf method. It is ugly but is fairly portable. Invoking this under FreeBSD-9 but with -m gives %%% cc -O2 -pipe foo.c -o foo ${CTFCONVERT_CMD} expands to empty string %%% This is because: - the rule in sys.mk says ${CTFCONVERT_CMD} - CTFCONVERT_CMD is normally defined in bsd.own.mk. But bsd.own.mk is only included by BSD makefiles. It is never included by portable makefiles. So ${CTFCONVERT_CMD} is used uninitialized. - for some reason, using variables uninitialized is not fatal in this context, although it is for the comparisons of ${MK_CTF} above. - ${CTFCONVERT_CMD} is replaced by the empty string. Old versions of make warn about the use of an empty string as a shell command. - the code that is supposed to prevent the previous warning is in bsd.own.mk, where it is not reached for portable makefiles. It is: % .if ${MK_CTF} != "no" % CTFCONVERT_CMD= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} This uses the full ctfconvert if WITH_CTF. % .elif ${MAKE_VERSION} >= 5201111300 % CTFCONVERT_CMD= make(1) has been modified to not complain about the empty string. The version test detects which versions of make don't complain. % .else % CTFCONVERT_CMD= @: The default is to generate this non-empty string and an extra shell command to execute it, for old versions of make. % .endif But none of this works for portable makefiles, since it is not reached. Bruce