Re: Trouble Finding GCC

Bill Deegan <[email protected]> Tue, 17 Sep 2024 10:42:27 -0700
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <CAEyG4CFiPWUOW+ZuyCoEBZNDTJ89BDSspSkjOLduJhm5Azys5w@mail.gmail.com>
--===============3422354716096383413==
Content-Type: multipart/alternative; boundary="00000000000038ff5806225437e9"

--00000000000038ff5806225437e9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I'd do the following:

change:
main.Tool(SCons.Tool.FindTool(['gcc', 'clang'], main))
to:
x=3Dmain.Tool(SCons.Tool.FindTool(['gcc', 'clang'], main))
breakpoint()

That'll drop you into python debugger, then
p type(x)
p x
p [str(a) for a in x]

And then paste those results into email and share with us?

Any chance we can get you to join our discord server as it'd be much
faster/easier to debug this "live" rather than back and forth via email?
https://discord.gg/bXVpWAy

-Bill

On Tue, Sep 17, 2024 at 7:12=E2=80=AFAM Waqar, Faaiq G <faaiq.waqar@gatech.=
edu>
wrote:

> Thank you for the explanation. So I added the detection line
> (print(main.Detect(['gcc', 'clang']))) after I first initialize "main",
> which returns
> Apptainer> scons build/X86_MESI_Two_Level/gem5.fast
> scons: Reading SConscript files ...
> gcc
>
> Which I am understanding as it finding the gcc tool without issue. So
> then, when the SConscript moves onto the the main.Tool call, It still
> fails. I noticed a few more note placed in this thread, which I haven't
> replied to but will acknowledge. Indeed the SConscript setup I have is
> directly from Gem5, and it does work for most folks if not all folks,
> including myself on other systems. However, in the process of setting thi=
s
> up on my university's HPC, we encountered this issue leaving both IT and
> myself slightly puzzled.
>
> So to address the finding above, it detects the tool, and then fails due
> to the nonetype issue once again ("TypeError: 'NoneType' object is not
> callable: ... SConstruct", line 192:
>     main.Tool(SCons.Tool.FindTool(['gcc', 'clang'], main))
>   File "/usr/lib/python3/dist-packages/SCons/Environment.py", line 2033:
>     tool(self)")
> Any thoughts on this. I am reading into the Environment.py file to
> understand the cause. Thanks for the insight
>
> -----Original Message-----
> From: Mats Wichmann <[email protected]>
> Sent: Monday, September 16, 2024 2:23 PM
> To: Waqar, Faaiq G <[email protected]>; SCons users mailing list <
> [email protected]>
> Subject: Re: [Scons-users] Trouble Finding GCC
>
> [You don't often get email from [email protected]. Learn why this is
> important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On 9/16/24 12:06, Waqar, Faaiq G wrote:
> > Thank you for your response, and making me aware of this question from
> the FAQ.
> > So the gcc I am using is located in is /usr/bin/gcc. I added the
> following lines to my SConscript based my rudimentary understanding of th=
e
> FAQ solution:
> >
> > main =3D Environment(tools=3D[
> >          'default', 'git', TempFileSpawn, EnvDefaults, MakeActionTool,
> >          ConfigFile, AddLocalRPATH, SwitchingHeaders, TagImpliesTool,
> Blob
> >      ])
> >
> > ->main.AppendENVPath('PATH', '/usr/bin/gcc')
> > ->main.Tool("gcc")
> >
> > main.Tool(SCons.Tool.FindTool(['gcc', 'clang'], main))
> > main.Tool(SCons.Tool.FindTool(['g++', 'clang++'], main))
> >
> > I am still running into the issue, I assume because I am not using
> > this correctly. Any advice? Thank you again for your time
> /usr/bin should be part of the default path. The default path on
> POSIX-like systems is:
>
> env['ENV']['PATH'] =3D '/usr/local/bin:/opt/bin:/bin:/usr/bin:/snap/bin'
>
> I think there's possibly a terminology overload here...  the Tool() metho=
d
> loads what SCons calls a Tool Specification Module - which does setup so
> that you can go ahead and use the actual underlying program.
> It happens that the tool modules for the binaries named gcc and clang use
> the same names...  but you don't want to pass the path to the binary, lik=
e
> /usr/bin/gcc, to Tool, you want SCons to find the tool module itself, whi=
ch
> will be in a path like [path-to-SCons]/SCons/Tool/gcc.py.  (g++ has a too=
l
> named gcc and
> clang++ has one named clangxx, because a '+' is not valid in a Python
> module name).
>
> The "public API" for finding a tool is env.Detect() (well, main.Detect(),
> which you shouldn't even have to use, but as an experiment you could run:
>
> print(main.Detect(['gcc', 'clang'])
>
> and see if it finds either of those - it just returns the name, not the
> path.
>
>
> _______________________________________________
> Scons-users mailing list
> [email protected]
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>

--00000000000038ff5806225437e9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I&#39;d do the following:</div><div><br></div><div>ch=
ange:</div><div><span class=3D"gmail-im">main.Tool(SCons.Tool.FindTool([&#3=
9;gcc&#39;, &#39;clang&#39;], main))</span></div><div><span class=3D"gmail-=
im">to:</span></div><div><span class=3D"gmail-im">x=3D</span><span class=3D=
"gmail-im">main.Tool(SCons.Tool.FindTool([&#39;gcc&#39;, &#39;clang&#39;], =
main))</span></div><div><span class=3D"gmail-im">breakpoint()</span></div><=
div><span class=3D"gmail-im"><br></span></div><div><span class=3D"gmail-im"=
>That&#39;ll drop you into python debugger, then</span></div><div><span cla=
ss=3D"gmail-im">p type(x)</span></div><div><span class=3D"gmail-im">p x</sp=
an></div><div><span class=3D"gmail-im">p [str(a) for a in x]</span></div><d=
iv><span class=3D"gmail-im"><br></span></div><div><span class=3D"gmail-im">=
And then paste those results into email and share with us?</span></div><div=
><span class=3D"gmail-im"><br></span></div><div><span class=3D"gmail-im">An=
y chance we can get you to join our discord server as it&#39;d be much fast=
er/easier to debug this &quot;live&quot; rather than back and forth via ema=
il?</span></div><div><a href=3D"https://discord.gg/bXVpWAy">https://discord=
.gg/bXVpWAy</a></div><div><span class=3D"gmail-im"><br></span></div><div><s=
pan class=3D"gmail-im">-Bill<br></span></div></div><br><div class=3D"gmail_=
quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Sep 17, 2024 at 7:12=
=E2=80=AFAM Waqar, Faaiq G &lt;<a href=3D"mailto:[email protected]">fa=
[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
);padding-left:1ex">Thank you for the explanation. So I added the detection=
 line (print(main.Detect([&#39;gcc&#39;, &#39;clang&#39;]))) after I first =
initialize &quot;main&quot;, which returns <br>
Apptainer&gt; scons build/X86_MESI_Two_Level/gem5.fast<br>
scons: Reading SConscript files ...<br>
gcc<br>
<br>
Which I am understanding as it finding the gcc tool without issue. So then,=
 when the SConscript moves onto the the main.Tool call, It still fails. I n=
oticed a few more note placed in this thread, which I haven&#39;t replied t=
o but will acknowledge. Indeed the SConscript setup I have is directly from=
 Gem5, and it does work for most folks if not all folks, including myself o=
n other systems. However, in the process of setting this up on my universit=
y&#39;s HPC, we encountered this issue leaving both IT and myself slightly =
puzzled.<br>
<br>
So to address the finding above, it detects the tool, and then fails due to=
 the nonetype issue once again (&quot;TypeError: &#39;NoneType&#39; object =
is not callable: ... SConstruct&quot;, line 192:<br>
=C2=A0 =C2=A0 main.Tool(SCons.Tool.FindTool([&#39;gcc&#39;, &#39;clang&#39;=
], main))<br>
=C2=A0 File &quot;/usr/lib/python3/dist-packages/SCons/Environment.py&quot;=
, line 2033:<br>
=C2=A0 =C2=A0 tool(self)&quot;)<br>
Any thoughts on this. I am reading into the Environment.py file to understa=
nd the cause. Thanks for the insight<br>
<br>
-----Original Message-----<br>
From: Mats Wichmann &lt;<a href=3D"mailto:[email protected]" target=3D"_blan=
k">[email protected]</a>&gt; <br>
Sent: Monday, September 16, 2024 2:23 PM<br>
To: Waqar, Faaiq G &lt;<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>&gt;; SCons users mailing list &lt;<a hre=
f=3D"mailto:[email protected]" target=3D"_blank">[email protected]<=
/a>&gt;<br>
Subject: Re: [Scons-users] Trouble Finding GCC<br>
<br>
[You don&#39;t often get email from <a href=3D"mailto:[email protected]" tar=
get=3D"_blank">[email protected]</a>. Learn why this is important at <a href=
=3D"https://aka.ms/LearnAboutSenderIdentification" rel=3D"noreferrer" targe=
t=3D"_blank">https://aka.ms/LearnAboutSenderIdentification</a> ]<br>
<br>
On 9/16/24 12:06, Waqar, Faaiq G wrote:<br>
&gt; Thank you for your response, and making me aware of this question from=
 the FAQ.<br>
&gt; So the gcc I am using is located in is /usr/bin/gcc. I added the follo=
wing lines to my SConscript based my rudimentary understanding of the FAQ s=
olution:<br>
&gt;<br>
&gt; main =3D Environment(tools=3D[<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &#39;default&#39;, &#39;git&#39;, Te=
mpFileSpawn, EnvDefaults, MakeActionTool,<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ConfigFile, AddLocalRPATH, Switching=
Headers, TagImpliesTool, Blob<br>
&gt;=C2=A0 =C2=A0 =C2=A0 ])<br>
&gt;<br>
&gt; -&gt;main.AppendENVPath(&#39;PATH&#39;, &#39;/usr/bin/gcc&#39;)<br>
&gt; -&gt;main.Tool(&quot;gcc&quot;)<br>
&gt;<br>
&gt; main.Tool(SCons.Tool.FindTool([&#39;gcc&#39;, &#39;clang&#39;], main))=
 <br>
&gt; main.Tool(SCons.Tool.FindTool([&#39;g++&#39;, &#39;clang++&#39;], main=
))<br>
&gt;<br>
&gt; I am still running into the issue, I assume because I am not using <br=
>
&gt; this correctly. Any advice? Thank you again for your time<br>
/usr/bin should be part of the default path. The default path on POSIX-like=
 systems is:<br>
<br>
env[&#39;ENV&#39;][&#39;PATH&#39;] =3D &#39;/usr/local/bin:/opt/bin:/bin:/u=
sr/bin:/snap/bin&#39;<br>
<br>
I think there&#39;s possibly a terminology overload here...=C2=A0 the Tool(=
) method loads what SCons calls a Tool Specification Module - which does se=
tup so that you can go ahead and use the actual underlying program.<br>
It happens that the tool modules for the binaries named gcc and clang use t=
he same names...=C2=A0 but you don&#39;t want to pass the path to the binar=
y, like /usr/bin/gcc, to Tool, you want SCons to find the tool module itsel=
f, which will be in a path like [path-to-SCons]/SCons/Tool/gcc.py.=C2=A0 (g=
++ has a tool named gcc and<br>
clang++ has one named clangxx, because a &#39;+&#39; is not valid in a Pyth=
on<br>
module name).<br>
<br>
The &quot;public API&quot; for finding a tool is env.Detect() (well, main.D=
etect(), which you shouldn&#39;t even have to use, but as an experiment you=
 could run:<br>
<br>
print(main.Detect([&#39;gcc&#39;, &#39;clang&#39;])<br>
<br>
and see if it finds either of those - it just returns the name, not the pat=
h.<br>
<br>
<br>
_______________________________________________<br>
Scons-users mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Scons-users@scon=
s.org</a><br>
<a href=3D"https://pairlist4.pair.net/mailman/listinfo/scons-users" rel=3D"=
noreferrer" target=3D"_blank">https://pairlist4.pair.net/mailman/listinfo/s=
cons-users</a><br>
</blockquote></div>

--00000000000038ff5806225437e9--

--===============3422354716096383413==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users

--===============3422354716096383413==--