Skip to content

[Microsoft.Android.Build.Tasks] Stream llvm-objdump output again - #13609

Merged
simonrozsival merged 1 commit into
mainfrom
simonrozsival-fix-objdump-output-streaming
Nov 18, 2026
Merged

simonrozsival merged 1 commit into
mainfrom
simonrozsival-fix-objdump-output-streaming

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Context: #12988
Context: #13515

On macOS and Linux, ObjdumpStreamsOutputBeforeProcessExit in ExtractTypeMapKeysFromNativeAotObjectTests fails:

Failed ObjdumpStreamsOutputBeforeProcessExit [6 s]
   System.InvalidOperationException : llvm-objdump exited with code 1: stderr output

#12988 added this test to check that <ExtractTypeMapKeysFromNativeAotObject/> reads llvm-objdump stdout while the process is still running, and kept RunObjdumpAsync on ProcessUtils.StartProcess for that reason. #13515 switched RunObjdumpAsync to Process.RunAndCaptureTextAsync, which buffers all of stdout until the process exits. The fake llvm-objdump in the test waits for the task to consume its output, times out, and exits with code 1.

CI did not catch this: Microsoft.Android.Build.Tasks.Tests only runs on Windows, where the test is skipped because the fake llvm-objdump is a shell script.

RunObjdumpAsync goes back to ProcessUtils.StartProcess, as before #13515. llvm-readobj still uses Process.RunAndCaptureTextAsync; its output is parsed as one JSON document.

Validation on macOS:

  • dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -c Release -p:_AndroidTreatWarningsAsErrors=true --filter "Name=ObjdumpStreamsOutputBeforeProcessExit": failed (1/1) before the fix, passed (1/1) after.
  • dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -c Release -p:_AndroidTreatWarningsAsErrors=true --no-build --filter "FullyQualifiedName~ExtractTypeMapKeysFromNativeAotObjectTests": passed (24/24).

Context: #12988
Context: #13515

#13515 switched RunObjdumpAsync to Process.RunAndCaptureTextAsync,
which buffers stdout until llvm-objdump exits and breaks
ObjdumpStreamsOutputBeforeProcessExit on macOS/Linux. Go back to
ProcessUtils.StartProcess so output is streamed.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 10:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change restoring streaming llvm-objdump output.

No open issues 🎉

What changed in this PR

Restores streaming of llvm-objdump output during NativeAOT type-map extraction, addressing the regression introduced by #13515.

Changes:

  • Uses ProcessUtils.StartProcess so stdout is consumed while llvm-objdump is running.
  • Captures stderr for nonzero-exit diagnostics; leaves llvm-readobj processing unchanged.
File Description
src/​Microsoft.Android.Build.Tasks/​Tasks/​ExtractTypeMapKeysFromNativeAotObject.cs Restores streaming stdout and preserves error reporting for llvm-objdump.

Review effort: Balanced

@simonrozsival
simonrozsival enabled auto-merge (squash) November 18, 2026 20:08
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ecf131d8 against main at 1dc2fdd5 (merge-base 18b89409). This was a static, read-only review; I didn't build or run anything, so the macOS test results are from your description.

LGTM. What I checked:

  • Revert scope: #13515 changed only the RunObjdumpAsync hunk in this file, and this PR restores it line for line: ProcessUtils.StartProcess (startInfo, stdout, stderr, CancellationToken), the StringWriter for stderr, and the same InvalidOperationException with the exit code and stderr. Nothing else from #13515 needs restoring.
  • Streaming: ProcessUtils.StartProcess reads stdout in chunks while the process runs and drains stderr concurrently, so a full stderr pipe can't stall llvm-objdump. TypeMapSymbolWriter overrides Write (char[], int, int) and keeps partial lines until the explicit Flush (), so chunks that split a line are handled.
  • Errors and cancellation: a nonzero exit still throws with stderr in the message; cancellation is checked before start, kills the process, and is rechecked after exit; the process is disposed.
  • Test: the fake llvm-objdump in ExtractTypeMapKeysFromNativeAotObjectTests writes stdout, then 10,000 stderr lines, and waits for SignalingWriter to see output before exiting 0. With streaming restored, that sequence completes and stdout is symbol output\n.
  • Unchanged paths: the relocations path still uses a plain StringWriter, and llvm-readobj stays on Process.RunAndCaptureTextAsync as described. None of the 7 newer commits on main touch this file, ProcessUtils.cs or the test.

@simonrozsival
simonrozsival merged commit fa63738 into main Nov 18, 2026
39 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-fix-objdump-output-streaming branch November 18, 2026 21:04
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.

3 participants