From owner-freebsd-current@freebsd.org Wed Sep 4 14:58:50 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA146F4345 for ; Wed, 4 Sep 2019 14:58:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 46Nn5Q3zByz4QRg for ; Wed, 4 Sep 2019 14:58:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 88522F4344; Wed, 4 Sep 2019 14:58:50 +0000 (UTC) Delivered-To: current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 88180F4343 for ; Wed, 4 Sep 2019 14:58:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46Nn5Q13fQz4QRc for ; Wed, 4 Sep 2019 14:58:49 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1567609128; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=FScqB3Rk/c5ifa4X5jUiGQSdOHs/Q7eS+o1HkP6WXuQgj3BmfxcP55oHTgcLMKQHjQ/tnCoxItFaG U55EC4POBQac1O5E2gJky50SClwEDDCDu1ZJMvZtYe/wOlCaBesJOg7JzEmeczJv4xrQs7G1eT0vUA YIFxOr5vmnAQZFIccqTYBsabElGr9tQh2iqSNnxkuEFxVgvLWSofPHN+3dwzkICqEIcoiAjKWtul8S dQatNgrNU8YEeY9yb1FRbV/fUKyHVT70RxZ1fT1/+5SAkemnd7BjddhCtiOWyf9j5VWIDbpd6OceFb zDViv8vcfVt4jY5jH3XqdnmPRJ1gL8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:dkim-signature:from; bh=TDvisCKmgxwqnZZ2CUDmoWyyvBk1azrZOlHYWW4K5sY=; b=l/AKjMZnTJMaIddbj+ZIIN5RhhJuqrhwGFDbnH+YkD7HDlpM2csk8TtTXb+FUqqJtqSBBij8rEyul kpdQ3xXAoXgYibbAGBEVPLlH/H5X9/FGtBiqqHgr+hieeqcsLoA3Ub65+KMugHoLqrWVwJcIG0AM8Y AV+arKfaJ9KYu/TpTNbeMZUenxKFqcxsTLI6X4R1UD8ik+ZRMEEP6xJqvujl2w4sb3oh4MKRtNitaD DP7Y9K90jWn0hEvQX7fwqyYZtM2nqaxkxmN4M1iR3TGJLjPXN27JagxJJbdWmBrMzAn3cG4BhCs/2r YgMcDUt+/hnuECzBAlzrWytPbOzg1Vw== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:from; bh=TDvisCKmgxwqnZZ2CUDmoWyyvBk1azrZOlHYWW4K5sY=; b=R++vvjwahgcQAygyDCnob4uWWwzFfoLhg/EteGiKmHtmhQSfrdJD9pPy+EzyPP/6iZ6oQxGeyo3AI m4WQHOvfsaHggY3+JYouxyBIUF0lmOGs3d6a1Pn55JzAJGWLXODfNgcpG1R5tXLDWBKcbLRScIJOsQ pACR/lrzU0jaS7BCXn86ISm/gsWTbsMh+7mfZwZb69dkI18VmrmDQyyUHR4A237UM9Pc43hUxNUA8k FxXG/CAD1CXW7c5eqKVMjihqLDdAYcmMHNmM14bnQ7PiMpayRuFRNMoZdGAEbxLOZBdds5uHdSoS7Q aV90IvPuZH7O0jsQPL7rDIAFoZp0uAA== X-MHO-RoutePath: aGlwcGll X-MHO-User: 7ec17528-cf24-11e9-b67c-cdd75d6ce7a8 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 7ec17528-cf24-11e9-b67c-cdd75d6ce7a8; Wed, 04 Sep 2019 14:58:47 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x84Ewj1B042006; Wed, 4 Sep 2019 08:58:45 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <5ab957620b5e28f1d9de14df12f9fdf60d00fc35.camel@freebsd.org> Subject: Re: Weird goings on with make::empty() From: Ian Lepore To: Kyle Evans , Enji Cooper Cc: Poul-Henning Kamp , current Date: Wed, 04 Sep 2019 08:58:45 -0600 In-Reply-To: References: <3843.1567598344@critter.freebsd.dk> <969A062A-A52A-49E3-B4E3-CC9377B08C80@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 46Nn5Q13fQz4QRc X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.982,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 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, 04 Sep 2019 14:58:50 -0000 On Wed, 2019-09-04 at 09:33 -0500, Kyle Evans wrote: > On Wed, Sep 4, 2019 at 9:27 AM Enji Cooper > wrote: > > > > > > > On Sep 4, 2019, at 04:59, Poul-Henning Kamp > > > wrote: > > > > > > On: > > > > > > Repository Root: svn+ssh://repo.freebsd.org/base > > > Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f > > > Revision: 351809 > > > > > > I built a kernel, but drm-current-kmod did not get compiled > > > from the new world order in /usr/local/sys/modules > > > > > > Debugging I ended up doing this to src/sys/conf/kern.post.mk: > > > > > > Index: sys/conf/kern.post.mk > > > ============================================================== > > > ===== > > > --- sys/conf/kern.post.mk (revision 351809) > > > +++ sys/conf/kern.post.mk (working copy) > > > @@ -77,12 +77,14 @@ > > > ${target:S/^reinstall$/install/:S/^clobber$/cleandir/} > > > .endif > > > .for module in ${LOCAL_MODULES} > > > -.if !empty(module) > > > + true "XXX A $(module) 2 ${LOCALBASE} 3 ${LOCAL_MODULES} 4 > > > ${MODULES_WITH_WORLD}" > > > +#.if !empty(module) > > > + true "XXX B $(module) 2 ${LOCALBASE} 3 ${LOCAL_MODULES} 4 > > > ${MODULES_WITH_WORLD}" > > > @${ECHODIR} "===> ${module} > > > (${target:S/^reinstall$/install/:S/^clobber$/cleandir/})" > > > @cd ${LOCAL_MODULES_DIR}/${module}; ${MKMODULESENV} > > > ${MAKE} \ > > > DIRPRFX="${module}/" \ > > > ${target:S/^reinstall$/install/:S/^clobber$/cleandir/} > > > -.endif > > > +#.endif > > > .endfor > > > .endif > > > .endfor > > > > > > This gives me the expected output from buildkernel: > > > > > > true "XXX A drm-current-kmod 2 /usr/local 3 drm-current-kmod 4 > > > " > > > true "XXX B drm-current-kmod 2 /usr/local 3 drm-current-kmod 4 > > > " > > > > > > If I leave in the ".if !empty(module)" line in, I only get: > > > > > > true "XXX A drm-current-kmod 2 /usr/local 3 drm-current-kmod 4 > > > " > > > > > > suggestions welcome... > > > > (CCing Kyle) > > > > This behavior change is probably caused by r351799. > > > > I personally think the code before Kyle’s change and after it was > > buggy. It’s not word splitting LOCAL_MODULES before iterating over > > it. > > > > I've backed out r351799 since it breaks usage of LOCAL_MODULES > (though > I really don't understand how empty works, apparently, and that makes > me sad)... please advise on a correct path forward, because it's not > clear to me. > > Thanks, > > Kyle Evans > I'm not positive, but I suspect this has to do with when variables are expanded. In particular, the loop variable for a .for is expanded on each loop iteration, but doesn't yet exist during parsing. I suspect that the .if is evaluated earlier, during parsing. For example, this makefile: all: .for x in a "" b .if empty(x) @echo empty .endif @echo ${x} .endfor @echo done gives this output: revolution > make -f /tmp/Makefile empty a empty empty b done The way I interpret that is that empty(x) is true during parsing, so the for loop is generated to contain "@echo empty" and "@echo ${x}", then the for loop actually runs and prints both "empty" and the value of ${x} on each iteration. -- Ian