@@ -102,11 +102,6 @@ in batch file format instead of executing them.
102
102
. PARAMETER HostArchName
103
103
The architecture where the toolchain will execute.
104
104
105
- . PARAMETER Allocator
106
- The memory allocator used in the toolchain binaries, if it's
107
- `mimalloc`, it uses mimalloc. Otherwise, it uses the default
108
- allocator.
109
-
110
105
. EXAMPLE
111
106
PS> .\Build.ps1
112
107
@@ -143,7 +138,6 @@ param(
143
138
[switch ] $DebugInfo ,
144
139
[switch ] $EnableCaching ,
145
140
[string ] $Cache = " " ,
146
- [string ] $Allocator = " " ,
147
141
[switch ] $Summary ,
148
142
[switch ] $ToBatch
149
143
)
@@ -1692,44 +1686,56 @@ function Build-Compilers() {
1692
1686
}
1693
1687
1694
1688
# Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject
1695
- function Build-Mimalloc () {
1689
+ function Build-mimalloc () {
1696
1690
[CmdletBinding (PositionalBinding = $false )]
1697
1691
param
1698
1692
(
1699
1693
[Parameter (Position = 0 , Mandatory = $true )]
1700
1694
[hashtable ]$Arch
1701
1695
)
1702
1696
1703
- $MSBuildArgs = @ (" $SourceCache \mimalloc\ide\vs2022\mimalloc.sln" )
1697
+ # TODO: migrate to the CMake build
1698
+ $MSBuildArgs = @ ()
1704
1699
$MSBuildArgs += " -noLogo"
1705
1700
$MSBuildArgs += " -maxCpuCount"
1706
- $MSBuildArgs += " -p:Configuration=Release"
1707
- $MSBuildArgs += " -p:Platform=$ ( $Arch.ShortName ) "
1701
+
1702
+ $Properties = @ {}
1703
+ TryAdd- KeyValue $Properties Configuration Release
1704
+ TryAdd- KeyValue $Properties OutDir " $ ( $Arch.BinaryCache ) \mimalloc\bin\"
1705
+ TryAdd- KeyValue $Properties Platform " $ ( $Arch.ShortName ) "
1708
1706
1709
1707
Isolate- EnvVars {
1710
1708
Invoke-VsDevShell $Arch
1711
1709
# Avoid hard-coding the VC tools version number
1712
1710
$VCRedistDir = (Get-ChildItem " ${env: VCToolsRedistDir} \$ ( $HostArch.ShortName ) " - Filter " Microsoft.VC*.CRT" ).FullName
1713
1711
if ($VCRedistDir ) {
1714
- $MSBuildArgs += " -p:VCRedistDir= $VCRedistDir \"
1712
+ TryAdd - KeyValue $Properties VCRedistDir " $VCRedistDir \"
1715
1713
}
1716
1714
}
1717
1715
1718
- Invoke-Program $msbuild @MSBuildArgs
1716
+ foreach ($Property in $Properties.GetEnumerator ()) {
1717
+ if ($Property.Value.Contains (" " )) {
1718
+ $MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value.Replace (' \' , ' \\' )) "
1719
+ } else {
1720
+ $MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value ) "
1721
+ }
1722
+ }
1723
+
1724
+ Invoke-Program $msbuild " $SourceCache \mimalloc\ide\vs2022\mimalloc-lib.vcxproj" @MSBuildArgs " -p:IntDir=$ ( $Arch.BinaryCache ) \mimalloc\mimalloc\"
1725
+ Invoke-Program $msbuild " $SourceCache \mimalloc\ide\vs2022\mimalloc-override-dll.vcxproj" @MSBuildArgs " -p:IntDir=$ ( $Arch.BinaryCache ) \mimalloc\mimalloc-override-dll\"
1719
1726
1720
1727
$HostSuffix = if ($Arch -eq $ArchX64 ) { " " } else { " -arm64" }
1721
1728
$BuildSuffix = if ($BuildArch -eq $ArchX64 ) { " " } else { " -arm64" }
1722
- $Products = @ ( " mimalloc.dll" )
1723
- foreach ($Product in $Products ) {
1724
- Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\$Product " - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1725
- }
1726
- Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1729
+
1730
+ Copy-Item - Path " $ ( $Arch.BinaryCache ) \mimalloc\bin\mimalloc.dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin\"
1731
+ Copy-Item - Path " $ ( $Arch.BinaryCache ) \mimalloc\bin\mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1727
1732
# When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
1728
1733
# https://github.com/microsoft/mimalloc/issues/997
1729
1734
if ($IsCrossCompiling ) {
1730
- Copy-Item - Path " $SourceCache \mimalloc\out\msvc- $ ( $Arch.ShortName ) \Release \mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin\mimalloc-redirect$BuildSuffix .dll"
1735
+ Copy-Item - Path " $ ( $Arch.BinaryCache ) \mimalloc\bin \mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin\mimalloc-redirect$BuildSuffix .dll"
1731
1736
}
1732
1737
1738
+ # TODO: should we split this out into its own function?
1733
1739
$Tools = @ (
1734
1740
" swift.exe" ,
1735
1741
" swiftc.exe" ,
@@ -1746,9 +1752,9 @@ function Build-Mimalloc() {
1746
1752
foreach ($Tool in $Tools ) {
1747
1753
$Binary = [IO.Path ]::Combine(" $ ( $Arch.ToolchainInstallRoot ) \usr\bin" , $Tool )
1748
1754
# Binary-patch in place
1749
- Invoke-Program " $SourceCache \mimalloc\bin\minject$BuildSuffix " " -f" " -i" " -v" " $Binary "
1755
+ Start-Process - Wait - WindowStyle Hidden - FilePath " $SourceCache \mimalloc\bin\minject$BuildSuffix " - ArgumentList @ ( " -f" , " -i" , " -v" , " $Binary " )
1750
1756
# Log the import table
1751
- Invoke-Program " $SourceCache \mimalloc\bin\minject$BuildSuffix " " -l" " $Binary "
1757
+ Start-Process - Wait - WindowStyle Hidden - FilePath " $SourceCache \mimalloc\bin\minject$BuildSuffix " - ArgumentList @ ( " -l" , " $Binary " )
1752
1758
}
1753
1759
}
1754
1760
@@ -2995,16 +3001,13 @@ function Build-Installer($Arch) {
2995
3001
# TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
2996
3002
# when cross-compiling https://github.com/apple/swift/issues/71655
2997
3003
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling ) { " false" } else { " true" }
2998
- $ENABLE_MIMALLOC = if ($Allocator -eq " mimalloc" ) { " true" } else { " false" }
2999
- # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3000
- # https://github.com/microsoft/mimalloc/issues/997
3001
- $WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling ) { " true" } else { " false" }
3002
3004
3003
3005
$Properties = @ {
3004
3006
BundleFlavor = " offline" ;
3005
3007
TOOLCHAIN_ROOT = " $ ( $Arch.ToolchainInstallRoot ) \" ;
3006
- ENABLE_MIMALLOC = $ENABLE_MIMALLOC ;
3007
- WORKAROUND_MIMALLOC_ISSUE_997 = $WORKAROUND_MIMALLOC_ISSUE_997 ;
3008
+ # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3009
+ # https://github.com/microsoft/mimalloc/issues/997
3010
+ WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling ) { " true" } else { " false" };
3008
3011
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
3009
3012
SWIFT_DOCC_BUILD = " $ ( $Arch.BinaryCache ) \swift-docc\release" ;
3010
3013
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
@@ -3178,8 +3181,8 @@ if (-not $SkipBuild) {
3178
3181
3179
3182
Install-HostToolchain
3180
3183
3181
- if (-not $SkipBuild -and $Allocator -eq " mimalloc " ) {
3182
- Invoke-BuildStep Build-Mimalloc $HostArch
3184
+ if (-not $SkipBuild ) {
3185
+ Invoke-BuildStep Build-mimalloc $HostArch
3183
3186
}
3184
3187
3185
3188
if (-not $SkipBuild -and -not $IsCrossCompiling ) {
0 commit comments