Skip to content

Conversation

@charles-zablit
Copy link
Contributor

Add an Extract-TarBall function to build.ps1 and use it to extract SCCache archives instead of Extract-ZipFile on ARM64 Windows.

SCCache is released as a .tar.gz file on ARM64 Windows, but as a .zip file on x64 Windows. Because of this, with the -EnableCachine flag, build.ps1 fails to install SCCache on ARM64 Windows. This patch introduces an Extract-TarBall function which is then used to extract tar.gz files.

@charles-zablit charles-zablit self-assigned this Sep 15, 2025
@charles-zablit charles-zablit added the Windows Platform: Windows label Sep 15, 2025
@charles-zablit
Copy link
Contributor Author

@swift-ci please smoke test

utils/build.ps1 Outdated
Write-Output "Extracting '$TarBallFileName' ..."
New-Item -ItemType Directory -ErrorAction Ignore -Path $destination | Out-Null
try {
tar -xvf $source -C $destination | Out-Null
Copy link
Member

Choose a reason for hiding this comment

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

Will this actually ever throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should not. I thought that if tar returned 1 the function would throw but that's not the case. Fixed, thanks!

utils/build.ps1 Outdated
Comment on lines 1127 to 1128
}
catch {
Copy link
Member

Choose a reason for hiding this comment

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

Please coddle the braces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the try/catch altogether.

utils/build.ps1 Outdated
}
}

$destination = if ($CreateExtractPath) { $destination } else { $BinaryCache }
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the Expand-ZipFile function to have the same functionalities. That's not needed in this patch, I removed it.

utils/build.ps1 Outdated
Comment on lines 1102 to 1105
[string]$TarBallFileName,
[string]$BinaryCache,
[string]$ExtractPath,
[bool]$CreateExtractPath = $true
Copy link
Member

Choose a reason for hiding this comment

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

These map to names, so please rename these:
TarBallFileName -> Source
ExtractPath -> Destination
CreateExtractPath -> CreateDestination

Do we ever invoke this with CreateDestinattion being $false? If not, perhaps we should just drop the parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed CreateDestination as we only call the function in one place.

The initial name of the parameters was copied from the Expand-ZipFile function. I have renamed them.

@charles-zablit charles-zablit force-pushed the charles-zablit/windows/fix-sccache-installation-arm64 branch from 0b8ffb3 to 6c109eb Compare September 15, 2025 16:07
@charles-zablit charles-zablit force-pushed the charles-zablit/windows/fix-sccache-installation-arm64 branch from 6c109eb to 071c789 Compare October 1, 2025 09:28
@charles-zablit
Copy link
Contributor Author

@swift-ci please test

utils/build.ps1 Outdated
@@ -1174,6 +1174,31 @@ function Get-Dependencies {
Expand-Archive -Path $source -DestinationPath $destination -Force
}

function Expand-TarBall {
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename this to Expand-TapeArchive or Expand-TarFile? "tarball" is a very unix-y colloquialism.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to using Expand-TapeArchive.

utils/build.ps1 Outdated
Comment on lines 1183 to 1184
$source = Join-Path -Path $BinaryCache -ChildPath $SourceName
$destination = Join-Path -Path $BinaryCache -ChildPath $DestinationName
Copy link
Member

Choose a reason for hiding this comment

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

Please use Pascal Case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@charles-zablit charles-zablit force-pushed the charles-zablit/windows/fix-sccache-installation-arm64 branch from 071c789 to 5cc226a Compare October 2, 2025 11:21
@charles-zablit
Copy link
Contributor Author

@swift-ci please smoke test

utils/build.ps1 Outdated
@@ -1227,8 +1252,13 @@ function Get-Dependencies {

if ($EnableCaching) {
$SCCache = Get-SCCache
DownloadAndVerify $SCCache.URL "$BinaryCache\sccache-$SCCacheVersion.zip" $SCCache.SHA256
Expand-ZipFile sccache-$SCCacheVersion.zip $BinaryCache sccache-$SCCacheVersion
$FileExtension = if ($SCCache.URL.EndsWith('.tar.gz')) { "tar.gz" } else { "zip" }
Copy link
Member

Choose a reason for hiding this comment

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

[System.IO.Path]::GetExtension() is better to get the extension; that along with the inversion below should work.

if ($Extension -eq "zip") {
  Expand-ZipFile ...
} else {
  Expand-TapeArchive ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Testing only on Windows for now because I'm not sure if this API works for URLs as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to be working!

@charles-zablit charles-zablit force-pushed the charles-zablit/windows/fix-sccache-installation-arm64 branch from 5cc226a to 1312cb7 Compare October 6, 2025 16:50
@charles-zablit
Copy link
Contributor Author

@swift-ci please smoke test windows

@charles-zablit
Copy link
Contributor Author

@swift-ci please smoke test linux

@charles-zablit
Copy link
Contributor Author

@swift-ci please smoke test macos

@charles-zablit
Copy link
Contributor Author

@swift-ci please test windows

1 similar comment
@charles-zablit
Copy link
Contributor Author

@swift-ci please test windows

@charles-zablit charles-zablit merged commit 8ffe033 into swiftlang:main Oct 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Platform: Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants