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

Change how we build the cross-OS DAC to support building in the VMR #111927

Merged
merged 11 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions eng/DotNetBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<InnerBuildArgs Condition="'$(DotNetBuildMonoBundleLLVMOptimizer)' != ''">$(InnerBuildArgs) /p:MonoBundleLLVMOptimizer=$(DotNetBuildMonoBundleLLVMOptimizer)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildMonoCrossAOT)' != ''">$(InnerBuildArgs) /p:DotNetBuildMonoCrossAOT=$(DotNetBuildMonoCrossAOT)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildAllRuntimePacks)' != ''">$(InnerBuildArgs) /p:DotNetBuildAllRuntimePacks=$(DotNetBuildAllRuntimePacks)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildPass)' != ''">$(InnerBuildArgs) /p:DotNetBuildPass=$(DotNetBuildPass)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(PgoInstrument)' == 'true'">$(InnerBuildArgs) $(FlagParameterPrefix)pgoinstrument</InnerBuildArgs>

<!-- This prop needs to be passed to the inner build manually as the BaseInnerSourceBuildCommand gets overridden above -->
Expand All @@ -89,6 +90,7 @@
<InnerBuildArgs Condition="'$(RestoreConfigFile)' != ''">$(InnerBuildArgs) /p:RestoreConfigFile=$(RestoreConfigFile)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(ForceDryRunSigning)' != ''">$(InnerBuildArgs) /p:ForceDryRunSigning=$(ForceDryRunSigning)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DefaultArtifactVisibility)' != ''">$(InnerBuildArgs) /p:DefaultArtifactVisibility=$(DefaultArtifactVisibility)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetEsrpToolPath)' != ''">$(InnerBuildArgs) /p:DotNetEsrpToolPath=$(DotNetEsrpToolPath)</InnerBuildArgs>

<!-- Pass locations for assets, packages and symbols -->
<InnerBuildArgs Condition="'$(SourceBuiltAssetsDir)' != ''">$(InnerBuildArgs) /p:SourceBuiltAssetsDir=$(SourceBuiltAssetsDir)</InnerBuildArgs>
Expand Down
11 changes: 7 additions & 4 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<DefaultSubsets Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(PrimaryRuntimeFlavor)' != 'Mono'">clr+libs+tools+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(DotNetBuildRuntimeNativeAOTRuntimePack)' == 'true'">clr.nativeaotlibs+clr.nativeaotruntime+libs+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(DotNetBuildMonoCrossAOT)' == 'true'">mono+packs</DefaultSubsets>

<!-- In the Win-x86 BuildPass2 job in the VMR, we want to build the cross-OS DACs and pack them. -->
<DefaultSubsets Condition="'$(DotNetBuildPass)' == '2' and '$(TargetRid)' == 'win-x86'">crossdacpack</DefaultSubsets>
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<PropertyGroup>
Expand All @@ -85,7 +88,7 @@
<_subset Condition="'$(Subset)' != ''">+$(Subset.ToLowerInvariant())+</_subset>
<_subset Condition="'$(Subset)' == ''">+$(DefaultSubsets)+</_subset>
</PropertyGroup>


<PropertyGroup Condition="'$(RuntimeFlavor)' == ''">
<RuntimeFlavor Condition="('$(TargetsMobile)' == 'true' or '$(TargetsLinuxBionic)' == 'true') and ($(_subset.Contains('+clr.nativeaotlibs+')) or $(_subset.Contains('+clr.runtime+')))">CoreCLR</RuntimeFlavor>
Expand All @@ -96,8 +99,8 @@
</PropertyGroup>

<PropertyGroup>
<DefaultCoreClrSubsets>clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native</DefaultCoreClrSubsets>
<DefaultCoreClrSubsets Condition="'$(PackageRID)' == 'linux-armel'">clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
<DefaultCoreClrSubsets>clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native</DefaultCoreClrSubsets>
<DefaultCoreClrSubsets Condition="'$(PackageRID)' == 'linux-armel'">clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
<!-- Even on platforms that do not support the CoreCLR runtime, we still want to build ilasm/ildasm. -->
<DefaultCoreClrSubsets Condition="'$(RuntimeFlavor)' != 'CoreCLR'">clr.iltools+clr.packages</DefaultCoreClrSubsets>

