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