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

Enable PDB archives for source-build #14015

Merged
merged 4 commits into from
Sep 11, 2023

Conversation

NikolaMilosavljevic
Copy link
Member

@NikolaMilosavljevic NikolaMilosavljevic commented Sep 7, 2023

Resolves: dotnet/source-build#3547, dotnet/source-build#3609 and dotnet/source-build#3610

This change enables creation of repo-specific PDB archives, named Symbols.<repo-name>.tar.gz. Archives get included in main source-build intermediate package, and eventually extracted to artifacts/<chip>/<flavor> i.e. artifacts/x64/Release.

New infra collects all PDBs using **\obj\**\*.pdb pattern.

File hierarchy is preserved, which enables archive to contain multiple files with the same name. File hierarchy is rooted in $(CurrentRepoSourceBuildArtifactsDir) except for source-build-externals repo, which uses $(RepoRoot).

Validation VMR build is in progress: https://dev.azure.com/dnceng/internal/_build/results?buildId=2261578&view=results

Example content, from Symbols.sourcelink.tar.gz:

obj/dotnet-sourcelink/Release/net8.0/dotnet-sourcelink.pdb
obj/Microsoft.Build.Tasks.Git/Release/net8.0/Microsoft.Build.Tasks.Git.pdb
obj/Microsoft.SourceLink.AzureDevOpsServer.Git/Release/net8.0/Microsoft.SourceLink.AzureDevOpsServer.Git.pdb
obj/Microsoft.SourceLink.AzureRepos.Git/Release/net8.0/Microsoft.SourceLink.AzureRepos.Git.pdb
obj/Microsoft.SourceLink.Bitbucket.Git/Release/net8.0/Microsoft.SourceLink.Bitbucket.Git.pdb
obj/Microsoft.SourceLink.Common/Release/net8.0/Microsoft.SourceLink.Common.pdb
obj/Microsoft.SourceLink.Gitea/Release/net8.0/Microsoft.SourceLink.Gitea.pdb
obj/Microsoft.SourceLink.Gitee/Release/net8.0/Microsoft.SourceLink.Gitee.pdb
obj/Microsoft.SourceLink.GitHub/Release/net8.0/Microsoft.SourceLink.GitHub.pdb
obj/Microsoft.SourceLink.GitLab/Release/net8.0/Microsoft.SourceLink.GitLab.pdb
obj/Microsoft.SourceLink.GitWeb/Release/net8.0/Microsoft.SourceLink.GitWeb.pdb

Here are some numbers:

Repo Previous intermediate size (MB) Symbols archive (MB) New intermediate size (MB)
arcade 6 0 6
aspnetcore 94 7 101
cecil 0.6 0.3 0.9
command-line-api 0.6 0.3 0.9
deplyment-tools 0.1 0.03 0.13
diagnostics 0.06 0.06 0.12
emsdk 0.04 0 0.04
format 14.4 0.07 14.5
fsharp 109 0 109
installer 203 0 203
msbuild 8.4 3.4 11.8
nuget-client 5.3 1.4 6.7
razor 1 1 2
roslyn 78 41 119
roslyn-analyzers 18.3 3 21.3
runtime - crossgen 256 0 256
runtime - ilcompiler 79 0 79
runtime - main 177 128 305
runtime - runtime 139 0 139
sdk 74.7 2.2 76.9
source-build-externals 3 3 6
source-build-reference-packages 23.5 0 23.5
sourcelink 0.7 0.1 0.8
symreader 0.3 0.06 0.4
templating 1.3 0.6 2
test-templates 0.2 0.004 0.2
vstest 3 0 3
xdt 0.2 0.1 0.3
xliff-tasks 0.1 0.04 0.15
Totals 1297 192 1489

@@ -79,6 +81,48 @@
</ItemGroup>
</Target>

<!-- Discover all repo's symbols that match **\obj\**\*.pdb, to be included in the "main" intermediate nupkg. -->
<Target Name="CreateSymbolsList" Condition="'$(SupplementalIntermediateNupkgCategory)' == ''">
Copy link
Member

Choose a reason for hiding this comment

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