Expand Down Expand Up @@ -195,7 +198,7 @@
<SubsetName Include="Clr.Tools" Description="Managed tools that support CoreCLR development and testing." />
<SubsetName Include="Clr.ToolsTests" OnDemand="true" Description="Unit tests for the clr.tools subset." />
<SubsetName Include="Clr.Packages" Description="The projects that produce NuGet packages for the CoreCLR runtime, crossgen, and IL tools." />
<SubsetName Include="LinuxDac" Condition="$([MSBuild]::IsOsPlatform(Windows))" Description="The cross-OS Windows->libc-based Linux DAC. Skipped on x86." />
<SubsetName Include="LinuxDac" Condition="$([MSBuild]::IsOsPlatform(Windows))" OnDemand="true" Description="The cross-OS Windows->libc-based Linux DAC. Skipped on x86." />
<SubsetName Include="AlpineDac" Condition="$([MSBuild]::IsOsPlatform(Windows))" OnDemand="true" Description="The cross-OS Windows->musl-libc-based Linux DAC. Skipped on x86" />
<SubsetName Include="CrossDacPack" OnDemand="true"
Description="Packaging of cross OS DAC. Requires all assets needed to be present at a folder specified by $(CrossDacArtifactsDir). See 'Microsoft.CrossOsDiag.Private.CoreCLR.proj' for details." />
Expand Down
25 changes: 25 additions & 0 deletions eng/extract-for-crossdac.ps1
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$DownloadDirectory,
[Parameter(Mandatory)]
[string]
$ExtractDirectory
)

Add-Type -Assembly 'System.IO.Compression.FileSystem'

Write-Host "Looking for packages under $DownloadDirectory"

foreach ($file in Get-ChildItem $DownloadDirectory -Recurse -Filter '*.nupkg') {
Write-Host "Found Package: $($file.FullName)"
if ($file.Name -match '^(?<id>Microsoft.NETCore.App.Runtime.linux(-musl)?-((arm(64)?)|x64)).(?<ver>.+).nupkg$') {
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved
$id = $matches['id']
$ver = $matches['ver']
Write-Host "Extracting Package: $id $ver to $ExtractDirectory/$($id.ToLowerInvariant())/$ver"
[System.IO.Compression.ZipFile]::ExtractToDirectory($file.FullName, "$ExtractDirectory/$($id.ToLowerInvariant())/$ver")
} else {
throw "Unexpected file name: $($file.Name)"
}
}
12 changes: 9 additions & 3 deletions eng/native/sign-with-dac-certificate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ param(
[Parameter(ValueFromRemainingArguments=$true)][string[]]$filesToSign
)

