<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">I apologize for the second message, but I’ve created a revision with my proposed solution that works on our end.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I’d appreciate any feedback or guidance if this change is not the right way to fix my problem.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><a href="https://reviews.llvm.org/D78229/new/">https://reviews.llvm.org/D78229/new/</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">J.B.<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="color:#1F497D"><o:p> </o:p></span></a></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Nagurne, James
<br>
<b>Sent:</b> Wednesday, April 15, 2020 1:52 PM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Cc:</b> llvm_cgt@list.ti.com - LLVM Compiler Development (May contain non-TIers) (llvm_cgt@list.ti.com)<br>
<b>Subject:</b> lit errors when relying on PYTHONPATH for modules<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Our team utilizes a local directory for most of our non-standard python modules. An example of this is ‘pygments’.<o:p></o:p></p>
<p class="MsoNormal">We put this directory into our PYTHONPATH when we provision our systems for builds and validation.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">When LLVM configuration begins, there’s a section of code in llvm/cmake/config-ix.cmake that goes and looks for ‘pygments’, among other modules.<o:p></o:p></p>
<p class="MsoNormal">It correctly finds these modules and sets LLVM_HAVE_OPT_VIEWER_MODULES.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This variable is used to initialize a feature checked by the opt-viewer lit tests. Since we had the modules during LLVM configuration, we will therefore run the tests.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">lit creates a test script that looks something like this:<o:p></o:p></p>
<p class="MsoNormal">set -o pipefail;set -x;{ : 'RUN: at line 5';   /usr/bin/python3 /<LLVM_ROOT>/llvm/tools/opt-viewer/opt-viewer.py <options><o:p></o:p></p>
<p class="MsoNormal">…<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And executes that script with:<o:p></o:p></p>
<p class="MsoNormal">/bin/bash <BUILD_DIR>/test/tools/opt-viewer/Output/basic.test.script<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Starting a new shell via /bin/bash will not propagate the PYTHONPATH with which we initially configured LLVM, and the test fails because it can’t find ‘pygments’. The function which executes this command, executeCommand, does have an ‘env’
 parameter, but the argument sent in is usually ‘test.config.environment’, which does not include PYTHONPATH.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Are we missing something fundamental in our setup?<o:p></o:p></p>
<p class="MsoNormal">There’s a list of host variables that get propagated into the test suite (with_system_environment) in lit.cfg.py. Should we add “PYTHONPATH” to the list of variables propagated in llvm/test/lit.cfg.py?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">J.B.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>