Bug in MSVC_BATCH handling
Eric Fahlgren <[email protected]> Sun, 15 Dec 2019 09:13:09 -0800
| Newsgroups | gmane.comp.programming.tools.scons.devel |
|---|---|
| Message-ID | <CAP2Qz+WKPAy1LKhYhh5fvS8ntFF7czApyCnmiDUd1tN6rvtFGQ@mail.gmail.com> |
--===============8477913967238204939==
Content-Type: multipart/alternative; boundary="0000000000003a43b10599c13622"
--0000000000003a43b10599c13622
Content-Type: text/plain; charset="UTF-8"
Py 3.7 64, Win 10 64
SCons 3.1.1 (but same as master in this case)
While cleaning up some old scripts, I uncovered a bug that I've been
working around for who knows how long and finally isolated it.
Problem: When MSVC_BATCH is enabled globally, files with different target
name are built individually, but ignoring the specified $TARGET name.
Here's a little example, note the first argument to the "cl" output.
Input:
env = Environment(MSVC_BATCH=True)
bug32 = env.Object(target='file32', source='file.cpp')
Output:
cl /FoWIN32\src\\ /c WIN32\src\file.cpp
If you explicitly suppress batching in the Object, then it works fine.
Input:
obj32 = env.Object(target='file32', source='file.cpp', MSVC_BATCH=False)
Output:
cl /FoWIN32\src\file32.obj /c WIN32\src\file.cpp
I chased this to the logic in Tool.msvc, the function msvc_output_flag
where it's checking the state of the MSVC_BATCH variable, and ignores the
difference in base name that the function just above (msvc_batch_key)
performs, see lines 168-173. My hack, which seems to work, is to change
line 191 in msvc.py from:
191: if 'MSVC_BATCH' not in env or env.subst('$MSVC_BATCH') in ('0', '
False', '', None):
to use the already-working logic in the batch key function like this:
191: if msvc_batch_key(None, env, target, source) is None:
I tried it on single file and multi-file compilations, and from my cursory
playing around, this keeps the batched files together and separates out
those with different target base names, but then I didn't try all cases or
check any other downstream code in the pipeline to see if this would break
anything there...
--0000000000003a43b10599c13622
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:arial,sa=
ns-serif;color:#000000">Py 3.7 64, Win 10 64<br></div><div class=3D"gmail_d=
efault" style=3D"font-family:arial,sans-serif;color:#000000">SCons 3.1.1 (b=
ut same as master in this case)<span class=3D"gmail-d-inline-block gmail-fl=
ex-shrink-0 gmail-v-align-bottom gmail-f6 gmail-mt-2 gmail-mt-md-0"><span d=
atetime=3D"2019-04-27T19:39:27Z" class=3D"gmail-no-wrap" title=3D"Apr 27, 2=
019, 12:39 PM PDT"></span>
</span>
</div><div class=3D"gmail_default" style=3D"font-family:arial,sans-serif;co=
lor:#000000"><br></div><div class=3D"gmail_default" style=3D"font-family:ar=
ial,sans-serif;color:#000000">While cleaning up some old scripts, I uncover=
ed a bug that I've been working around for who knows how long and final=
ly isolated it.</div><div class=3D"gmail_default" style=3D"font-family:aria=
l,sans-serif;color:#000000"><br></div><div class=3D"gmail_default" style=3D=
"font-family:arial,sans-serif;color:#000000">Problem: When MSVC_BATCH is en=
abled globally, files with different target name are built individually, bu=
t ignoring the specified $TARGET name.=C2=A0 Here's a little example, n=
ote the first argument to the "cl" output.<br></div><div class=3D=
"gmail_default" style=3D"font-family:arial,sans-serif;color:#000000"><br></=
div><div class=3D"gmail_default" style=3D"font-family:arial,sans-serif;colo=
r:#000000">Input:</div><div class=3D"gmail_default" style=3D"font-family:ar=
ial,sans-serif;color:#000000">env =3D Environment(MSVC_BATCH=3DTrue)<br></d=
iv>
<div class=3D"gmail_default" style=3D"font-family:arial,sans-serif;color:rg=
b(0,0,0)">
bug32 =3D env.Object(target=3D'file32', source=3D'file.cpp'=
)<br></div><div class=3D"gmail_default" style=3D"font-family:arial,sans-ser=
if;color:rgb(0,0,0)">
</div><div><span class=3D"gmail_default" style=3D"font-family:arial,sans-se=
rif;color:rgb(0,0,0)"><br></span></div><div><span class=3D"gmail_default" s=
tyle=3D"font-family:arial,sans-serif;color:rgb(0,0,0)">Output:<br></span></=
div><div><span class=3D"gmail_default" style=3D"font-family:arial,sans-seri=
f;color:rgb(0,0,0)">cl=C2=A0 /FoWIN32\src\\=C2=A0 /c=C2=A0 WIN32\src\file.c=
pp</span></div><div><br></div><div><div style=3D"font-family:arial,sans-ser=
if;color:rgb(0,0,0)" class=3D"gmail_default">If you explicitly suppress bat=
ching in the Object, then it works fine.
<div class=3D"gmail_default" style=3D"font-family:arial,sans-serif;color:rg=
b(0,0,0)">Input:<br></div><div class=3D"gmail_default" style=3D"font-family=
:arial,sans-serif;color:rgb(0,0,0)">obj32 =3D env.Object(target=3D'file=
32', source=3D'file.cpp', MSVC_BATCH=3DFalse)<br></div><div cla=
ss=3D"gmail_default" style=3D"font-family:arial,sans-serif;color:rgb(0,0,0)=
">
</div><div><span class=3D"gmail_default" style=3D"font-family:arial,sans-se=
rif;color:rgb(0,0,0)"></span>Output:<br></div><div>
<div><span class=3D"gmail_default" style=3D"font-family:arial,sans-serif;co=
lor:rgb(0,0,0)">cl=C2=A0 /FoWIN32\src\file32.obj=C2=A0 /c=C2=A0 WIN32\src\f=
ile.cpp</span></div>
</div></div></div><div><br></div><div><div style=3D"font-family:arial,sans-=
serif;color:rgb(0,0,0)" class=3D"gmail_default">I chased this to the logic =
in Tool.msvc, the function msvc_output_flag where it's checking the sta=
te of the MSVC_BATCH variable, and ignores the difference in base name that=
the function just above (msvc_batch_key) performs, see lines 168-173.=C2=
=A0 My hack, which seems to work, is to change line 191 in msvc.py from:</d=
iv><div style=3D"font-family:arial,sans-serif;color:rgb(0,0,0)" class=3D"gm=
ail_default"><br></div><div style=3D"font-family:arial,sans-serif;color:rgb=
(0,0,0)" class=3D"gmail_default">191: =C2=A0=C2=A0=C2=A0
<span class=3D"gmail-pl-k">if</span> <span class=3D"gmail-pl-s"><span c=
lass=3D"gmail-pl-pds">'</span>MSVC_BATCH<span class=3D"gmail-pl-pds">&#=
39;</span></span> <span class=3D"gmail-pl-k">not</span> <span class=3D"gmai=
l-pl-k">in</span> env <span class=3D"gmail-pl-k">or</span> env.<span class=
=3D"gmail-pl-token">subst</span>(<span class=3D"gmail-pl-s"><span class=3D"=
gmail-pl-pds">'</span>$MSVC_BATCH<span class=3D"gmail-pl-pds">'</sp=
an></span>) <span class=3D"gmail-pl-k">in</span> (<span class=3D"gmail-pl-s=
"><span class=3D"gmail-pl-pds">'</span>0<span class=3D"gmail-pl-pds">&#=
39;</span></span>, <span class=3D"gmail-pl-s"><span class=3D"gmail-pl-pds">=
'</span>False<span class=3D"gmail-pl-pds">'</span></span>, <span cl=
ass=3D"gmail-pl-s"><span class=3D"gmail-pl-pds">'</span><span class=3D"=
gmail-pl-pds">'</span></span>, <span class=3D"gmail-pl-c1">None</span>)=
:
</div></div><div><br></div><div><div style=3D"font-family:arial,sans-serif;=
color:rgb(0,0,0)" class=3D"gmail_default">to use the already-working logic =
in the batch key function like this:<br></div><div style=3D"font-family:ari=
al,sans-serif;color:rgb(0,0,0)" class=3D"gmail_default"><br></div><div styl=
e=3D"font-family:arial,sans-serif;color:rgb(0,0,0)" class=3D"gmail_default"=
>191:=C2=A0 =C2=A0 if msvc_batch_key(None, env, target, source) is None:</d=
iv></div><div><br></div><div><div style=3D"font-family:arial,sans-serif;col=
or:rgb(0,0,0)" class=3D"gmail_default">I tried it on single file and multi-=
file compilations, and from my cursory playing around, this keeps the batch=
ed files together and separates out those with different target base names,=
but then I didn't try all cases or check any other downstream code in =
the pipeline to see if this would break anything there...</div><br></div></=
div>
--0000000000003a43b10599c13622--
--===============8477913967238204939==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Scons-dev mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/scons-dev
--===============8477913967238204939==--