While I appreciate the breaking down of logic into smaller chunks, it feels weird to me that CreateSymbolsList is a separate target whose output is then deleted by another target: CreateSymbolsArchive. It seems like the symbols list is just an implementation detail of the logic to create the archive and doesn't deserve a separate target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is true. It started as a single target which I split into two to simplify conditioning of few tasks (packaging, message, deletion of symbols list) - each task would need its own condition.

However, I see the point and will revert to my original design.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with de9bb57

@NikolaMilosavljevic
Copy link
Member Author

Found a small issue in one of the conditions - it caused few issues: 1) no archive for source-build-externals and 2) unnecessarily longer hierarchy in most packages. Testing the fix locally...

</PropertyGroup>

<ItemGroup>
<AbsoluteSymbolPath Include="$(SymbolsRoot)\**\obj\**\*.pdb" />
Copy link
Member

Choose a reason for hiding this comment

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

Apologies if this is a stupid question, but is there any risk of a not-just-built pdb file being available at this path? Is there any support for posioning pdb files to catch potential leaks?

Copy link
Member Author

Choose a reason for hiding this comment

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

obj folder would contain content of just compiled sources. bin folder would also contain dependencies.

Copy link
Member

@MichaelSimons MichaelSimons left a comment

Choose a reason for hiding this comment

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

Looks good. I'd be curious to see what the size impact is to the current intermediates. I know runtime has run into the 500MB limit AZDO has on individual artifact files.

<SymbolsArchiveLocation>$(CurrentRepoSourceBuildArtifactsPackagesDir)</SymbolsArchiveLocation>
<SymbolsList>$(SymbolsArchiveLocation)\symbols.lst</SymbolsList>
<SymbolsArchivePrefix>Symbols.</SymbolsArchivePrefix>
<SymbolsArchiveName>$(SymbolsArchiveLocation)$(SymbolsArchivePrefix)$(GitHubRepositoryName).tar.gz</SymbolsArchiveName>
Copy link
Member

Choose a reason for hiding this comment

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

Should the symbols tarball include the rid and version like other SB artifacts?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea - will update the name so it matches other artifacts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Source-build intermediate package does not include the Rid, i.e. Microsoft.SourceBuild.Intermediate.sdk.8.0.100-rc.2.23423.14.nupkg

I see that infra is evaluating Rid from current OS, which produces RIDs like linux-x64, so that could be used. But, is there a value - would version be enough?

TargetRID in SourceBuildIntermediate.proj, which is called from AfterSourceBuild.proj, is set to linux-x64.

If we use both version and rid we get this: Symbols.sourcelink.8.0.0-beta.23422.2.linux-x64.tar.gz

Just version: Symbols.sourcelink.8.0.0-beta.23422.2.tar.gz

Related intermediate package: Microsoft.SourceBuild.Intermediate.sourcelink.8.0.0-beta.23422.2.nupkg

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that only runtime and sdk have non-portable RID set in TargetRid property. Other repos use the portable Rid, as we are doing portable source-builds for majority of the repos..

My test build with both version and rid produced the following - naming is inconsistent, but it matches the Rid used for repo's build:

Symbols.aspnetcore.8.0.0-rc.2.23423.7.linux-x64.tar.gz
Symbols.cecil.0.11.4.0-alpha.23407.2.linux-x64.tar.gz
Symbols.command-line-api.0.1.435601.linux-x64.tar.gz
Symbols.deployment-tools.8.0.0-preview.6.23407.1.linux-x64.tar.gz
Symbols.diagnostics.7.0.0-preview.23211.1.linux-x64.tar.gz
Symbols.format.8.0.442201.linux-x64.tar.gz
Symbols.msbuild.17.8.0-preview-23424-01.linux-x64.tar.gz
Symbols.nuget-client.1.0.0-preview.23424.1.linux-x64.tar.gz
Symbols.razor.7.0.0-preview.23423.3.linux-x64.tar.gz
Symbols.roslyn-analyzers.3.11.0-beta1.23420.2.linux-x64.tar.gz
Symbols.roslyn.4.8.0-2.23423.10.linux-x64.tar.gz
Symbols.runtime.8.0.0-rc.2.23418.14.fedora.36-x64.tar.gz
Symbols.sdk.8.0.100-rc.2.23423.14.fedora.36-x64.tar.gz
Symbols.source-build-externals.8.0.0-alpha.1.23421.1.linux-x64.tar.gz
Symbols.sourcelink.8.0.0-beta.23422.2.linux-x64.tar.gz
Symbols.symreader.2.1.0-beta.23253.1.linux-x64.tar.gz
Symbols.templating.8.0.100-rc.2.23423.2.linux-x64.tar.gz
Symbols.test-templates.1.1.0-rc.23410.2.linux-x64.tar.gz
Symbols.xdt.7.0.0-preview.22423.2.linux-x64.tar.gz
Symbols.xliff-tasks.1.0.0-beta.23418.1.linux-x64.tar.gz

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with e41ac2f


