Skip to content

Commit

Permalink
Reduce differences between bash and cmd versions of crossgen test scr…
Browse files Browse the repository at this point in the history
…ipt (#108500)

* Reduce differences between bash and cmd versions of crossgen test script
* Fix bash crossgen runner script not passing full file list in composite mode
* Clean up shellcheck warnings
  • Loading branch information
kg authored Oct 4, 2024
1 parent b2c8aa2 commit f05bfc4
Showing 1 changed file with 61 additions and 39 deletions.
100 changes: 61 additions & 39 deletions src/tests/Common/CLRTest.CrossGen.targets
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
TakeLock
if [ ! -d IL-CG2 ]%3B then
mkdir IL-CG2
cp ./*.dll IL-CG2/
rm IL-CG2/composite-r2r.dll 2>/dev/null
rm IL-CG2/Coreclr.TestWrapper.dll 2>/dev/null
rm IL-CG2/*.XUnitWrapper.dll 2>/dev/null
if [ ! -z ${CompositeBuildMode+x} ]%3B then
cp $(AssemblyName).dll IL-CG2/
cp $CORE_ROOT/lib*.so $CORE_ROOT/lib*.dylib $(scriptPath)
else
cp *.dll IL-CG2/
rm IL-CG2/composite-r2r.dll 2>/dev/null
rm IL-CG2/Coreclr.TestWrapper.dll 2>/dev/null
rm IL-CG2/*.XUnitWrapper.dll 2>/dev/null
# HACK: copy native shared shim libraries. Not needed on Windows.
cp "$CORE_ROOT"/lib*.so "$CORE_ROOT"/lib*.dylib $(scriptPath)
ExtraCrossGen2Args+=" --composite"
fi
ExtraCrossGen2Args+=" $(CrossGen2TestExtraArguments)"
Expand All @@ -75,15 +77,17 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
ExtraCrossGen2Args+=" --inputbubble"
fi
# NOTE: CrossGen2TestCheckPdb not implemented in this version (no PDBs on *nix)
__cg2ExitCode=0
__r2rDumpExitCode=0
OneFileCrossgen2() {
RunCrossgen2OnFiles() {
date +%H:%M:%S
__OutputFile=$1
__ResponseFile="$__OutputFile.rsp"
rm $__ResponseFile 2>/dev/null
rm "$__ResponseFile" 2>/dev/null
__R2RDumpCommand=$_DebuggerFullPath
# Tests run locally need __TestDotNetCmd (set by runtest.py) or a compatible 5.0 dotnet runtime in the path
Expand All @@ -99,30 +103,45 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
__Command+=" @$__ResponseFile"
__Command+=" $ExtraCrossGen2Args"
echo $2 >> $__ResponseFile
# Expand glob or multiple filenames into array
__InputFiles=($2)
for dllFile in "${__InputFiles[@]}"; do
echo "$dllFile" >> "$__ResponseFile"
done
echo -o:$__OutputFile>>$__ResponseFile
echo -r:$CORE_ROOT/System.*.dll>>$__ResponseFile
echo -r:$CORE_ROOT/Microsoft.*.dll>>$__ResponseFile
echo -r:$CORE_ROOT/xunit.*.dll>>$__ResponseFile
echo -r:$CORE_ROOT/mscorlib.dll>>$__ResponseFile
echo --verify-type-and-field-layout>>$__ResponseFile
echo --method-layout:random>>$__ResponseFile
echo -o:"$__OutputFile" >> "$__ResponseFile"
echo --targetarch:$(TargetArchitecture) >> "$__ResponseFile"
echo --targetos:$(TargetOS) >> "$__ResponseFile"
echo --verify-type-and-field-layout >> "$__ResponseFile"
echo --method-layout:random >> "$__ResponseFile"
if [ ! -z ${CrossGen2SynthesizePgo+x} ]%3B then
echo --synthesize-random-mibc>>$__ResponseFile
echo --embed-pgo-data>>$__ResponseFile
echo --synthesize-random-mibc >> "$__ResponseFile"
echo --embed-pgo-data >> "$__ResponseFile"
fi
if [ ! -z ${HotColdSplitting+x} ]%3B then
echo --hot-cold-splitting>>$__ResponseFile
echo --hot-cold-splitting >> "$__ResponseFile"
fi
echo --targetarch:$(TargetArchitecture)>>$__ResponseFile
echo --targetos:$(TargetOS)>>$__ResponseFile
# HACK: Suppress the globbing of the references and filenames causing empty lines in the response file
set -o noglob
echo -r:$CORE_ROOT/System.*.dll >> "$__ResponseFile"
echo -r:$CORE_ROOT/Microsoft.*.dll >> "$__ResponseFile"
echo -r:$CORE_ROOT/xunit.*.dll >> "$__ResponseFile"
echo -r:$CORE_ROOT/mscorlib.dll >> "$__ResponseFile"
echo -r:$CORE_ROOT/netstandard.dll >> "$__ResponseFile"
# HACK: Re-enable globbing
set +o noglob
echo "Response file: $__ResponseFile"
cat $__ResponseFile
cat "$__ResponseFile"
# Suppress some DOTNET variables for the duration of Crossgen2 execution
export -n DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun DOTNET_TC_OnStackReplacement DOTNET_TC_PartialCompilation
export -n DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
# FIXME: Remove this?
# work around problems in 6.0 OSR
export -n DOTNET_TC_OnStackReplacement DOTNET_TC_PartialCompilation
echo "Running CrossGen2: $__Command"
$__Command
Expand All @@ -132,24 +151,25 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
$__R2RDumpCommand
__r2rDumpExitCode=$?
export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun DOTNET_TC_OnStackReplacement DOTNET_TC_PartialCompilation
export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
export DOTNET_TC_OnStackReplacement DOTNET_TC_PartialCompilation
date +%H:%M:%S
}
if [ ! -z ${CompositeBuildMode+x} ]%3B then
ExtraCrossGen2Args+=" --composite"
OneFileCrossgen2 "$PWD/composite-r2r.dll" "$PWD/IL-CG2/*.dll"
shopt -s nullglob
RunCrossgen2OnFiles "$PWD/composite-r2r.dll" "$PWD/IL-CG2/*.dll"
else
ExtraCrossGen2Args+= -r:$PWD/IL-CG2/*.dll
for dllFile in $PWD/IL-CG2/*.dll
do
echo $dllFile
bareFileName="${dllFile##*/}"
OneFileCrossgen2 "$PWD/$bareFileName" "$dllFile"
if [ $__cg2ExitCode -ne 0 ]; then
break
fi
done
ExtraCrossGen2Args+=" -r:$PWD/IL-CG2/*.dll"
for dllFile in "$PWD"/IL-CG2/*.dll
do
echo $dllFile
bareFileName="${dllFile##*/}"
RunCrossgen2OnFiles "$PWD/$bareFileName" "$dllFile"
if [ $__cg2ExitCode -ne 0 ]; then
break
fi
done
fi
echo "Crossgen2 compilation finished, exit code $__cg2ExitCode" >> $compilationDoneFlagFile
Expand Down Expand Up @@ -254,6 +274,7 @@ if defined RunCrossGen2 (
set __Command=!_DebuggerFullPath! "!CORE_ROOT!\crossgen2\crossgen2.exe"
set __Command=!__Command! @"!__ResponseFile!"
set __Command=!__Command! !ExtraCrossGen2Args!
echo !__InputFile!>>!__ResponseFile!
echo -o:!__OutputFile!>>!__ResponseFile!
echo --targetarch:$(TargetArchitecture)>>!__ResponseFile!
Expand Down Expand Up @@ -287,18 +308,19 @@ if defined RunCrossGen2 (
set "DOTNET_HeapVerify="
set "DOTNET_ReadyToRun="
REM FIXME: remove this?
REM work around problems in 6.0 OSR
set "DOTNET_TC_OnStackReplacement="
set "DOTNET_TC_PartialCompilation="
echo "!__Command!"
echo "Running CrossGen2: !__Command!"
call !__Command!
set CrossGen2Status=!ERRORLEVEL!
IF NOT !CrossGen2Status!==0 goto :DoneR2RDumpOperations
echo "!__R2RDumpCommand!"
echo "Running R2RDump: !__R2RDumpCommand!"
call !__R2RDumpCommand!
set R2RDumpStatus=!ERRORLEVEL!
Expand Down

0 comments on commit f05bfc4

Please sign in to comment.