Skip to content

llvm-foreach: print full command when failing#22044

Open
crystarm wants to merge 1 commit into
intel:syclfrom
crystarm:fix/llvm-foreach-print-full-command-on-failure
Open

llvm-foreach: print full command when failing#22044
crystarm wants to merge 1 commit into
intel:syclfrom
crystarm:fix/llvm-foreach-print-full-command-on-failure

Conversation

@crystarm
Copy link
Copy Markdown

@crystarm crystarm commented May 18, 2026

Fixes #20747

Summary

llvm-foreach currently reports generic errors (for example, No such file or directory) without showing which command failed.
This change improves diagnostics by printing the full command line that llvm-foreach attempted to run.

What changed

  • Added command formatting helper using sys::printArg(...) to preserve proper quoting.
  • Added unified failure reporting that includes the full command line.
  • Updated failure handling to print command line for:
    • command lookup failure (findProgramByName),
    • process launch failure (ExecuteNoWait with ExecutionFailed),
    • launched process non-zero exit status (both polling path and final wait path).
  • Stored submitted jobs as process + formatted command so failures can always report the exact command.

Tests

Extended llvm-foreach tests on both platforms:

  • llvm/test/tools/llvm-foreach/llvm-foreach-lin.ll
  • llvm/test/tools/llvm-foreach/llvm-foreach-win.ll

Added checks for:

  • non-zero command exit (false / cmd /c exit 1),
  • missing executable (llvm-foreach-command-does-not-exist),
  • expected llvm-foreach: command: ... output.

Validation

  • llvm-lit run for llvm/test/tools/llvm-foreach in local Linux setup (Linux tests pass; Windows-specific test is unsupported as expected).
  • Formatting/diagnostics checks for modified files are clean.

@crystarm crystarm requested a review from a team as a code owner May 18, 2026 16:35
@crystarm
Copy link
Copy Markdown
Author

Hi @sarnex!! (。・ω・。)

Could you please take a look when you have a chance?

I'm not entirely sure who would be the best person to ping here... But I'm tagging you since you reported the original issue.

@sarnex
Copy link
Copy Markdown
Contributor

sarnex commented May 20, 2026

Maybe @YuriPlyakhin or @maksimsab can take a first look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llvm-foreach should print the full command when failing

2 participants