Skip to content

🍒 Cherry pick utils: avoid redirection and use pipes for output redirection #82847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Jul 7, 2025

Explanation: This fixes the encoding of the written plist files produced during a Windows toolchain build.
Scope: Bug fix for the Windows toolchain
Original PR: #80775
Risk: Low, this simply maintains the encoding on program output during a toolchain build.
Testing: Swift CI
Reviewers: @jeffdav @compnerd

Original commit description:
When the output is directly redirected, the output is re-encoded. This is particularly important as Write-PList uses Invoke-Program to invoke python.exe to write the plist. However, because it is writing to a file, while the output from Python is in UTF-8, the redirection re-encodes the output to UTF16LE (BOM). Adjust the invocation to use PS7+ 2| and pipe both stdout and stderr as appropriate into files with UTF-8 encoding restoring the encoding for the file.

When the output is directly redirected, the output is re-encoded. This
is particularly important as `Write-PList` uses `Invoke-Program` to
invoke `python.exe` to write the plist. However, because it is writing
to a file, while the output from Python is in UTF-8, the redirection
re-encodes the output to UTF16LE (BOM). Adjust the invocation to use
PS7+ `2|` and pipe both stdout and stderr as appropriate into files with
UTF-8 encoding restoring the encoding for the file.
@plemarquand plemarquand requested a review from a team as a code owner July 7, 2025 19:53
@plemarquand plemarquand added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jul 7, 2025
@plemarquand
Copy link
Contributor Author

For more context, this prevents the VS Code Swift Extension from initializing with a nightly 6.2 toolchain build as it expects Windows.platform/Info.plist to be encoded utf8.

@plemarquand
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@bkhouri bkhouri left a comment

Choose a reason for hiding this comment

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

It would have been nice being able to add a test to ensure we don't regress. Would https://github.com/swiftlang/swift-integration-tests be the right place?

@plemarquand plemarquand merged commit 6ece29f into swiftlang:release/6.2 Jul 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants