Skip to content

Commit

Permalink
Crossgen2 cross target testing (dotnet#42663)
Browse files Browse the repository at this point in the history
Add cross compilation testing for crossgen2.

The goal here is to cover cross compilation for the framework libraries, with support for testing cross compilation behavior between across the large swath of possible cross target possibilities.

This testing is added to the crossgen2 outerloop and is based on the work that @echesakovMSFT built for crossgen1 for cross target support for Linux X64 to Linux Arm. (The testing model has been tweaked to allow for general purpose cross target testing.)

Important details.

There is now a cross targeting build job, which builds (on either X64 Windows or X64 Linux) the framework dlls for a given target architecture, and captures their SHA1 hashes.

Then there is a comparison job which will run crossgen2 on an arbitrary set of platforms targetting a specific OS/Architecture pair. 

The current state is that is known that the x86 compiler does not quite produce identical output when varied between 64 and 32 bit, there are significant issues compiling arm32 code, and arm64 code is nearly perfect with cross compilation.
  • Loading branch information
davidwrighton authored Oct 2, 2020
1 parent 74fe95b commit 332f118
Show file tree
Hide file tree
Showing 4 changed files with 1,366 additions and 1 deletion.
131 changes: 130 additions & 1 deletion eng/pipelines/coreclr/crossgen2-outerloop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/build-coreclr-and-libraries-job.yml
jobTemplate: /eng/pipelines/coreclr/templates/build-job.yml
buildConfig: checked
platforms:
- Linux_x64
Expand All @@ -30,6 +30,36 @@ jobs:
jobParameters:
testGroup: outerloop

- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/build-job.yml
buildConfig: Release
platforms:
- Linux_arm
- Linux_arm64
- Linux_x64
- Windows_NT_x86
- Windows_NT_x64
jobParameters:
testGroup: outerloop

- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/libraries/build-job.yml
buildConfig: Release
platforms:
- Linux_arm
- Linux_arm64
- Linux_x64
- OSX_x64
- Windows_NT_x86
- Windows_NT_x64
- Windows_NT_arm64
- CoreClrTestBuildHost # Either OSX_x64 or Linux_x64
jobParameters:
isOfficialBuild: false
liveRuntimeBuildConfig: Release

- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/templates/runtimes/build-test-job.yml
Expand Down Expand Up @@ -74,3 +104,102 @@ jobs:
crossgen2: true
displayNameArgs: R2R_CG2
liveLibrariesBuildConfig: Release

# Build Crossgen2 baselines
# These are the various crossgen2 targets that are supported, and cover all major
# significantly different code generators
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/crossgen2-comparison-build-job.yml
buildConfig: Release
platforms:
- Linux_arm
- Linux_arm64
- Linux_x64
- Windows_NT_x86
- Windows_NT_x64
jobParameters:
testGroup: outerloop
liveLibrariesBuildConfig: Release

# test crossgen target Windows X86
# This job verifies that 32-bit and 64 bit crossgen2 produces the same binaries,
# and that cross-os targetting works
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/crossgen2-comparison-job.yml
buildConfig: Release
platforms:
- Linux_x64
- Windows_NT_x86
helixQueueGroup: pr
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
jobParameters:
testGroup: outerloop
liveLibrariesBuildConfig: Release
targetos: Windows_NT
targetarch: x86

# test target Linux X64
# verify that cross OS targetting works
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/crossgen2-comparison-job.yml
buildConfig: Release
platforms:
- Windows_NT_x64
helixQueueGroup: pr
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
jobParameters:
testGroup: outerloop
liveLibrariesBuildConfig: Release
targetos: Linux
targetarch: x64

# test target Windows X64
# verify that cross OS targetting works
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/crossgen2-comparison-job.yml
buildConfig: Release
platforms:
- Linux_x64
helixQueueGroup: pr
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
jobParameters:
testGroup: outerloop
liveLibrariesBuildConfig: Release
targetos: Windows_NT
targetarch: x64

# test target Linux arm
# verify that cross architecture targetting works
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/crossgen2-comparison-job.yml
buildConfig: Release
platforms:
- Linux_arm
helixQueueGroup: pr
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
jobParameters:
testGroup: outerloop
liveLibrariesBuildConfig: Release
targetos: Linux
targetarch: arm

# test target Linux arm64
# verify that cross architecture targetting works
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/coreclr/templates/crossgen2-comparison-job.yml
buildConfig: Release
platforms:
- Linux_arm64
helixQueueGroup: pr
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
jobParameters:
testGroup: outerloop
liveLibrariesBuildConfig: Release
targetos: Linux
targetarch: arm64
169 changes: 169 additions & 0 deletions eng/pipelines/coreclr/templates/crossgen2-comparison-build-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
parameters:
buildConfig: ''
archType: ''
osGroup: ''
osSubgroup: ''
container: ''
helixQueues: ''
runtimeVariant: ''
crossrootfsDir: ''
stagedBuild: false
variables: {}
pool: ''

# When set to a non-empty value (Debug / Release), it determines libraries
# build configuration to use for the tests. Setting this property implies
# a dependency of this job on the appropriate libraries build and is used
# to construct the name of the Azure artifact representing libraries build
# to use for building the tests.
liveLibrariesBuildConfig: ''

### Crossgen-comparison build job
###
### Ensure that the output of cross-architecture, e.g. x64-hosted-arm-targeting,
### crossgen matches that of native, e.g. arm-hosted-arm-targeting, crossgen.

jobs:
- template: xplat-pipeline-job.yml
parameters:
buildConfig: ${{ parameters.buildConfig }}
archType: ${{ parameters.archType }}
osGroup: ${{ parameters.osGroup }}
osSubgroup: ${{ parameters.osSubgroup }}
stagedBuild: ${{ parameters.stagedBuild }}
runtimeVariant: ${{ parameters.runtimeVariant }}
liveLibrariesBuildConfig: ${{ parameters.liveLibrariesBuildConfig }}
helixType: 'test/crossgen-comparison/'
pool: ${{ parameters.pool }}

# Compute job name from template parameters
name: ${{ format('test_crossgen2_comparison_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
displayName: ${{ format('Test crossgen2-comparison build {0}{1} {2} {3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}

crossrootfsDir: ${{ parameters.crossrootfsDir }}

variables:
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
- group: DotNet-HelixApi-Access
- name: hostArchType
value: x64
- name: targetFlavor
value: $(osGroup).$(archType).$(buildConfigUpper)
- name: crossFlavor
value: $(osGroup).$(hostArchType)_$(archType).$(buildConfigUpper)
- name: artifactsDirectory
value: $(Build.SourcesDirectory)$(dir)artifacts
- name: binDirectory
value: $(artifactsDirectory)$(dir)bin
- name: productDirectory
value: $(binDirectory)$(dir)coreclr
- name: workItemDirectory
value: $(artifactsDirectory)$(dir)tests$(dir)coreclr$(dir)$(targetFlavor)$(dir)Tests$(dir)CrossCompileRoot
- name: crossgencompare_build_artifact
value: crossgen_comparison_build_$(osGroup)$(osSubgroup)_$(archType)
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
- name: target_crossgen2_os
value: windows
- ${{ if eq(parameters.osGroup, 'Linux') }}:
- name: target_crossgen2_os
value: linux
- ${{ if eq(parameters.osGroup, 'OSX') }}:
- name: target_crossgen2_os
value: osx
- name: crossgen2location
value: $(productDirectory)$(dir)$(targetFlavor)$(dir)crossgen2$(dir)crossgen2.dll
- ${{ if ne(parameters.archType, 'x64') }}:
- name: crossgen2location
value: $(productDirectory)$(dir)$(targetFlavor)$(dir)x64$(dir)crossgen2$(dir)crossgen2.dll
- name: librariesProductDllDir
value: $(Build.SourcesDirectory)$(dir)artifacts$(dir)bin$(dir)runtime$(dir)net5.0-$(osGroup)$(osSubgroup)-$(buildConfig)-$(archType)

- ${{ parameters.variables }}

# Test job depends on the corresponding build job
dependsOn:
- ${{ format('coreclr_{0}_product_build_{1}{2}_{3}_{4}', parameters.runtimeVariant, parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.buildConfig) }}
- ${{ if ne(parameters.liveLibrariesBuildConfig, '') }}:
- ${{ format('libraries_build_{0}{1}_{2}_{3}', parameters.osGroup, parameters.osSubgroup, parameters.archType, parameters.liveLibrariesBuildConfig) }}

# Run all steps in the container.
# Note that the containers are defined in platform-matrix.yml
container: ${{ parameters.container }}
timeoutInMinutes: 180 # 3 hrs

steps:

# Download product build
- template: /eng/pipelines/common/download-artifact-step.yml
parameters:
unpackFolder: $(buildProductRootFolderPath)
artifactFileName: '$(buildProductArtifactName)$(archiveExtension)'
artifactName: '$(buildProductArtifactName)'
displayName: 'product build'

# Optionally download live-built libraries
- ${{ if ne(parameters.liveLibrariesBuildConfig, '') }}:
- template: /eng/pipelines/common/download-artifact-step.yml
parameters:
unpackFolder: $(librariesDownloadDir)
cleanUnpackFolder: false
artifactFileName: '$(librariesBuildArtifactName)$(archiveExtension)'
artifactName: '$(librariesBuildArtifactName)'
displayName: 'live-built libraries'

# Populate Core_Root
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(buildConfig) $(archType) $(crossArg) generatelayoutonly
displayName: Populate Core_Root

# Create work item directory and populate with assemblies
- ${{ if ne(parameters.osGroup, 'Windows_NT') }}:
- script: |
mkdir -p $(workItemDirectory)
mkdir -p $(workItemDirectory)/log
mkdir -p $(workItemDirectory)/dlls
cp $(librariesProductDllDir)/* $(workItemDirectory)/dlls
cp $(productDirectory)/$(targetFlavor)/IL/System.Private.CoreLib.dll $(workItemDirectory)/dlls
displayName: Create directories
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
- script: |
md $(workItemDirectory)\log
md $(workItemDirectory)\dlls
echo copy $(librariesProductDllDir)\* $(workItemDirectory)\dlls
copy $(librariesProductDllDir)\* $(workItemDirectory)\dlls
echo copy $(productDirectory)\$(targetFlavor)\IL\System.Private.CoreLib.dll $(workItemDirectory)\dlls
copy $(productDirectory)\$(targetFlavor)\IL\System.Private.CoreLib.dll $(workItemDirectory)\dlls
displayName: Create directories

# Create baseline output on the host (x64) machine
- task: PythonScript@0
displayName: Create cross-platform crossgen baseline
inputs:
scriptSource: 'filePath'
scriptPath: $(Build.SourcesDirectory)/src/tests/Common/scripts/crossgen2_comparison.py
${{ if ne(parameters.osGroup, 'Windows_NT') }}:
pythonInterpreter: /usr/bin/python3
arguments:
crossgen_framework
--crossgen $(crossgen2location)
--dotnet $(Build.SourcesDirectory)/dotnet.sh
--core_root $(workItemDirectory)/dlls
--result_dir $(workItemDirectory)/log
--target_os $(target_crossgen2_os)
--target_arch $(archType)
${{ if eq(parameters.osGroup, 'Windows_NT') }}:
arguments:
crossgen_framework
--crossgen $(crossgen2location)
--dotnet $(Build.SourcesDirectory)\dotnet.cmd
--core_root $(workItemDirectory)\dlls
--result_dir $(workItemDirectory)\log
--target_os $(target_crossgen2_os)
--target_arch $(archType)

- task: PublishPipelineArtifact@1
displayName: Publish cross compiled component
inputs:
targetPath: $(workItemDirectory)
artifactName: $(crossgencompare_build_artifact)
continueOnError: true
condition: always()
Loading

0 comments on commit 332f118

Please sign in to comment.