[llvm] [lit] Export env vars in script to avoid pruning (PR #105759)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 23:25:34 PDT 2024


================
@@ -1226,7 +1226,18 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
                     commands[i] += f" && {{ {command}; }}"
         if test.config.pipefail:
             f.write(b"set -o pipefail;" if mode == "wb" else "set -o pipefail;")
+
+        # Manually export any DYLD_* variables used by dyld on macOS because
+        # otherwise they are lost when the shell executable is run, before the
+        # lit test is executed.
+        env_str = "\n".join(
+            "export {}={};".format(k, shlex.quote(v))
+            for k, v in test.config.environment.items()
+            if k.startswith("DYLD_")
+        )
+        f.write(bytes(env_str, "utf-8") if mode == "wb" else env_str)
         f.write(b"set -x;" if mode == "wb" else "set -x;")
+
         if sys.version_info > (3, 0) and mode == "wb":
----------------
arichardson wrote:

Unrelated to this change but the version check can be dropped. 
Nit: the newline before is unrelated to this patch.

https://github.com/llvm/llvm-project/pull/105759


More information about the llvm-commits mailing list