@@ -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
@@ -144,7 +139,6 @@ param(
144
139
[switch ] $DebugInfo ,
145
140
[switch ] $EnableCaching ,
146
141
[string ] $Cache = " " ,
147
- [string ] $Allocator = " " ,
148
142
[switch ] $Summary ,
149
143
[switch ] $ToBatch
150
144
)
@@ -1685,44 +1679,56 @@ function Build-Compilers() {
1685
1679
}
1686
1680
1687
1681
# Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject
1688
- function Build-Mimalloc () {
1682
+ function Build-mimalloc () {
1689
1683
[CmdletBinding (PositionalBinding = $false )]
1690
1684
param
1691
1685
(
1692
1686
[Parameter (Position = 0 , Mandatory = $true )]
1693
1687
[hashtable ]$Arch
1694
1688
)
1695
1689
1696
- $MSBuildArgs = @ (" $SourceCache \mimalloc\ide\vs2022\mimalloc.sln" )
1690
+ # TODO: migrate to the CMake build
1691
+ $MSBuildArgs = @ ()
1697
1692
$MSBuildArgs += " -noLogo"
1698
1693
$MSBuildArgs += " -maxCpuCount"
1699
- $MSBuildArgs += " -p:Configuration=Release"
1700
- $MSBuildArgs += " -p:Platform=$ ( $Arch.ShortName ) "
1694
+
1695
+ $Properties = @ {}
1696
+ TryAdd- KeyValue $Properties Configuration Release
1697
+ TryAdd- KeyValue $Properties OutDir " $ ( $Arch.BinaryCache ) \mimalloc\bin\"
1698
+ TryAdd- KeyValue $Properties Platform " $ ( $Arch.ShortName ) "
1701
1699
1702
1700
Isolate- EnvVars {
1703
1701
Invoke-VsDevShell $Arch
1704
1702
# Avoid hard-coding the VC tools version number
1705
1703
$VCRedistDir = (Get-ChildItem " ${env: VCToolsRedistDir} \$ ( $HostArch.ShortName ) " - Filter " Microsoft.VC*.CRT" ).FullName
1706
1704
if ($VCRedistDir ) {
1707
- $MSBuildArgs += " -p:VCRedistDir= $VCRedistDir \"
1705
+ TryAdd - KeyValue $Properties VCRedistDir " $VCRedistDir \"
1708
1706
}
1709
1707
}
1710
1708
1711
- Invoke-Program $msbuild @MSBuildArgs
1709
+ foreach ($Property in $Properties.GetEnumerator ()) {
1710
+ if ($Property.Value.Contains (" " )) {
1711
+ $MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value.Replace (' \' , ' \\' )) "
1712
+ } else {
1713
+ $MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value ) "
1714
+ }
1715
+ }
1716
+
1717
+ Invoke-Program $msbuild " $SourceCache \mimalloc\ide\vs2022\mimalloc-lib.vcxproj" @MSBuildArgs " -p:IntDir=$ ( $Arch.BinaryCache ) \mimalloc\mimalloc\"
1718
+ Invoke-Program $msbuild " $SourceCache \mimalloc\ide\vs2022\mimalloc-override-dll.vcxproj" @MSBuildArgs " -p:IntDir=$ ( $Arch.BinaryCache ) \mimalloc\mimalloc-override-dll\"
1712
1719
1713
1720
$HostSuffix = if ($Arch -eq $ArchX64 ) { " " } else { " -arm64" }
1714
1721
$BuildSuffix = if ($BuildArch -eq $ArchX64 ) { " " } else { " -arm64" }
1715
- $Products = @ ( " mimalloc.dll" )
1716
- foreach ($Product in $Products ) {
1717
- Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\$Product " - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1718
- }
1719
- Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1722
+
1723
+ Copy-Item - Path " $ ( $Arch.BinaryCache ) \mimalloc\bin\mimalloc.dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin\"
1724
+ Copy-Item - Path " $ ( $Arch.BinaryCache ) \mimalloc\bin\mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1720
1725
# When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
1721
1726
# https://github.com/microsoft/mimalloc/issues/997
1722
1727
if ($IsCrossCompiling ) {
1723
- Copy-Item - Path " $SourceCache \mimalloc\out\msvc- $ ( $Arch.ShortName ) \Release \mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin\mimalloc-redirect$BuildSuffix .dll"
1728
+ Copy-Item - Path " $ ( $Arch.BinaryCache ) \mimalloc\bin \mimalloc-redirect$HostSuffix .dll" - Destination " $ ( $Arch.ToolchainInstallRoot ) \usr\bin\mimalloc-redirect$BuildSuffix .dll"
1724
1729
}
1725
1730
1731
+ # TODO: should we split this out into its own function?
1726
1732
$Tools = @ (
1727
1733
" swift.exe" ,
1728
1734
" swiftc.exe" ,
@@ -1739,9 +1745,9 @@ function Build-Mimalloc() {
1739
1745
foreach ($Tool in $Tools ) {
1740
1746
$Binary = [IO.Path ]::Combine(" $ ( $Arch.ToolchainInstallRoot ) \usr\bin" , $Tool )
1741
1747
# Binary-patch in place
1742
- Invoke-Program " $SourceCache \mimalloc\bin\minject$BuildSuffix " " -f" " -i" " -v" " $Binary "
1748
+ Start-Process - Wait - WindowStyle Hidden - FilePath " $SourceCache \mimalloc\bin\minject$BuildSuffix " - ArgumentList @ ( " -f" , " -i" , " -v" , " $Binary " )
1743
1749
# Log the import table
1744
- Invoke-Program " $SourceCache \mimalloc\bin\minject$BuildSuffix " " -l" " $Binary "
1750
+ Start-Process - Wait - WindowStyle Hidden - FilePath " $SourceCache \mimalloc\bin\minject$BuildSuffix " - ArgumentList @ ( " -l" , " $Binary " )
1745
1751
}
1746
1752
}
1747
1753
@@ -2927,16 +2933,13 @@ function Build-Installer($Arch) {
2927
2933
# TODO(hjyamauchi) Re-enable the swift-inspect and swift-docc builds
2928
2934
# when cross-compiling https://github.com/apple/swift/issues/71655
2929
2935
$INCLUDE_SWIFT_DOCC = if ($IsCrossCompiling ) { " false" } else { " true" }
2930
- $ENABLE_MIMALLOC = if ($Allocator -eq " mimalloc" ) { " true" } else { " false" }
2931
- # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
2932
- # https://github.com/microsoft/mimalloc/issues/997
2933
- $WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling ) { " true" } else { " false" }
2934
2936
2935
2937
$Properties = @ {
2936
2938
BundleFlavor = " offline" ;
2937
2939
TOOLCHAIN_ROOT = " $ ( $Arch.ToolchainInstallRoot ) \" ;
2938
- ENABLE_MIMALLOC = $ENABLE_MIMALLOC ;
2939
- WORKAROUND_MIMALLOC_ISSUE_997 = $WORKAROUND_MIMALLOC_ISSUE_997 ;
2940
+ # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
2941
+ # https://github.com/microsoft/mimalloc/issues/997
2942
+ WORKAROUND_MIMALLOC_ISSUE_997 = if ($IsCrossCompiling ) { " true" } else { " false" };
2940
2943
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
2941
2944
SWIFT_DOCC_BUILD = " $ ( $Arch.BinaryCache ) \swift-docc\release" ;
2942
2945
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
@@ -3104,8 +3107,8 @@ if (-not $SkipBuild) {
3104
3107
3105
3108
Install-HostToolchain
3106
3109
3107
- if (-not $SkipBuild -and $Allocator -eq " mimalloc " ) {
3108
- Invoke-BuildStep Build-Mimalloc $HostArch
3110
+ if (-not $SkipBuild ) {
3111
+ Invoke-BuildStep Build-mimalloc $HostArch
3109
3112
}
3110
3113
3111
3114
if (-not $SkipBuild -and -not $IsCrossCompiling ) {
0 commit comments