[llvm] [lit] Export env vars in script to avoid pruning (PR #105759)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 17:58:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-testing-tools
Author: Keith Smiley (keith)
<details>
<summary>Changes</summary>
On macOS the dynamic loader prunes dyld specific environment variables such as `DYLD_INSERT_LIBRARIES`, `DYLD_LIBRARY_PATH`, etc. If these are set in the lit config it's safe to assume that the user actually wanted their subprocesses to run with these variables, versus the python interpreter that gets executed with them before they are pruned. This change exports all known variables in the shell script instead of relying on them being passed through.
---
Full diff: https://github.com/llvm/llvm-project/pull/105759.diff
1 Files Affected:
- (modified) llvm/utils/lit/lit/TestRunner.py (+5)
``````````diff
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da7fa86fd39173..7ea9fb9594cc32 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1223,6 +1223,11 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
if test.config.pipefail:
f.write(b"set -o pipefail;" if mode == "wb" else "set -o pipefail;")
f.write(b"set -x;" if mode == "wb" else "set -x;")
+
+ env_str = "\n".join("export {}={};".format(k, shlex.quote(v))
+ for k, v in test.config.environment.items())
+ f.write(bytes(env_str, "utf-8") if mode == "wb" else env_str)
+
if sys.version_info > (3, 0) and mode == "wb":
f.write(bytes("{ " + "; } &&\n{ ".join(commands) + "; }", "utf-8"))
else:
``````````
</details>
https://github.com/llvm/llvm-project/pull/105759
More information about the llvm-commits
mailing list