$inputFile = Get-Content -Raw $PSScriptRoot/signing/input.template.json | ConvertFrom-Json
$inputFile.SignBatches.SignRequestFiles = $filesToSign | ForEach-Object {
[array]$signEntries = $filesToSign | ForEach-Object {
@{
SourceLocation = $_
}
}

$inputFile = Get-Content -Raw $PSScriptRoot/signing/input.template.json | ConvertFrom-Json
$inputFile.SignBatches[0].SignRequestFiles = $signEntries

$inputJson = [System.IO.Path]::GetTempFileName()
# Our JSON goes up to 6 levels deep, so we need to set the depth to 6
# to successfully round-trip our JSON through ConvertTo-Json
$inputFile | ConvertTo-Json -Depth 6 | Out-File -FilePath $inputJson -Encoding utf8

$outputJson = Resolve-Path "$PSScriptRoot/../../artifacts/log/Release/signing-$(New-Guid).json.log"
$outputJson = "$PSScriptRoot/../../artifacts/log/Release/signing-$(New-Guid).json.log"

New-Item $outputJson -ItemType File

$outputJson = Resolve-Path $outputJson

Write-Host "Signing files with DAC certificate"
Write-Host "Logging output to $outputJson"
Expand Down
9 changes: 0 additions & 9 deletions eng/pipelines/coreclr/templates/crossdac-hostarch.yml

This file was deleted.

18 changes: 6 additions & 12 deletions eng/pipelines/coreclr/templates/install-diagnostic-certs.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
parameters:
isOfficialBuild:
type: boolean
displayName: 'Is Official Build'
certNames:
type: array
displayName: 'Certificate Name'
vaultName:
type: string
displayName: 'Key Vault Name'
azureSubscription:
type: string
displayName: 'Azure Subscription'
isOfficialBuild: false
certNames: []
vaultName: ''
azureSubscription: ''
scriptRoot: '$(Build.SourcesDirectory)'

steps:
- ${{ if and(eq(parameters.isOfficialBuild, true), ne(variables['Build.Reason'], 'PullRequest'), or(startswith(variables['Build.SourceBranch'], 'refs/heads/release/'), startswith(variables['Build.SourceBranch'], 'refs/heads/internal/release/'), startswith(variables['Build.SourceBranch'], 'refs/heads/reltest/')), not(endsWith(variables['Build.SourceBranch'], '-staging'))) }}:
Expand All @@ -29,6 +22,7 @@ steps:
$signArgs = '/p:DotNetEsrpToolPath=$(esrpclient.toolpath)\$(esrpclient.toolname)'
echo "##vso[task.setvariable variable=_SignDiagnosticFilesArgs;]$signArgs"
displayName: 'Install diagnostic certificates'
workingDirectory: ${{ parameters.scriptRoot }}
env:
${{ each cert in parameters.certNames }}:
${{ cert }}: $(${{ cert }})
6 changes: 3 additions & 3 deletions eng/pipelines/coreclr/templates/remove-diagnostic-certs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
parameters:
isOfficialBuild:
type: boolean
displayName: 'Is Official Build'
isOfficialBuild: false
scriptRoot: '$(Build.SourcesDirectory)'

steps:
- ${{ if and(eq(parameters.isOfficialBuild, true), ne(variables['Build.Reason'], 'PullRequest'), or(startswith(variables['Build.SourceBranch'], 'refs/heads/release/'), startswith(variables['Build.SourceBranch'], 'refs/heads/internal/release/'), startswith(variables['Build.SourceBranch'], 'refs/heads/reltest/')), not(endsWith(variables['Build.SourceBranch'], '-staging'))) }}:
- powershell: |
eng/pipelines/remove-diagnostic-certs.ps1 "$(DacCertificateThumbprints)"
workingDirectory: ${{ parameters.scriptRoot }}
displayName: 'Remove Diagnostic Certificates'
condition: always()
57 changes: 15 additions & 42 deletions eng/pipelines/runtime-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ extends:

#
# Build all runtime packs for Linux and Linux musl
# Upload CoreCLR runtime for CrossDac packaging
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
Expand All @@ -171,26 +170,10 @@ extends:
isOfficialBuild: ${{ variables.isOfficialBuild }}
timeoutInMinutes: 120
postBuildSteps:
# Upload libcoreclr.so for CrossDac packaging
- task: CopyFiles@2
displayName: Gather runtime for CrossDac
inputs:
SourceFolder: $(Build.SourcesDirectory)/artifacts/bin/coreclr/$(osGroup).$(archType).$(_BuildConfig)
Contents: libcoreclr.so
TargetFolder: $(Build.SourcesDirectory)/artifacts/CoreCLRCrossDacArtifacts/$(osGroup)$(osSubgroup).$(archType).$(_BuildConfig)/$(crossDacHostArch)
- task: 1ES.PublishBuildArtifacts@1
displayName: Publish runtime for CrossDac
inputs:
PathtoPublish: $(Build.SourcesDirectory)/artifacts/CoreCLRCrossDacArtifacts
PublishLocation: Container
ArtifactName: CoreCLRCrossDacArtifacts

# Upload the results.
- template: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
parameters:
name: $(osGroup)$(osSubgroup)_$(archType)
extraVariablesTemplates:
- template: /eng/pipelines/coreclr/templates/crossdac-hostarch.yml

#
# Build and Pack CrossDac
Expand All @@ -203,17 +186,21 @@ extends:
- windows_x64
jobParameters:
templatePath: 'templates-official'
buildArgs: -s crossdacpack -c $(_BuildConfig) /p:CrossDacArtifactsDir=$(crossDacArtifactsPath)
buildArgs: -s crossdacpack -c $(_BuildConfig) /p:CrossRuntimeExtractionRoot=$(CrossRuntimeExtractionRoot) $(_SignDiagnosticFilesArgs)
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved
nameSuffix: CrossDac
isOfficialBuild: ${{ variables.isOfficialBuild }}
timeoutInMinutes: 120
preBuildSteps:
- task: DownloadBuildArtifacts@0
displayName: Download Runtimes for CrossDac packaging
- task: DownloadPipelineArtifact@2
displayName: Download runtime packs for CrossDac
inputs:
artifactName: $(crossDacArtifactsContainer)
downloadPath: $(crossDacArtifactsBasePath)
checkDownloadedFiles: true
artifact: 'IntermediateArtifacts'
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved
path: $(Build.SourcesDirectory)/artifacts/RuntimeDownload
patterns: |
IntermediateArtifacts/linux_*/Shipping/Microsoft.NETCore.App.Runtime.linux-*.nupkg
!IntermediateArtifacts/linux_*/Shipping/Microsoft.NETCore.App.Runtime.linux-*.symbols.nupkg
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved
- powershell: $(Build.SourcesDirectory)/eng/extract-for-crossdac.ps1 -DownloadDirectory $(Build.SourcesDirectory)/artifacts/RuntimeDownload -ExtractDirectory $(CrossRuntimeExtractionRoot)
displayName: Extract runtime packs
- template: /eng/pipelines/coreclr/templates/install-diagnostic-certs.yml
parameters:
isOfficialBuild: ${{ variables.isOfficialBuild }}
Expand All @@ -222,22 +209,10 @@ extends:
- 'dotnet-diagnostics-esrp-pki-onecert'
vaultName: 'clrdiag-esrp-id'
azureSubscription: 'diagnostics-esrp-kvcertuser'
- template: /eng/pipelines/common/templates/global-build-step.yml
parameters:
buildArgs: -s linuxdac+alpinedac -c $(_BuildConfig) $(_SignDiagnosticFilesArgs)
archParameter: -arch x64,x86,arm,arm64
postBuildSteps:
- template: /eng/pipelines/coreclr/templates/remove-diagnostic-certs.yml
parameters:
isOfficialBuild: ${{ variables.isOfficialBuild }}
- task: CopyFiles@2
displayName: Gather CrossDacs
inputs:
SourceFolder: $(Build.SourcesDirectory)/artifacts/bin/coreclr
Contents: |
**
!**\sharedFramework\**
TargetFolder: $(crossDacArtifactsPath)
postBuildSteps:
# Save packages using the prepare-signed-artifacts format.
# CrossDac packages are expected to be in the windows_x64 folder.
- template: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
Expand All @@ -251,12 +226,10 @@ extends:
- build_linux_musl_arm_release_AllRuntimes
- build_linux_musl_arm64_release_AllRuntimes
variables:
- name: crossDacArtifactsContainer
value: CoreCLRCrossDacArtifacts
- name: crossDacArtifactsBasePath
value: $(Build.StagingDirectory)/CrossDac
- name: crossDacArtifactsPath
value: $(crossDacArtifactsBasePath)/$(crossDacArtifactsContainer)
- name: CrossRuntimeExtractionRoot
value: $(Build.SourcesDirectory)/artifacts/CrossDac
- name: _SignDiagnosticFilesArgs
value: ''

#
# Build All runtime packs for mobile platforms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
<IsShipping>false</IsShipping>
<CreatePackedPackage>false</CreatePackedPackage>
<PackageDescription>Private transport package for .NET Core cross OS diagnostic tooling.</PackageDescription>
<CrossDacArtifactsDir>$(ArtifactsBinDir)/coreclr/$(CrossDacOutputDir)</CrossDacArtifactsDir>
hoyosjs marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
<!-- Intentional rather than globbing here, even if very manual, to make sure we publish the Cross OS Dac -->
<NativeBinary Include="$(CrossDacBinRoot)/mscordaccore.dll" />
<NativeBinary Include="$(CrossDacBinRoot)/mscordbi.dll" />
<NativeBinary Include="$(CrossDacArtifactsDir)/mscordaccore.dll" />
<NativeBinary Include="$(CrossDacArtifactsDir)/mscordbi.dll" />
<!-- The infrastructure, and this package is only for indexing. Avoid creating a transport package and just let this one have the symbols itself -->
<File Include="@(NativeBinary -> '%(RootDir)%(Directory)/%(Filename).pdb')">
<TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
</File>

<NativeBinary Include="$(CrossDacBinRoot)/libcoreclr.so" />
<NativeBinary Include="$(CoreCLRRuntimePath)/libcoreclr.so" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
Expand Down
Loading
Loading