Skip to content

Commit

Permalink
WIP: Initial implementation of Crossgen2 CI pipeline, take dotnet#3
Browse files Browse the repository at this point in the history
I have refactored my Crossgen2 CI pipeline change to not use
SuperIlc for framework compilation. I intend to introduce that at a
later time to basically simplify the change and make it easier to
review and test.

Thanks

Tomas
  • Loading branch information
trylek committed Oct 29, 2019
1 parent ff7c12c commit 8502a0a
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 154 deletions.
32 changes: 29 additions & 3 deletions build-test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set __SkipNative=
set __RuntimeId=
set __TargetsWindows=1
set __DoCrossgen=
set __DoCrossgen2=
set __CopyNativeTestBinaries=0
set __CopyNativeProjectsAfterCombinedTestBuild=true
set __SkipGenerateLayout=0
Expand Down Expand Up @@ -92,6 +93,7 @@ if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&se
if /i "%1" == "buildagainstpackages" (echo error: Remove /BuildAgainstPackages switch&&exit /b1)
if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "crossgen2" (set __DoCrossgen2=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
if /i "%1" == "targetsNonWindows" (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "Exclude" (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
Expand Down Expand Up @@ -526,6 +528,17 @@ if defined __DoCrossgen (
)
)

if defined __DoCrossgen2 (
set __CrossgenArg="/p:Crossgen2=true"
if "%__BuildArch%" == "x64" (
echo %__MsgPrefix%Running crossgen2 on framework assemblies
call :PrecompileFX
) else (
echo "%__MsgPrefix%Crossgen2 only supported on x64, for now"
)
)


rd /s /q "%CORE_ROOT_STAGE%"

REM =========================================================================================
Expand Down Expand Up @@ -614,9 +627,22 @@ echo "%2" | findstr /b "xunit." >nul && (
set __CrossgenExe="%CORE_ROOT_STAGE%\crossgen.exe"
if /i "%__BuildArch%" == "arm" ( set __CrossgenExe="%CORE_ROOT_STAGE%\x86\crossgen.exe" )
if /i "%__BuildArch%" == "arm64" ( set __CrossgenExe="%CORE_ROOT_STAGE%\x64\crossgen.exe" )
set __CrossgenExe=%__CrossgenExe%

if defined __DoCrossgen2 (
set __CrossgenExe="%CORE_ROOT_STAGE%\crossgen2\crossgen2.exe"
)

set __CrossgenOutputFile="%CORE_ROOT%\temp.ni.dll"

if defined __Crossgen (
"!__CrossgenExe!" /Platform_Assemblies_Paths "!CORE_ROOT!" /in "%1" /out "!__CrossgenOutputFile" >nul 2>nul
set /a __exitCode = !errorlevel!
) else (
"!CORE_ROOT_STAGE!\crossgen2\crossgen2 -r:"!CORE_ROOT!\*.dll" -O --inputbubble -out:"__CrossgenOutputFile" "%1" >nul 2>nul
set /a __exitCode = !errorlevel!
)

"%__CrossgenExe%" /Platform_Assemblies_Paths "%CORE_ROOT%" /in "%1" /out "%CORE_ROOT%/temp.ni.dll" >nul 2>nul
set /a __exitCode = %errorlevel%
if "%__exitCode%" == "-2146230517" (
echo %2 is not a managed assembly.
exit /b 0
Expand All @@ -629,7 +655,7 @@ if %__exitCode% neq 0 (

REM Delete original .dll & replace it with the Crossgened .dll
del %1
ren "%CORE_ROOT%\temp.ni.dll" %2
ren "%__CrossgenOutputFile%" %2

echo Successfully precompiled %2
exit /b 0
Expand Down
41 changes: 37 additions & 4 deletions build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,40 @@ generate_layout()
fi

# Precompile framework assemblies with crossgen if required
if [ $__DoCrossgen -ne 0 ]; then
if [[ $__DoCrossgen != 0 || $__DoCrossgen2 != 0 ]]; then
precompile_coreroot_fx
fi
}

precompile_coreroot_fx()
{
echo "${__MsgPrefix}Running crossgen on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
local overlayDir=$CORE_ROOT

echo "${__MsgPrefix}Running ${action} on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"

# Read the exclusion file for this platform
skipCrossGenFiles=($(read_array "$(dirname "$0")/tests/skipCrossGenFiles.${__BuildArch}.txt"))
skipCrossGenFiles+=('System.Runtime.WindowsRuntime.dll')

local overlayDir=$CORE_ROOT
# Delete previously crossgened assemblies
rm ${overlayDir}/*.ni.dll

# Collect reference assemblies for Crossgen2
local crossgen2References=""

if [[ $__DoCrossgen2 != 0 ]]; then
skipCrossGenFiles+=('System.Private.CoreLib.dll')
skipCrossGenFiles+=('System.Runtime.Serialization.Formatters.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll')
skipCrossGenFiles+=('CommandLine.dll')

for reference in ${overlayDir}/*.dll
do
crossgen2References+=" -r:${reference}"
done
fi

filesToPrecompile=$(find -L $overlayDir -maxdepth 1 -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f)
for fileToPrecompile in ${filesToPrecompile}
Expand All @@ -189,7 +209,15 @@ precompile_coreroot_fx()
continue
fi
echo Precompiling $filename
$__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr

if [[ $__DoCrossgen != 0 ]]; then
$__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename 1> $filename.stdout 2>$filename.stderr
fi

if [[ $__DoCrossgen2 != 0 ]]; then
${overlayDir}/crossgen2/crossgen2 ${crossgen2References} -O --inputbubble --out ${filename%.[^.]*}.ni.dll $filename 1>$filename.stdout 2>$filename.stderr
fi

local exitCode=$?
if [[ $exitCode != 0 ]]; then
if grep -q -e '0x80131018' $filename.stderr; then
Expand Down Expand Up @@ -718,6 +746,7 @@ __GenerateTestHostOnly=
__priority1=
__BuildTestWrappersOnly=
__DoCrossgen=0
__DoCrossgen2=0
__CopyNativeTestBinaries=0
__CopyNativeProjectsAfterCombinedTestBuild=true
__SkipGenerateLayout=0
Expand Down Expand Up @@ -924,6 +953,10 @@ while :; do
__DoCrossgen=1
;;

crossgen2)
__DoCrossgen2=1
;;

bindir)
if [ -n "$2" ]; then
__RootBinDir="$2"
Expand Down
142 changes: 2 additions & 140 deletions eng/pipelines/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,175 +13,37 @@ jobs:
#
- template: /eng/checkout-job.yml

#
# Debug builds
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: build-job.yml
buildConfig: debug
platforms:
- Windows_NT_x64
- Windows_NT_x86
jobParameters:
testGroup: innerloop

#
# Checked builds
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: build-job.yml
buildConfig: checked
platforms:
- Linux_arm
- Linux_arm64
- Linux_musl_x64
- Linux_x64
- OSX_x64
- Windows_NT_arm
- Windows_NT_arm64
- Windows_NT_x64
- Windows_NT_x86
jobParameters:
testGroup: innerloop

#
# Release builds
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: build-job.yml
buildConfig: release
platforms:
- Linux_arm64
- Linux_musl_x64
- Linux_rhel6_x64
- OSX_x64
- Windows_NT_arm
- Windows_NT_arm64
- Windows_NT_x64
jobParameters:
testGroup: innerloop

#
# Checked test builds
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: build-test-job.yml
buildConfig: checked
platforms:
- Linux_arm
- Linux_arm64
- OSX_x64
- Windows_NT_arm
- Windows_NT_arm64
- Windows_NT_x64
- Windows_NT_x86
helixQueueGroup: pr
jobParameters:
testGroup: innerloop

#
# Checked JIT test executions
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: run-test-job.yml
buildConfig: checked
platforms:
- Linux_arm
- Linux_arm64
- Linux_musl_x64
- Linux_x64
- OSX_x64
- Windows_NT_arm
- Windows_NT_arm64
- Windows_NT_x64
- Windows_NT_x86
helixQueueGroup: pr
jobParameters:
testGroup: innerloop

#
# Checked R2R test executions
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: run-test-job.yml
buildConfig: checked
platforms:
- Linux_x64
- OSX_x64
- Windows_NT_x64
- Windows_NT_x86
helixQueueGroup: pr
jobParameters:
testGroup: innerloop
readyToRun: true
displayNameArgs: R2R

#
# CoreFX test runs against CoreCLR
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: run-test-job.yml
buildConfig: checked
platforms:
- Linux_x64
- Windows_NT_x64
helixQueueGroup: pr
testGroup: innerloop
jobParameters:
testGroup: innerloop
corefxTests: true
displayNameArgs: CoreFX

#
# Crossgen-comparison jobs
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: crossgen-comparison-job.yml
buildConfig: checked
platforms:
- Linux_arm
helixQueueGroup: pr

#
# Release test builds
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: build-test-job.yml
buildConfig: release
platforms:
- OSX_x64
helixQueueGroup: pr
jobParameters:
testGroup: innerloop

#
# Release test builds
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: run-test-job.yml
buildConfig: release
platforms:
- Linux_musl_x64
helixQueueGroup: pr
jobParameters:
testGroup: innerloop

#
# Formatting
#
- template: /eng/platform-matrix.yml
parameters:
jobTemplate: format-job.yml
platforms:
- Linux_x64

crossgen2: true
displayNameArgs: R2R_CG2
11 changes: 8 additions & 3 deletions eng/run-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parameters:
testGroup: ''
crossrootfsDir: ''
readyToRun: false
crossgen2: false
helixQueues: ''
# If true, run the corefx tests instead of the coreclr ones
corefxTests: false
Expand Down Expand Up @@ -71,6 +72,9 @@ jobs:
- ${{ if eq(parameters.readyToRun, true) }}:
- name: crossgenArg
value: 'crossgen'
- ${{ if eq(parameters.crossgen2, true) }}:
- name: crossgenArg
value: 'crossgen2'

- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
- group: DotNet-HelixApi-Access
Expand Down Expand Up @@ -182,10 +186,10 @@ jobs:
- ${{ if eq(parameters.readyToRun, true) }}:
- ${{ if ne(parameters.osGroup, 'Windows_NT') }}:
- script: ./build-test.sh skipmanaged skipnative $(crossgenArg) $(buildConfig) $(archType) $(crossArg) $(priorityArg)
displayName: Crossgen framework assemblies
displayName: Precompile framework with ${crossgenArg}
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
- script: build-test.cmd skipmanaged skipnative $(crossgenArg) $(buildConfig) $(archType) $(priorityArg)
displayName: Crossgen framework assemblies
displayName: Precompile framework with ${crossgenArg}


# Send tests to Helix
Expand Down Expand Up @@ -252,7 +256,8 @@ jobs:
timeoutPerTestCollectionInMinutes: 300
timeoutPerTestInMinutes: 90

runCrossGen: ${{ parameters.readyToRun }}
runCrossGen: ${{ and(parameters.readyToRun, not(parameters.crossgen2)) }}
runCrossGen2: ${{ and(parameters.readyToRun, parameters.crossgen2) }}
runInUnloadableContext: ${{ parameters.runInUnloadableContext }}

${{ if eq(variables['System.TeamProject'], 'internal') }}:
Expand Down
2 changes: 2 additions & 0 deletions eng/send-to-helix-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ parameters:
timeoutPerTestCollectionInMinutes: ''
timeoutPerTestInMinutes: ''
runCrossGen: ''
runCrossGen2: ''
helixProjectArguments: ''
runInUnloadableContext: ''
longRunningGcTests: ''
Expand Down Expand Up @@ -44,6 +45,7 @@ steps:
_HelixTargetQueues: ${{ join(',', parameters.helixQueues) }}
_HelixType: ${{ parameters.helixType }}
_RunCrossGen: ${{ parameters.runCrossGen }}
_RunCrossGen2: ${{ parameters.runCrossGen2 }}
_RunInUnloadableContext: ${{ parameters.runInUnloadableContext }}
_LongRunningGcTests: ${{ parameters.longRunningGcTests }}
_GcSimulatorTests: ${{ parameters.gcSimulatorTests }}
Expand Down
2 changes: 2 additions & 0 deletions eng/test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ parameters:
container: ''
testGroup: ''
readyToRun: false
crossgen2: false
helixQueues: ''
crossrootfsDir: ''
# If true, run the corefx tests instead of the coreclr ones
Expand Down Expand Up @@ -48,6 +49,7 @@ jobs:
testGroup: ${{ parameters.testGroup }}
crossrootfsDir: ${{ parameters.crossrootfsDir }}
readyToRun: ${{ parameters.readyToRun }}
crossgen2: ${{ parameters.crossgen2 }}
helixQueues: ${{ parameters.helixQueues }}
corefxTests: ${{ parameters.coreFxTests }}
displayNameArgs: ${{ parameters.displayNameArgs }}
Expand Down
Loading

0 comments on commit 8502a0a

Please sign in to comment.