Skip to content

Commit

Permalink
utils: adjust the -Clean option to clean before execution
Browse files Browse the repository at this point in the history
This hoists the cleaning to prior to building the toolchain. This is
particularly important as changes in the module format may cause the
compiler to crash. Due to the use of Swift in the Swift compiler, we
load modules early and a previous run may have left over modules from
the last run, which would result in the module attempting to be loaded.
This cleans out the extra modules before the toolchain build avoiding
that.
  • Loading branch information
compnerd committed Jan 26, 2025
1 parent 998ad51 commit 877c53a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2790,6 +2790,19 @@ try {

Fetch-Dependencies

if ($Clean) {
10..[HostComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$_" -ErrorAction Ignore }
# In case of a previous test run, clear out the swiftmodules as they are not a stable format.
Remove-Item -Force -Recurse -Path "$($HostARch.ToolchainInstallRoot)\usr\lib\swift\windows\*.swiftmodule" -ErrorAction Ignore
foreach ($Arch in $WindowsSDKArchs) {
0..[TargetComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$($Arch.BuildID + $_)" -ErrorAction Ignore }
}
foreach ($Arch in $AndroidSDKArchs) {
0..[TargetComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$($Arch.BuildID + $_)" -ErrorAction Ignore }
}
}


if (-not $SkipBuild) {
if ($EnableCaching -And (-Not (Test-SCCacheAtLeast -Major 0 -Minor 7 -Patch 4))) {
throw "Minimum required sccache version is 0.7.4"
Expand All @@ -2810,18 +2823,6 @@ if (-not $SkipBuild) {
Invoke-BuildStep Build-Compilers $HostArch
}

if ($Clean) {
10..[HostComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$_" -ErrorAction Ignore }
# In case of a previous test run, clear out the swiftmodules as they are not a stable format.
Remove-Item -Force -Recurse "$($HostARch.ToolchainInstallRoot)\usr\lib\swift\windows" -ErrorAction Ignore
foreach ($Arch in $WindowsSDKArchs) {
0..[TargetComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$($Arch.BuildID + $_)" -ErrorAction Ignore }
}
foreach ($Arch in $AndroidSDKArchs) {
0..[TargetComponent].getEnumValues()[-1] | ForEach-Object { Remove-Item -Force -Recurse "$BinaryCache\$($Arch.BuildID + $_)" -ErrorAction Ignore }
}
}

if (-not $SkipBuild) {
foreach ($Arch in $WindowsSDKArchs) {
Invoke-BuildStep Build-ZLib Windows $Arch
Expand Down

0 comments on commit 877c53a

Please sign in to comment.