[PATCH] D54963: [lit] Pass more environment variables through on Windows

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 11:08:45 PST 2018


zturner created this revision.
zturner added a reviewer: rnk.
Herald added a subscriber: delcypher.

This arose when I was trying to have a substitution which invoked a python script P, and that python script tried to invoke clang-cl (or even cl).  Since we invoke P with a custom environment, it doesn't inherit the environment of the parent, and then when we go to invoke clang-cl, it's unable to find the MSVC installation directory.  There were many more I could have passed through which are set by vcvarsall, but I tried to keep it simple and only pass through the important ones.


https://reviews.llvm.org/D54963

Files:
  llvm/utils/lit/lit/TestingConfig.py


Index: llvm/utils/lit/lit/TestingConfig.py
===================================================================
--- llvm/utils/lit/lit/TestingConfig.py
+++ llvm/utils/lit/lit/TestingConfig.py
@@ -26,7 +26,16 @@
                      'LSAN_OPTIONS', 'ADB', 'ANDROID_SERIAL',
                      'SANITIZER_IGNORE_CVE_2016_2143', 'TMPDIR', 'TMP', 'TEMP',
                      'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT',
-                     'FILECHECK_DUMP_INPUT_ON_FAILURE', 'FILECHECK_OPTS']
+                     'FILECHECK_DUMP_INPUT_ON_FAILURE', 'FILECHECK_OPTS',
+                     'VCINSTALLDIR', 'VCToolsinstallDir', 'VSINSTALLDIR',
+                     'WindowsSdkDir', 'WindowsSDKLibVersion']
+
+        if sys.platform == 'win32':
+            pass_vars.append('INCLUDE')
+            pass_vars.append('LIB')
+            pass_vars.append('PATHEXT')
+            environment['PYTHONBUFFERED'] = '1'
+
         for var in pass_vars:
             val = os.environ.get(var, '')
             # Check for empty string as some variables such as LD_PRELOAD cannot be empty
@@ -34,15 +43,6 @@
             if val:
                 environment[var] = val
 
-        if sys.platform == 'win32':
-            environment.update({
-                    'INCLUDE' : os.environ.get('INCLUDE',''),
-                    'PATHEXT' : os.environ.get('PATHEXT',''),
-                    'PYTHONUNBUFFERED' : '1',
-                    'TEMP' : os.environ.get('TEMP',''),
-                    'TMP' : os.environ.get('TMP',''),
-                    })
-
         # Set the default available features based on the LitConfig.
         available_features = []
         if litConfig.useValgrind:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54963.175538.patch
Type: text/x-patch
Size: 1682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181127/7cb27fb9/attachment.bin>


More information about the llvm-commits mailing list