JDevlieghere created this revision.
JDevlieghere added reviewers: labath, aprantl, davide.
Herald added a project: LLDB.

Setting `CCC_OVERRIDE_OPTIONS ` is a powerful way to change the behavior of the 
compiler. It's especially convenient for modifying how we build test inferiors. 
However, this is currently not possible, because we don't forward the 
environment variable. This patch adds support for this.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D66327

Files:
  lldb/packages/Python/lldbsuite/test/plugins/builder_base.py


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -36,6 +36,16 @@
     return os.path.realpath(compiler)
 
 
+def getEnv():
+    """Returns the build environment."""
+    env = dict()
+    whitelist = ['PATH', 'CCC_OVERRIDE_OPTIONS']
+    for v in whitelist:
+        if v in os.environ:
+            env[v] = os.environ[v]
+    return env
+
+
 def getArchFlag():
     """Returns the flag required to specify the arch"""
     compiler = getCompiler()
@@ -127,7 +137,7 @@
 
 def runBuildCommands(commands, sender):
     try:
-        lldbtest.system(commands, sender=sender)
+        lldbtest.system(commands, sender=sender, env=os.environ.copy())
     except subprocess.CalledProcessError as called_process_error:
         # Convert to a build-specific error.
         # We don't do that in lldbtest.system() since that


Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -36,6 +36,16 @@
     return os.path.realpath(compiler)
 
 
+def getEnv():
+    """Returns the build environment."""
+    env = dict()
+    whitelist = ['PATH', 'CCC_OVERRIDE_OPTIONS']
+    for v in whitelist:
+        if v in os.environ:
+            env[v] = os.environ[v]
+    return env
+
+
 def getArchFlag():
     """Returns the flag required to specify the arch"""
     compiler = getCompiler()
@@ -127,7 +137,7 @@
 
 def runBuildCommands(commands, sender):
     try:
-        lldbtest.system(commands, sender=sender)
+        lldbtest.system(commands, sender=sender, env=os.environ.copy())
     except subprocess.CalledProcessError as called_process_error:
         # Convert to a build-specific error.
         # We don't do that in lldbtest.system() since that
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to