[llvm] [LIT] Fix env without subcommand causing early return in pipeline (PR #184028)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 06:01:22 PST 2026
================
@@ -831,16 +831,28 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env, shenv.umask)
args = updateEnv(cmd_shenv, args)
if not args:
- # Return the environment variables if no argument is provided.
- env_str = "\n".join(
- f"{key}={value}" for key, value in sorted(cmd_shenv.env.items())
- )
- results.append(
- ShellCommandResult(
- j, env_str, "", 0, timeoutHelper.timeoutReached(), []
+ if len(cmd.commands) == 1:
+ # Single command: return environment variables in-process.
+ env_str = "\n".join(
+ f"{key}={value}" for key, value in sorted(cmd_shenv.env.items())
)
- )
- return 0
+ results.append(
+ ShellCommandResult(
+ j, env_str, "", 0, timeoutHelper.timeoutReached(), []
+ )
+ )
+ return 0
+ # Pipeline: replace with a subprocess that prints the
+ # environment variables to stdout so the output can be
+ # piped to the next command.
+ args = [
+ sys.executable,
+ "-c",
+ "import os, sys; sys.stdout.write("
+ "'\\n'.join(k + '=' + v"
+ " for k, v in sorted(os.environ.items())) + '\\n')",
+ ]
----------------
boomanaiden154 wrote:
We want to move away from using these (except for `_launch_with_limit.py`). We need pipeline support for in-process builtins. Moving `env.py` to being an out of process builtin just papers over that issue.
https://github.com/llvm/llvm-project/pull/184028
More information about the llvm-commits
mailing list