Skip to content
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

Rebuild Microsoft.CodeAnalysis #50968

Merged
merged 19 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": "Launch BuildValidator.dll",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/netcoreapp3.1/BuildValidator.dll",
"args": [
"--assembliesPath", "./artifacts/obj/RunTests",
"--debugPath", "./artifacts/BuildValidator",
"--sourcePath", "."
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Launch RunTests.dll",
"type": "coreclr",
Expand Down
35 changes: 35 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,38 @@ jobs:
continueOnError: true
condition: not(succeeded())

- job: Correctness_Rebuild
RikkiGibson marked this conversation as resolved.
Show resolved Hide resolved
pool:
vmImage: windows-2019
timeoutInMinutes: 90
steps:
- template: eng/pipelines/checkout-windows-task.yml

- task: PowerShell@2
displayName: Restore
inputs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -restore -binaryLog

- task: PowerShell@2
displayName: Build
inputs:
filePath: eng/build.ps1
arguments: -configuration Debug -prepareMachine -ci -build -bootstrap -publish -binaryLog -skipDocumentation

- script: .\artifacts\bin\BuildValidator\Debug\net472\BuildValidator.exe --assembliesPath .\artifacts\obj\Microsoft.CodeAnalysis --debugPath .\artifacts\BuildValidator --sourcePath .
displayName: Run BuildValidator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to have this logic in a eng/validate-rebuild.ps1 file, so it can be easily run locally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why not call test-rebuild.ps1?


In reply to: 578014609 [](ancestors = 578014609)


- task: PublishBuildArtifacts@1
displayName: Publish BuildValidator debug outputs
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/BuildValidator'
ArtifactName: 'BuildValidator_DebugOut'
publishLocation: Container
continueOnError: true
condition: failed()

- template: eng/pipelines/publish-logs.yml
parameters:
jobName: Correctness_Rebuild
configuration: Debug
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.8.27812-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta3.20174.1</MicrosoftMetadataVisualizerVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta3.21075.2</MicrosoftMetadataVisualizerVersion>
<MicrosoftMSXMLVersion>8.0.0</MicrosoftMSXMLVersion>
<MicrosoftNETBuildExtensionsVersion>2.2.101</MicrosoftNETBuildExtensionsVersion>
<MicrosoftNETCorePlatformsVersion>2.1.2</MicrosoftNETCorePlatformsVersion>
Expand Down Expand Up @@ -205,6 +205,7 @@
<SystemBuffersVersion>4.5.1</SystemBuffersVersion>
<SystemCompositionVersion>1.0.31</SystemCompositionVersion>
<SystemCodeDomVersion>4.7.0</SystemCodeDomVersion>
<SystemCommandLineVersion>2.0.0-beta1.20574.7</SystemCommandLineVersion>
<SystemCommandLineExperimentalVersion>0.3.0-alpha.19577.1</SystemCommandLineExperimentalVersion>
<SystemComponentModelCompositionVersion>4.5.0</SystemComponentModelCompositionVersion>
<SystemDrawingCommonVersion>4.5.0</SystemDrawingCommonVersion>
Expand Down
2 changes: 1 addition & 1 deletion eng/build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function Make-BootstrapBuild([switch]$force32 = $false) {

Run-MSBuild $projectPath "/restore /t:Pack /p:RoslynEnforceCodeStyle=false /p:RunAnalyzersDuringBuild=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=`"$dir`" /p:EnableNgenOptimization=false /p:PublishWindowsPdb=false $force32Flag" -logFileName "Bootstrap" -configuration $bootstrapConfiguration -runAnalyzers
$packageFile = Get-ChildItem -Path $dir -Filter "$packageName.*.nupkg"
Unzip "$dir\$packageFile" $dir
Unzip (Join-Path $dir $packageFile) $dir

Write-Host "Cleaning Bootstrap compiler artifacts"
Run-MSBuild $projectPath "/t:Clean" -logFileName "BootstrapClean"
Expand Down
43 changes: 43 additions & 0 deletions eng/test-rebuild.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<#
This script tests that Roslyn artifacts are rebuildable--i.e. that the source code and resources can be identified
#>

[CmdletBinding(PositionalBinding=$false)]
param(
[string]$configuration = "Debug",
[switch]$ci = $false,
[switch]$help)

Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"

function Print-Usage() {
Write-Host "Usage: test-rebuild.ps1"
Write-Host " -configuration Build configuration ('Debug' or 'Release')"
jaredpar marked this conversation as resolved.
Show resolved Hide resolved
Write-Host " -ci Set when running on CI server"
Write-Host " -help Print help and exit"
}

try {
if ($help) {
Print-Usage
exit 0
}

. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $RepoRoot

Write-Host "Building Roslyn"
Exec-Block { & (Join-Path $PSScriptRoot "build.ps1") -restore -build -ci:$ci -configuration:$configuration -pack -binaryLog}
& "artifacts\bin\BuildValidator\$configuration\net472\BuildValidator.exe" --assembliesPath "$ArtifactsDir/obj/Microsoft.CodeAnalysis"
RikkiGibson marked this conversation as resolved.
Show resolved Hide resolved

exit 0
}
catch [exception] {
Write-Host $_
Write-Host $_.Exception
exit 1
}
finally {
Pop-Location
}
12 changes: 7 additions & 5 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2016,11 +2016,13 @@ async partial void M() {}

AssertEx.AssertEqualToleratingWhitespaceDifferences(@"
MethodDebugInformation (index: 0x31, size: 20):
==================================================
1: nil
2: nil
3: nil
4:
================================================
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change (and similar changes in other tests) were required due to the mdv version update.

IL
================================================
1: nil
2: nil
3: nil
4:
{
Kickoff Method: 0x06000001 (MethodDef)
Locals: 0x11000002 (StandAloneSig)
Expand Down
25 changes: 13 additions & 12 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBIteratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,12 +1599,14 @@ public class C

AssertEx.AssertEqualToleratingWhitespaceDifferences(@"
MethodDebugInformation (index: 0x31, size: 40):
==================================================
1: nil
2: nil
3: nil
4: nil
5:
================================================
IL
================================================
1: nil
2: nil
3: nil
4: nil
5:
{
Kickoff Method: 0x06000001 (MethodDef)
Locals: 0x11000001 (StandAloneSig)
Expand All @@ -1615,12 +1617,11 @@ public class C
IL_0030: <hidden>
IL_0037: (5, 44) - (5, 45)
}
6: nil
7: nil
8: nil
9: nil
a: nil
",
6: nil
7: nil
8: nil
9: nil
a: nil",
writer.ToString());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBSourceLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public static void Main()
debugEntryPoint: null,
sourceLinkStream: new MemoryStream(new byte[] { 1, 2, 3 }),
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData()
{
SymWriterFactory = metadataProvider => new SymUnmanagedWriterWithoutSourceLinkSupport(metadataProvider)
Expand Down
4 changes: 4 additions & 0 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public void SymWriterErrors()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = _ => new MockSymUnmanagedWriter() });

result.Diagnostics.Verify(
Expand Down Expand Up @@ -219,6 +220,7 @@ public void SymWriterErrors2()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = SymWriterTestUtilities.ThrowingFactory });

result.Diagnostics.Verify(
Expand Down Expand Up @@ -250,6 +252,7 @@ public void SymWriterErrors3()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = SymWriterTestUtilities.ThrowingFactory });

result.Diagnostics.Verify(
Expand Down Expand Up @@ -281,6 +284,7 @@ public void SymWriterErrors4()
debugEntryPoint: null,
sourceLinkStream: null,
embeddedTexts: null,
pdbOptionsBlobReader: null,
testData: new CompilationTestData() { SymWriterFactory = _ => throw new DllNotFoundException("xxx") });

result.Diagnostics.Verify(
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ private void CompileAndEmit(
peStreamProvider,
refPeStreamProviderOpt,
pdbStreamProviderOpt,
pdbOptionsBlobReader: null,
testSymWriterFactory: null,
diagnostics: diagnostics,
emitOptions: emitOptions,
Expand Down
38 changes: 38 additions & 0 deletions src/Compilers/Core/Portable/Compilation/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,35 @@ public EmitResult Emit(
IEnumerable<EmbeddedText>? embeddedTexts = null,
Stream? metadataPEStream = null,
CancellationToken cancellationToken = default(CancellationToken))
{
return Emit(
peStream,
pdbStream,
xmlDocumentationStream,
win32Resources,
manifestResources,
options,
debugEntryPoint,
sourceLinkStream,
embeddedTexts,
metadataPEStream,
pdbOptionsBlobReader: null,
cancellationToken);
}

internal EmitResult Emit(
Stream peStream,
Stream? pdbStream,
Stream? xmlDocumentationStream,
Stream? win32Resources,
IEnumerable<ResourceDescription>? manifestResources,
EmitOptions? options,
IMethodSymbol? debugEntryPoint,
Stream? sourceLinkStream,
IEnumerable<EmbeddedText>? embeddedTexts,
Stream? metadataPEStream,
BlobReader? pdbOptionsBlobReader,
CancellationToken cancellationToken)
{
if (peStream == null)
{
Expand Down Expand Up @@ -2535,6 +2564,7 @@ public EmitResult Emit(
debugEntryPoint,
sourceLinkStream,
embeddedTexts,
pdbOptionsBlobReader,
testData: null,
cancellationToken: cancellationToken);
}
Expand All @@ -2554,6 +2584,7 @@ internal EmitResult Emit(
IMethodSymbol? debugEntryPoint,
Stream? sourceLinkStream,
IEnumerable<EmbeddedText>? embeddedTexts,
BlobReader? pdbOptionsBlobReader,
CompilationTestData? testData,
CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -2634,6 +2665,7 @@ internal EmitResult Emit(
new SimpleEmitStreamProvider(peStream),
(metadataPEStream != null) ? new SimpleEmitStreamProvider(metadataPEStream) : null,
(pdbStream != null) ? new SimpleEmitStreamProvider(pdbStream) : null,
pdbOptionsBlobReader,
testData?.SymWriterFactory,
diagnostics,
emitOptions: options,
Expand Down Expand Up @@ -2795,6 +2827,7 @@ internal bool SerializeToPeStream(
EmitStreamProvider peStreamProvider,
EmitStreamProvider? metadataPEStreamProvider,
EmitStreamProvider? pdbStreamProvider,
BlobReader? pdbOptionsBlobReader,
Func<ISymWriterMetadataProvider, SymUnmanagedWriter>? testSymWriterFactory,
DiagnosticBag diagnostics,
EmitOptions emitOptions,
Expand Down Expand Up @@ -2868,6 +2901,7 @@ internal bool SerializeToPeStream(
getPortablePdbStream,
nativePdbWriter,
pePdbFilePath,
pdbOptionsBlobReader,
emitOptions.EmitMetadataOnly,
emitOptions.IncludePrivateMembers,
deterministic,
Expand Down Expand Up @@ -2949,6 +2983,7 @@ internal static bool SerializePeToStream(
Func<Stream?>? getPortablePdbStreamOpt,
Cci.PdbWriter? nativePdbWriterOpt,
string? pdbPathOpt,
BlobReader? pdbOptionsBlobReader,
bool metadataOnly,
bool includePrivateMembers,
bool isDeterministic,
Expand All @@ -2966,6 +3001,7 @@ internal static bool SerializePeToStream(
getPeStream,
getPortablePdbStreamOpt,
nativePdbWriterOpt,
pdbOptionsBlobReader,
pdbPathOpt,
metadataOnly,
deterministicPrimaryOutput,
Expand All @@ -2988,6 +3024,7 @@ internal static bool SerializePeToStream(
getMetadataPeStreamOpt,
getPortablePdbStreamOpt: null,
nativePdbWriterOpt: null,
pdbOptionsBlobReader: null,
pdbPathOpt: null,
metadataOnly: true,
isDeterministic: true,
Expand Down Expand Up @@ -3043,6 +3080,7 @@ internal static bool SerializePeToStream(
metadataStream,
ilStream,
(nativePdbWriterOpt == null) ? pdbStream : null,
pdbOptionsBlobReader: null,
out MetadataSizes metadataSizes);

writer.GetMethodTokens(updatedMethods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public abstract class CompilationOptions
/// <summary>
/// Emit mode that favors debuggability.
/// </summary>
internal bool DebugPlusMode { get; private protected set; }
internal bool DebugPlusMode { get; set; }
RikkiGibson marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Specifies whether to import members with accessibility other than public or protected by default.
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/Microsoft.CodeAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<NoStdLib>true</NoStdLib>
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">partial</ApplyNgenOptimization>
<GeneratePerformanceSensitiveAttribute>true</GeneratePerformanceSensitiveAttribute>

<EmbedUntrackedSources>true</EmbedUntrackedSources>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary change correct? The idea being that when we are done with this effort that we will be adding this to Directory.Build.props? If so are we tracking that in an issue, comment, etc ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #51099 to track. There is a bug in wpf temp projects that prevent us from enabling this in Settings.props or Directory.Build.props for now (is one or the other preferred? Directory.Build.props seemed pretty empty.)

I should probably file the bug to get this property fixed with WPF projects. Do you know the right repo to do that in? Maybe @clairernovotny knows? It seems not so bad to exclude those projects from rebuilding for a while though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WPF issues with targets/props and source link should all be fixed by setting IncludePackageReferencesDuringMarkupCompilation to true in the Directory.Build.Props file and using a 5.0.200+ SDK to build. This enables fixes within the WPF targets that are currently opt-out.


<!-- NuGet -->
<IsPackable>true</IsPackable>
<PackageId>Microsoft.CodeAnalysis.Common</PackageId>
Expand Down Expand Up @@ -51,6 +52,7 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator.ExpressionCompiler" />
<InternalsVisibleTo Include="csc" />
<InternalsVisibleTo Include="csi" />
<InternalsVisibleTo Include="BuildValidator" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.Scripting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Scripting" />
Expand Down
Loading