Date: Wed, 4 Sep 2019 09:31:25 -0700 From: Enji Cooper <yaneurabeya@gmail.com> To: Ian Lepore <ian@freebsd.org> Cc: Kyle Evans <kevans@freebsd.org>, Poul-Henning Kamp <phk@phk.freebsd.dk>, current <current@freebsd.org> Subject: Re: Weird goings on with make::empty() Message-ID: <26F4833D-81C6-42B6-B6CD-DF62714FAAD8@gmail.com> In-Reply-To: <5ab957620b5e28f1d9de14df12f9fdf60d00fc35.camel@freebsd.org> References: <3843.1567598344@critter.freebsd.dk> <969A062A-A52A-49E3-B4E3-CC9377B08C80@gmail.com> <CACNAnaE7Gw=r92akmx=tXgGNb=H7GuKm7=iXX2cLtSAxNALikA@mail.gmail.com> <5ab957620b5e28f1d9de14df12f9fdf60d00fc35.camel@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Sep 4, 2019, at 07:58, Ian Lepore <ian@freebsd.org> wrote: >=20 >> On Wed, 2019-09-04 at 09:33 -0500, Kyle Evans wrote: >> On Wed, Sep 4, 2019 at 9:27 AM Enji Cooper <yaneurabeya@gmail.com> >> wrote: >>>=20 >>>=20 >>>> On Sep 4, 2019, at 04:59, Poul-Henning Kamp <phk@phk.freebsd.dk> >>>> wrote: >>>>=20 >>>> On: >>>>=20 >>>> Repository Root: svn+ssh://repo.freebsd.org/base >>>> Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f >>>> Revision: 351809 >>>>=20 >>>> I built a kernel, but drm-current-kmod did not get compiled >>>> from the new world order in /usr/local/sys/modules >>>>=20 >>>> Debugging I ended up doing this to src/sys/conf/kern.post.mk: >>>>=20 >>>> Index: sys/conf/kern.post.mk >>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>>> =3D=3D=3D=3D=3D >>>> --- 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} "=3D=3D=3D> ${module} >>>> (${target:S/^reinstall$/install/:S/^clobber$/cleandir/})" >>>> @cd ${LOCAL_MODULES_DIR}/${module}; ${MKMODULESENV} >>>> ${MAKE} \ >>>> DIRPRFX=3D"${module}/" \ >>>> ${target:S/^reinstall$/install/:S/^clobber$/cleandir/} >>>> -.endif >>>> +#.endif >>>> .endfor >>>> .endif >>>> .endfor >>>>=20 >>>> This gives me the expected output from buildkernel: >>>>=20 >>>> 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 >>>> " >>>>=20 >>>> If I leave in the ".if !empty(module)" line in, I only get: >>>>=20 >>>> true "XXX A drm-current-kmod 2 /usr/local 3 drm-current-kmod 4 >>>> " >>>>=20 >>>> suggestions welcome... >>>=20 >>> (CCing Kyle) >>>=20 >>> This behavior change is probably caused by r351799. >>>=20 >>> I personally think the code before Kyle=E2=80=99s change and after it wa= s >>> buggy. It=E2=80=99s not word splitting LOCAL_MODULES before iterating ov= er >>> it. >>>=20 >>=20 >> 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. >>=20 >> Thanks, >>=20 >> Kyle Evans >>=20 >=20 > 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: >=20 > all: > .for x in a "" b > .if empty(x) > @echo empty > .endif > @echo ${x} > .endfor > @echo done >=20 > gives this output: >=20 > revolution > make -f /tmp/Makefile=20 > empty > a > empty >=20 > empty > b > done >=20 > 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. Correct. Word splitting is the key. I=E2=80=99ll take a stab at this later o= n today. Thanks, -Enji=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26F4833D-81C6-42B6-B6CD-DF62714FAAD8>