<ItemGroup>
<AbsoluteSymbolPath Include="$(SymbolsRoot)\**\obj\**\*.pdb" />
<RelativeSymbolPath Include="@(AbsoluteSymbolPath)" Condition="'@(AbsoluteSymbolPath)' != ''">
Copy link
Member

Choose a reason for hiding this comment

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

Curious if this can be achieved in one ItemGroup

$([MSBuild]::MakeRelative($(SymbolsRoot), %(FullPath)))

Copy link
Member Author

Choose a reason for hiding this comment

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

Will test it out - thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

We can do something like this:

      <AbsoluteSymbolPath Include="$(SymbolsRoot)\**\obj\**\*.pdb" />
      <AbsoluteSymbolPath Update="@(AbsoluteSymbolPath)" Condition="'@(AbsoluteSymbolPath)' != ''">
        <RelativePath>$([MSBuild]::MakeRelative($(SymbolsRoot), %(FullPath)))</RelativePath>
      </AbsoluteSymbolPath>

It removes one ItemGroup.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with e41ac2f

</PropertyGroup>

<ItemGroup>
<AbsoluteSymbolPath Include="$(SymbolsRoot)\**\obj\**\*.pdb" />
Copy link
Member

Choose a reason for hiding this comment

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

I typically seem ItemGroups name in plural form as the are a type of collection. e.g. AbsoluteSymbolPaths

Copy link
Member Author

Choose a reason for hiding this comment

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

I've seen both plural and singular in use and can't seem to find any guidance for .NET codebase. It appears that even source-build infra is inconsistent, i.e.

Singular:

<IntermediateNupkgArtifactFile Include="$(CurrentRepoSourceBuildArtifactsPackagesDir)**\*.nupkg" />

<Content Include="@(IntermediatePackageFile->WithMetadataValue('Category', '$(SupplementalIntermediateNupkgCategory)'))" />

Plural:

<SourceBuildFilesToCopy Include="$(RepoRoot)/**/*" />

<SourceBuiltPackageFiles Include="$(CurrentRepoSourceBuiltNupkgCacheDir)**/*.nupkg" />

Copy link
Member

Choose a reason for hiding this comment

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

I acknowledge there are inconsistencies in the code base. I asked to see if you had reasons for using singular. I personally find the plural form can help the readability therefore tend to favor that form as a general rule.

@NikolaMilosavljevic
Copy link
Member Author

Looks good. I'd be curious to see what the size impact is to the current intermediates. I know runtime has run into the 500MB limit AZDO has on individual artifact files.

Added the relevant data to main comment.

@NikolaMilosavljevic
Copy link
Member Author

Found a small issue in one of the conditions - it caused few issues: 1) no archive for source-build-externals and 2) unnecessarily longer hierarchy in most packages. Testing the fix locally...

This is now fixed. I've updated the initial comment with updated symbols paths in archive packages and added all relevant numbers for intermediate and symbols archive sizes.

mthalman
mthalman previously approved these changes Sep 8, 2023
Copy link
Member

@mthalman mthalman left a comment

Choose a reason for hiding this comment

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

We want this for .NET 8, right? It's easier to just target release/8.0.1xx first and, once it's merged, it will then automatically be ported to main branch.

@NikolaMilosavljevic
Copy link
Member Author

We want this for .NET 8, right? It's easier to just target release/8.0.1xx first and, once it's merged, it will then automatically be ported to main branch.

Arcade repo doesn't have any 8.0-specific branch, they flow their main branch to installer's release/8.0.1xx branch; e.g. dotnet/installer#17293

I'm going to make a small update to this PR to address 2 of @MichaelSimons comments.

@NikolaMilosavljevic NikolaMilosavljevic merged commit 2bcf51c into dotnet:main Sep 11, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pdb files with .NET 8
4 participants