@@ -1587,47 +1587,52 @@ function Build-Mimalloc() {
15871587 [hashtable ]$Arch
15881588 )
15891589
1590- if ($Arch -eq $ArchX64 ) {
1591- $Args = @ ()
1592- Isolate- EnvVars {
1593- Invoke-VsDevShell $Arch
1594- # Avoid hard-coding the VC tools version number
1595- $VCRedistDir = (Get-ChildItem " ${env: VCToolsRedistDir} \$ ( $HostArch.ShortName ) " - Filter " Microsoft.VC*.CRT" ).FullName
1596- if ($VCRedistDir ) {
1597- $Args += " -p:VCRedistDir=$VCRedistDir \"
1598- }
1599- }
1600- $Args += " $SourceCache \mimalloc\ide\vs2022\mimalloc.sln"
1601- $Args += " -p:Configuration=Release"
1602- $Args += " -p:ProductArchitecture=$ ( $Arch.VSName ) "
1603- Invoke-Program $msbuild @Args
1604- $Dest = " $ ( $Arch.ToolchainInstallRoot ) \usr\bin"
1605- Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\mimalloc-override.dll" `
1606- - Destination " $Dest "
1607- Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\mimalloc-redirect.dll" `
1608- - Destination " $Dest "
1609- $MimallocExecutables = @ (" swift.exe" , " swiftc.exe" , " swift-driver.exe" , " swift-frontend.exe" )
1610- $MimallocExecutables += @ (" clang.exe" , " clang++.exe" , " clang-cl.exe" )
1611- $MimallocExecutables += @ (" lld.exe" , " lld-link.exe" , " ld.lld.exe" , " ld64.lld.exe" )
1612- foreach ($Exe in $MimallocExecutables ) {
1613- $ExePath = [IO.Path ]::Combine($Dest , $Exe )
1614- # Binary-patch in place
1615- $Args = @ ()
1616- $Args += " -f"
1617- $Args += " -i"
1618- $Args += " -v"
1619- $Args += $ExePath
1620- Invoke-Program " $SourceCache \mimalloc\bin\minject" @Args
1621- # Log the import table
1622- $Args = @ ()
1623- $Args += " -l"
1624- $Args += $ExePath
1625- Invoke-Program " $SourceCache \mimalloc\bin\minject" @Args
1626- dir " $ExePath "
1627- }
1628- } else {
1590+ if ($Arch -ne $ArchX64 ) {
16291591 throw " mimalloc is currently supported for X64 only"
16301592 }
1593+
1594+ $MSBuildArgs = @ (" $SourceCache \mimalloc\ide\vs2022\mimalloc.sln" )
1595+ $MSBuildArgs += " -noLogo"
1596+ $MSBuildArgs += " -maxCpuCount"
1597+ $MSBuildArgs += " -p:Configuration=Release"
1598+ $MSBuildArgs += " -p:ProductArchitecture=$ ( $Arch.VSName ) "
1599+
1600+ Isolate- EnvVars {
1601+ Invoke-VsDevShell $Arch
1602+ # Avoid hard-coding the VC tools version number
1603+ $VCRedistDir = (Get-ChildItem " ${env: VCToolsRedistDir} \$ ( $HostArch.ShortName ) " - Filter " Microsoft.VC*.CRT" ).FullName
1604+ if ($VCRedistDir ) {
1605+ $MSBuildArgs += " -p:VCRedistDir=$VCRedistDir \"
1606+ }
1607+ }
1608+
1609+ Invoke-Program $msbuild @MSBuildArgs
1610+
1611+ $Products = @ ( " mimalloc-override.dll" , " mimalloc-redirect.dll" )
1612+ foreach ($Product in $Products ) {
1613+ Copy-Item - Path " $SourceCache \mimalloc\out\msvc-$ ( $Arch.ShortName ) \Release\$Product " - Destination " $ ( Arch.ToolchainInstallRoot) \usr\bin"
1614+ }
1615+
1616+ $Tools = @ (
1617+ " swift.exe" ,
1618+ " swiftc.exe" ,
1619+ " swift-driver.exe" ,
1620+ " swift-frontend.exe" ,
1621+ " clang.exe" ,
1622+ " clang++.exe" ,
1623+ " clang-cl.exe" ,
1624+ " lld.exe" ,
1625+ " lld-link.exe" ,
1626+ " ld.lld.exe" ,
1627+ " ld64.lld.exe"
1628+ )
1629+ foreach ($Tool in $Tools ) {
1630+ $Binary = [IO.Path ]::Combine($Dest , $Tool )
1631+ # Binary-patch in place
1632+ Invoke-Program " $SourceCache \mimalloc\bin\minject" @ (" -f" , " -i" , " -v" , $Binary )
1633+ # Log the import table
1634+ Invoke-Program " $SourceCache \mimalloc\bin\minject" @ (" -l" , $Binary )
1635+ }
16311636}
16321637
16331638function Build-LLVM ([Platform ]$Platform , $Arch ) {
0 commit comments