Fix extraction of Swift SDKs on Windows#9843
Conversation
First, make sure we're using the Windows tar to extract archives on Windows. It's based on libarchive so also handles zip files. Second fix the args of the extract command to properly extract the Swift SDK tarballs. Also SandboxTests was calling tar directly which breaks when running the tests in bash.
|
@swift-ci please test |
| var tarPath: PWSTR? | ||
| defer { CoTaskMemFree(tarPath) } | ||
| let hr = withUnsafePointer(to: FOLDERID_System) { id in | ||
| SHGetKnownFolderPath(id, DWORD(KF_FLAG_DEFAULT.rawValue), nil, &tarPath) |
There was a problem hiding this comment.
Can you please refactor this into a free function? Also, you can parameterize the folder ID so it's generalizable. See https://github.com/swiftlang/swift-build/blob/main/Sources/SWBWindowsPlatform/KnownFolders.swift
There was a problem hiding this comment.
Sure. Should I just clone the swift-build one? This probably should be somewhere where tools can share, but for now...
There was a problem hiding this comment.
Yeah I'd just copy the swift-build one for now.
jakepetroules
left a comment
There was a problem hiding this comment.
Note to our future selves looking at this years down the road: this was specifically about fixing extraction when using the Git Bash shell, which caused a different, incompatible copy of tar.exe to be present in the path, and this patch makes it always use the copy from System32.
|
The real fix was actually to stop hardcoding the compression format when extracting with tar so that the Windows tar command would handle zip files properly. |
|
Our future selves should merge the Zip and Tar archivers so that we standardize on libarchive where we can. |
|
Where are you finding .zip based Swift SDKs, btw? All of our official ones are .tar.gz. |
|
Ah, true. You are correct, I ran into this running the tests on Windows and making sure we're running the right tar. The registry archives and prebuilts are zips. We'll always have a mix. |
|
@swift-ci please test windows |
First, make sure we're using the Windows tar to extract archives on Windows. It's based on libarchive so also handles zip files. Move hardcoded use of the ZipArchiver to the UniversalArchiver so the platform logic can kick in.
Second fix the args of the extract command to properly extract the Swift SDK tarballs.
Also SandboxTests was calling tar directly which breaks when running the tests in bash.