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

Modify build-test scripts to use response files for Crossgen compilation #39705

Merged
merged 2 commits into from
Jul 21, 2020
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
35 changes: 23 additions & 12 deletions src/coreclr/build-test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,14 @@ if defined __CompositeBuildMode (
)

for %%F in ("%CORE_ROOT%\System.*.dll";"%CORE_ROOT%\Microsoft.*.dll";%CORE_ROOT%\netstandard.dll;%CORE_ROOT%\mscorlib.dll) do (
if not "%%~nxF"=="Microsoft.CodeAnalysis.VisualBasic.dll" (
if not "%%~nxF"=="Microsoft.CodeAnalysis.CSharp.dll" (
if not "%%~nxF"=="Microsoft.CodeAnalysis.dll" (
if not "%%~nxF"=="System.Runtime.WindowsRuntime.dll" (
if defined __CompositeBuildMode (
echo %%F>>!__CompositeResponseFile!
) else (
call :PrecompileAssembly "%%F" %%~nxF __TotalPrecompiled __FailedToPrecompile __FailedAssemblies
call :PrecompileAssembly %%F %%~nxF __TotalPrecompiled __FailedToPrecompile __FailedAssemblies
echo Processed: !__TotalPrecompiled!, failed !__FailedToPrecompile!
)
)))))
))
)

if defined __CompositeBuildMode (
Expand Down Expand Up @@ -695,19 +692,33 @@ set AssemblyName=%2

REM Intentionally avoid using the .dll extension to prevent
REM subsequent compilations from picking it up as a reference
set __CrossgenOutputFile="%CORE_ROOT%\temp.ni._dll"
set __CrossgenOutputFile=%CORE_ROOT%\temp.ni._dll
set __CrossgenResponseFile="%CORE_ROOT%\%AssemblyName%.rsp
set __CrossgenCmd=

del /Q %__CrossgenResponseFile%

if defined __DoCrossgen (
set __CrossgenCmd=!__CrossgenExe! /Platform_Assemblies_Paths "!CORE_ROOT!" /in !AssemblyPath! /out !__CrossgenOutputFile!
echo !__CrossgenCmd!
!__CrossgenCmd!
set __CrossgenCmd=!__CrossgenExe! @!__CrossgenResponseFile!
echo /Platform_Assemblies_Paths "!CORE_ROOT!">>!__CrossgenResponseFile!
echo /in !AssemblyPath!>>!__CrossgenResponseFile!
echo /out !__CrossgenOutputFile!>>!__CrossgenResponseFile!
) else (
set __CrossgenCmd=!__Crossgen2Dll! -r:"!CORE_ROOT!\System.*.dll" -r:"!CORE_ROOT!\Microsoft.*.dll" -r:"!CORE_ROOT!\mscorlib.dll" -r:"!CORE_ROOT!\netstandard.dll" -O --inputbubble --out:!__CrossgenOutputFile! !AssemblyPath! --targetarch %__BuildArch%
echo !__CrossgenCmd!
call !__CrossgenCmd!
set __CrossgenCmd=!__Crossgen2Dll! @!__CrossgenResponseFile!
echo -r:!CORE_ROOT!\System.*.dll>>!__CrossgenResponseFile!
echo -r:!CORE_ROOT!\Microsoft.*.dll>>!__CrossgenResponseFile!
echo -r:!CORE_ROOT!\mscorlib.dll>>!__CrossgenResponseFile!
echo -r:!CORE_ROOT!\netstandard.dll>>!__CrossgenResponseFile!
echo -O>>!__CrossgenResponseFile!
echo --inputbubble>>!__CrossgenResponseFile!
echo --out:!__CrossgenOutputFile!>>!__CrossgenResponseFile!
echo !AssemblyPath!>>!__CrossgenResponseFile!
echo --targetarch:!__BuildArch!>>!__CrossgenResponseFile!
)

echo !__CrossgenCmd!
call !__CrossgenCmd!

set /a __exitCode = !errorlevel!

set /a "%~3+=1"
Expand Down
53 changes: 32 additions & 21 deletions src/coreclr/build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,35 +168,30 @@ precompile_coreroot_fx()
local outputDir="$overlayDir"/out

# Delete previously crossgened assemblies
rm "$overlayDir"/*.ni.dll

# Collect reference assemblies for Crossgen2
local crossgen2References=""
rm "$overlayDir"/*.ni.dll 2>/dev/null

if [[ "$__DoCrossgen2" != 0 ]]; then
compilerName=Crossgen2

mkdir "$outputDir"

skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll')

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

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

local totalPrecompiled=0
local failedToPrecompile=0
local compositeCommandLine="${__DotNetCli}"
compositeCommandLine+=" $__Crossgen2Dll"
compositeCommandLine+=" --composite"
compositeCommandLine+=" -O"
compositeCommandLine+=" --out:$outputDir/framework-r2r.dll"
compositeCommandLine+=" --targetarch ${__BuildArch}"
local compositeOutputFile=$outputDir/framework-r2r.dll
local compositeResponseFile=$compositeOutputFile.rsp
local compositeCommandLine="${__DotNetCli} $__Crossgen2Dll @$compositeResponseFile"

if [[ "$__CompositeBuildMode" != 0 ]]; then
rm $compositeResponseFile 2>/dev/null
echo --composite>>$compositeResponseFile
echo -O>>$compositeResponseFile
echo --out:$compositeOutputFile>>$compositeResponseFile
echo --targetarch:${__BuildArch}>>$compositeResponseFile
fi

declare -a failedAssemblies

filesToPrecompile=$(find -L "$overlayDir" -maxdepth 1 -iname Microsoft.\*.dll -o -iname System.\*.dll -o -iname netstandard.dll -o -iname mscorlib.dll -type f)
Expand All @@ -207,18 +202,32 @@ precompile_coreroot_fx()
fi

if [[ "$__CompositeBuildMode" != 0 ]]; then
compositeCommandLine+=" $filename"
echo $filename>>$compositeResponseFile
continue
fi

local commandLine=""
local responseFile="$overlayDir/$(basename $filename).rsp"

rm $responseFile 2>/dev/null

if [[ "$__DoCrossgen" != 0 ]]; then
commandLine="$__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename"
commandLine="$__CrossgenExe @$responseFile"
echo /Platform_Assemblies_Paths>>$responseFile
echo $overlayDir>>$responseFile
echo $filename>>$responseFile
fi

if [[ "$__DoCrossgen2" != 0 ]]; then
commandLine="${__DotNetCli} $__Crossgen2Dll $crossgen2References -O --inputbubble --out $outputDir/$(basename $filename) $filename --targetarch ${__BuildArch}"
commandLine="${__DotNetCli} $__Crossgen2Dll @$responseFile"
echo -O>>$responseFile
echo --inputbubble>>$responseFile
echo --out:$outputDir/$(basename $filename)>>$responseFile
echo --targetarch:${__BuildArch}>>$responseFile
echo $filename>>$responseFile
for reference in $overlayDir/*.dll; do
echo -r:$reference>>$responseFile
done
fi

echo Precompiling "$filename"
Expand All @@ -245,6 +254,8 @@ precompile_coreroot_fx()

if [[ "$__CompositeBuildMode" != 0 ]]; then
# Compile the entire framework in composite build mode
echo "Response file: $compositeResponseFile"
cat $compositeResponseFile
echo "Compiling composite R2R framework: $compositeCommandLine"
$compositeCommandLine
local exitCode="$?"
Expand Down