-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Update to .NET 6 Preview 6 and use crossgen2 #15763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adityapatwardhan
merged 21 commits into
PowerShell:master
from
adityapatwardhan:UseCrossGen2
Jul 19, 2021
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
99c0b27
Update build to use crossgen2
adityapatwardhan a5e9a0c
Remove fallback to crossgen
adityapatwardhan 9de4a23
Fix CA1846 issues
adityapatwardhan 9e01831
Remove --no-restore switch from dotnet publish
adityapatwardhan d877f06
Update to .NET 6 Preview 6
adityapatwardhan 7d941f6
Remove pdb generation for crossgen assembly as it fails on linux
adityapatwardhan e320bc2
Disable tests
adityapatwardhan ff274f6
Update the startup assemblies list
adityapatwardhan bc7a84c
Fix another parser test
adityapatwardhan dea13a0
Install crossgen package
adityapatwardhan b4e967b
Add logging
adityapatwardhan 3dbec6f
Use x64 crossgen for all windows
adityapatwardhan cce7ee4
Remove crossgen install
adityapatwardhan 75354ee
Add logging
adityapatwardhan 42cb0fa
Verify PATH in test
adityapatwardhan 88a662d
Add PATH
adityapatwardhan 70bbe96
Add bootstrap
adityapatwardhan b7d7a55
Rollback since dependency is missing
adityapatwardhan f0e1f19
Cleanup debug messages
adityapatwardhan 81fdb24
Disable tests for Test-Connection on macOS
adityapatwardhan 8b22cc8
Address comments from Travis
adityapatwardhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,7 +124,7 @@ function Get-EnvironmentInformation | |
| if ($environment.IsWindows) | ||
| { | ||
| $environment += @{'IsAdmin' = (New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)} | ||
| $environment += @{'nugetPackagesRoot' = "${env:USERPROFILE}\.nuget\packages"} | ||
| $environment += @{'nugetPackagesRoot' = "${env:USERPROFILE}\.nuget\packages", "${env:NUGET_PACKAGES}"} | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -419,7 +419,9 @@ Fix steps: | |
|
|
||
| # setup arguments | ||
| # adding ErrorOnDuplicatePublishOutputFiles=false due to .NET SDk issue: https://github.com/dotnet/sdk/issues/15748 | ||
| $Arguments = @("publish","--no-restore","/property:GenerateFullPaths=true", "/property:ErrorOnDuplicatePublishOutputFiles=false") | ||
| # removing --no-restore due to .NET SDK issue: https://github.com/dotnet/sdk/issues/18999 | ||
| # $Arguments = @("publish","--no-restore","/property:GenerateFullPaths=true", "/property:ErrorOnDuplicatePublishOutputFiles=false") | ||
| $Arguments = @("publish","/property:GenerateFullPaths=true", "/property:ErrorOnDuplicatePublishOutputFiles=false") | ||
| if ($Output -or $SMAOnly) { | ||
| $Arguments += "--output", (Split-Path $Options.Output) | ||
| } | ||
|
|
@@ -2323,78 +2325,85 @@ function Start-CrossGen { | |
|
|
||
| function New-CrossGenAssembly { | ||
| param ( | ||
| [Parameter(Mandatory= $true)] | ||
| [Parameter(Mandatory = $true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [String] | ||
| [String[]] | ||
| $AssemblyPath, | ||
| [Parameter(Mandatory= $true)] | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [String] | ||
| $CrossgenPath | ||
| $CrossgenPath, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [ValidateSet("alpine-x64", | ||
| "linux-arm", | ||
| "linux-arm64", | ||
| "linux-x64", | ||
| "osx-arm64", | ||
| "osx-x64", | ||
| "win-arm", | ||
| "win-arm64", | ||
| "win7-x64", | ||
| "win7-x86")] | ||
| [string] | ||
| $Runtime | ||
| ) | ||
|
|
||
| $outputAssembly = $AssemblyPath.Replace(".dll", ".ni.dll") | ||
| $platformAssembliesPath = Split-Path $AssemblyPath -Parent | ||
| $crossgenFolder = Split-Path $CrossgenPath | ||
| $niAssemblyName = Split-Path $outputAssembly -Leaf | ||
| $platformAssembliesPath = Split-Path $AssemblyPath[0] -Parent | ||
|
|
||
| try { | ||
| Push-Location $crossgenFolder | ||
| $targetOS, $targetArch = $Runtime -split '-' | ||
|
|
||
| # Generate the ngen assembly | ||
| Write-Verbose "Generating assembly $niAssemblyName" | ||
| Start-NativeExecution { | ||
| & $CrossgenPath /ReadyToRun /MissingDependenciesOK /in $AssemblyPath /out $outputAssembly /Platform_Assemblies_Paths $platformAssembliesPath | ||
| } | Write-Verbose | ||
| } finally { | ||
| Pop-Location | ||
| # Special cases where OS / Arch does not conform with runtime names | ||
| switch ($Runtime) { | ||
| 'alpine-x64' { | ||
| $targetOS = 'linux' | ||
| $targetArch = 'x64' | ||
| } | ||
| 'win-arm' { | ||
| $targetOS = 'windows' | ||
| $targetArch = 'arm' | ||
| } | ||
| 'win-arm64' { | ||
| $targetOS = 'windows' | ||
| $targetArch = 'arm64' | ||
| } | ||
| 'win7-x64' { | ||
| $targetOS = 'windows' | ||
| $targetArch = 'x64' | ||
| } | ||
| 'win7-x86' { | ||
| $targetOS = 'windows' | ||
| $targetArch = 'x86' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function New-CrossGenSymbol { | ||
| param ( | ||
| [Parameter(Mandatory= $true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [String] | ||
| $AssemblyPath, | ||
| [Parameter(Mandatory= $true)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [String] | ||
| $CrossgenPath | ||
| ) | ||
| $generatePdb = $targetos -eq 'windows' | ||
|
|
||
| # The path to folder must end with directory separator | ||
| $dirSep = [System.IO.Path]::DirectorySeparatorChar | ||
| $platformAssembliesPath = if (-not $platformAssembliesPath.EndsWith($dirSep)) { $platformAssembliesPath + $dirSep } | ||
|
|
||
| $platformAssembliesPath = Split-Path $AssemblyPath -Parent | ||
| $crossgenFolder = Split-Path $CrossgenPath | ||
|
|
||
| try { | ||
| Push-Location $crossgenFolder | ||
|
|
||
| $symbolsPath = [System.IO.Path]::ChangeExtension($assemblyPath, ".pdb") | ||
|
|
||
| $createSymbolOptionName = $null | ||
| if($Environment.IsWindows) | ||
| { | ||
| $createSymbolOptionName = '-CreatePDB' | ||
| Start-NativeExecution { | ||
| $crossgen2Params = @( | ||
| "-r" | ||
| $platformAssembliesPath | ||
| "--out-near-input" | ||
| "--single-file-compilation" | ||
| "-O" | ||
| "--targetos" | ||
| $targetOS | ||
| "--targetarch" | ||
| $targetArch | ||
| ) | ||
|
|
||
| } | ||
| elseif ($Environment.IsLinux) | ||
| { | ||
| $createSymbolOptionName = '-CreatePerfMap' | ||
| if ($generatePdb) { | ||
| $crossgen2Params += "--pdb" | ||
| } | ||
|
|
||
| if($createSymbolOptionName) | ||
| { | ||
| Start-NativeExecution { | ||
| & $CrossgenPath -readytorun -platform_assemblies_paths $platformAssembliesPath $createSymbolOptionName $platformAssembliesPath $AssemblyPath | ||
| } | Write-Verbose | ||
| } | ||
| $crossgen2Params += $AssemblyPath | ||
|
|
||
| # Rename the corresponding ni.dll assembly to be the same as the IL assembly | ||
| $niSymbolsPath = [System.IO.Path]::ChangeExtension($symbolsPath, "ni.pdb") | ||
| Rename-Item $niSymbolsPath $symbolsPath -Force -ErrorAction Stop | ||
| } finally { | ||
| Pop-Location | ||
| & $CrossgenPath $crossgen2Params | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2403,24 +2412,13 @@ function Start-CrossGen { | |
| } | ||
|
|
||
| # Get the path to crossgen | ||
| $crossGenExe = if ($environment.IsWindows) { "crossgen.exe" } else { "crossgen" } | ||
| $generateSymbols = $false | ||
| $crossGenExe = if ($environment.IsWindows) { "crossgen2.exe" } else { "crossgen2" } | ||
|
|
||
| # The crossgen tool is only published for these particular runtimes | ||
| $crossGenRuntime = if ($environment.IsWindows) { | ||
| if ($Runtime -match "-x86") { | ||
| "win-x86" | ||
| } elseif ($Runtime -match "-x64") { | ||
| "win-x64" | ||
| $generateSymbols = $true | ||
| } elseif (!($env:PROCESSOR_ARCHITECTURE -match "arm")) { | ||
| throw "crossgen for 'win-arm' and 'win-arm64' must be run on that platform" | ||
| } | ||
| } elseif ($Runtime -eq "linux-arm") { | ||
| throw "crossgen is not available for 'linux-arm'" | ||
| } elseif ($Runtime -eq "linux-x64") { | ||
| $Runtime | ||
| # We should set $generateSymbols = $true, but the code needs to be adjusted for different extension on Linux | ||
| # for windows the tool architecture is the host machine architecture, so it is always x64. | ||
| # we can cross compile for x86, arm and arm64 | ||
| "win-x64" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you comment why?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comment |
||
| } else { | ||
| $Runtime | ||
| } | ||
|
|
@@ -2440,31 +2438,9 @@ function Start-CrossGen { | |
| Select-Object -First 1 | ` | ||
| ForEach-Object { $_.FullName } | ||
| if (-not $crossGenPath) { | ||
| throw "Unable to find latest version of crossgen.exe. 'Please run Start-PSBuild -Clean' first, and then try again." | ||
| } | ||
| Write-Verbose "Matched CrossGen.exe: $crossGenPath" -Verbose | ||
|
|
||
| # Crossgen.exe requires the following assemblies: | ||
| # mscorlib.dll | ||
| # System.Private.CoreLib.dll | ||
| # clrjit.dll on Windows or libclrjit.so/dylib on Linux/OS X | ||
| $crossGenRequiredAssemblies = @("mscorlib.dll", "System.Private.CoreLib.dll") | ||
|
|
||
| $crossGenRequiredAssemblies += if ($environment.IsWindows) { | ||
| "clrjit.dll" | ||
| } elseif ($environment.IsLinux) { | ||
| "libclrjit.so" | ||
| } elseif ($environment.IsMacOS) { | ||
| "libclrjit.dylib" | ||
| } | ||
|
|
||
| # Make sure that all dependencies required by crossgen are at the directory. | ||
| $crossGenFolder = Split-Path $crossGenPath | ||
| foreach ($assemblyName in $crossGenRequiredAssemblies) { | ||
| if (-not (Test-Path "$crossGenFolder\$assemblyName")) { | ||
| Copy-Item -Path "$PublishPath\$assemblyName" -Destination $crossGenFolder -Force -ErrorAction Stop | ||
| } | ||
| throw "Unable to find latest version of crossgen2.exe. 'Please run Start-PSBuild -Clean' first, and then try again." | ||
| } | ||
| Write-Verbose "Matched CrossGen2.exe: $crossGenPath" -Verbose | ||
|
|
||
| # Common assemblies used by Add-Type or assemblies with high JIT and no pdbs to crossgen | ||
| $commonAssembliesForAddType = @( | ||
|
|
@@ -2495,11 +2471,13 @@ function Start-CrossGen { | |
|
|
||
| $fullAssemblyList = $commonAssembliesForAddType | ||
|
|
||
| foreach ($assemblyName in $fullAssemblyList) { | ||
| $assemblyPath = Join-Path $PublishPath $assemblyName | ||
| New-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyPath | ||
| $assemblyFullPaths = @() | ||
| $assemblyFullPaths += foreach ($assemblyName in $fullAssemblyList) { | ||
| Join-Path $PublishPath $assemblyName | ||
| } | ||
|
|
||
| New-CrossGenAssembly -CrossgenPath $crossGenPath -AssemblyPath $assemblyFullPaths -Runtime $Runtime | ||
|
|
||
| # | ||
| # With the latest dotnet.exe, the default load context is only able to load TPAs, and TPA | ||
| # only contains IL assembly names. In order to make the default load context able to load | ||
|
|
@@ -2523,12 +2501,6 @@ function Start-CrossGen { | |
| # Microsoft.CodeAnalysis.VisualBasic.dll, and Microsoft.CSharp.dll. | ||
| if ($commonAssembliesForAddType -notcontains $assemblyName) { | ||
| Remove-Item $symbolsPath -Force -ErrorAction Stop | ||
|
|
||
| if($generateSymbols) | ||
| { | ||
| Write-Verbose "Generating Symbols for $assemblyPath" | ||
| New-CrossGenSymbol -CrossgenPath $crossGenPath -AssemblyPath $assemblyPath | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "6.0.100-preview.4.21255.9" | ||
| "version": "6.0.100-preview.6.21355.2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.