Skip to content

Commit 7adab7c

Browse files
authored
Modify build-test scripts to use response files for Crossgen compilation (#39705)
This makes it much easier to rerun Crossgen(2) for a particular framework assembly or for the framework composite build as opposed to having to copy over the lengthy command line. Thanks Tomas
1 parent 932ea66 commit 7adab7c

File tree

2 files changed

+55
-33
lines changed

2 files changed

+55
-33
lines changed

src/coreclr/build-test.cmd

+23-12
Original file line numberDiff line numberDiff line change
@@ -653,17 +653,14 @@ if defined __CompositeBuildMode (
653653
)
654654

655655
for %%F in ("%CORE_ROOT%\System.*.dll";"%CORE_ROOT%\Microsoft.*.dll";%CORE_ROOT%\netstandard.dll;%CORE_ROOT%\mscorlib.dll) do (
656-
if not "%%~nxF"=="Microsoft.CodeAnalysis.VisualBasic.dll" (
657-
if not "%%~nxF"=="Microsoft.CodeAnalysis.CSharp.dll" (
658-
if not "%%~nxF"=="Microsoft.CodeAnalysis.dll" (
659656
if not "%%~nxF"=="System.Runtime.WindowsRuntime.dll" (
660657
if defined __CompositeBuildMode (
661658
echo %%F>>!__CompositeResponseFile!
662659
) else (
663-
call :PrecompileAssembly "%%F" %%~nxF __TotalPrecompiled __FailedToPrecompile __FailedAssemblies
660+
call :PrecompileAssembly %%F %%~nxF __TotalPrecompiled __FailedToPrecompile __FailedAssemblies
664661
echo Processed: !__TotalPrecompiled!, failed !__FailedToPrecompile!
665662
)
666-
)))))
663+
))
667664
)
668665

669666
if defined __CompositeBuildMode (
@@ -695,19 +692,33 @@ set AssemblyName=%2
695692

696693
REM Intentionally avoid using the .dll extension to prevent
697694
REM subsequent compilations from picking it up as a reference
698-
set __CrossgenOutputFile="%CORE_ROOT%\temp.ni._dll"
695+
set __CrossgenOutputFile=%CORE_ROOT%\temp.ni._dll
696+
set __CrossgenResponseFile="%CORE_ROOT%\%AssemblyName%.rsp
699697
set __CrossgenCmd=
700698

699+
del /Q %__CrossgenResponseFile%
700+
701701
if defined __DoCrossgen (
702-
set __CrossgenCmd=!__CrossgenExe! /Platform_Assemblies_Paths "!CORE_ROOT!" /in !AssemblyPath! /out !__CrossgenOutputFile!
703-
echo !__CrossgenCmd!
704-
!__CrossgenCmd!
702+
set __CrossgenCmd=!__CrossgenExe! @!__CrossgenResponseFile!
703+
echo /Platform_Assemblies_Paths "!CORE_ROOT!">>!__CrossgenResponseFile!
704+
echo /in !AssemblyPath!>>!__CrossgenResponseFile!
705+
echo /out !__CrossgenOutputFile!>>!__CrossgenResponseFile!
705706
) else (
706-
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%
707-
echo !__CrossgenCmd!
708-
call !__CrossgenCmd!
707+
set __CrossgenCmd=!__Crossgen2Dll! @!__CrossgenResponseFile!
708+
echo -r:!CORE_ROOT!\System.*.dll>>!__CrossgenResponseFile!
709+
echo -r:!CORE_ROOT!\Microsoft.*.dll>>!__CrossgenResponseFile!
710+
echo -r:!CORE_ROOT!\mscorlib.dll>>!__CrossgenResponseFile!
711+
echo -r:!CORE_ROOT!\netstandard.dll>>!__CrossgenResponseFile!
712+
echo -O>>!__CrossgenResponseFile!
713+
echo --inputbubble>>!__CrossgenResponseFile!
714+
echo --out:!__CrossgenOutputFile!>>!__CrossgenResponseFile!
715+
echo !AssemblyPath!>>!__CrossgenResponseFile!
716+
echo --targetarch:!__BuildArch!>>!__CrossgenResponseFile!
709717
)
710718

719+
echo !__CrossgenCmd!
720+
call !__CrossgenCmd!
721+
711722
set /a __exitCode = !errorlevel!
712723

713724
set /a "%~3+=1"

src/coreclr/build-test.sh

+32-21
Original file line numberDiff line numberDiff line change
@@ -168,35 +168,30 @@ precompile_coreroot_fx()
168168
local outputDir="$overlayDir"/out
169169

170170
# Delete previously crossgened assemblies
171-
rm "$overlayDir"/*.ni.dll
172-
173-
# Collect reference assemblies for Crossgen2
174-
local crossgen2References=""
171+
rm "$overlayDir"/*.ni.dll 2>/dev/null
175172

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

179176
mkdir "$outputDir"
180-
181-
skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll')
182-
skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll')
183-
skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll')
184-
185-
for reference in "$overlayDir"/*.dll; do
186-
crossgen2References+=" -r:${reference}"
187-
done
188177
fi
189178

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

192181
local totalPrecompiled=0
193182
local failedToPrecompile=0
194-
local compositeCommandLine="${__DotNetCli}"
195-
compositeCommandLine+=" $__Crossgen2Dll"
196-
compositeCommandLine+=" --composite"
197-
compositeCommandLine+=" -O"
198-
compositeCommandLine+=" --out:$outputDir/framework-r2r.dll"
199-
compositeCommandLine+=" --targetarch ${__BuildArch}"
183+
local compositeOutputFile=$outputDir/framework-r2r.dll
184+
local compositeResponseFile=$compositeOutputFile.rsp
185+
local compositeCommandLine="${__DotNetCli} $__Crossgen2Dll @$compositeResponseFile"
186+
187+
if [[ "$__CompositeBuildMode" != 0 ]]; then
188+
rm $compositeResponseFile 2>/dev/null
189+
echo --composite>>$compositeResponseFile
190+
echo -O>>$compositeResponseFile
191+
echo --out:$compositeOutputFile>>$compositeResponseFile
192+
echo --targetarch:${__BuildArch}>>$compositeResponseFile
193+
fi
194+
200195
declare -a failedAssemblies
201196

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

209204
if [[ "$__CompositeBuildMode" != 0 ]]; then
210-
compositeCommandLine+=" $filename"
205+
echo $filename>>$compositeResponseFile
211206
continue
212207
fi
213208

214209
local commandLine=""
210+
local responseFile="$overlayDir/$(basename $filename).rsp"
211+
212+
rm $responseFile 2>/dev/null
215213

216214
if [[ "$__DoCrossgen" != 0 ]]; then
217-
commandLine="$__CrossgenExe /Platform_Assemblies_Paths $overlayDir $filename"
215+
commandLine="$__CrossgenExe @$responseFile"
216+
echo /Platform_Assemblies_Paths>>$responseFile
217+
echo $overlayDir>>$responseFile
218+
echo $filename>>$responseFile
218219
fi
219220

220221
if [[ "$__DoCrossgen2" != 0 ]]; then
221-
commandLine="${__DotNetCli} $__Crossgen2Dll $crossgen2References -O --inputbubble --out $outputDir/$(basename $filename) $filename --targetarch ${__BuildArch}"
222+
commandLine="${__DotNetCli} $__Crossgen2Dll @$responseFile"
223+
echo -O>>$responseFile
224+
echo --inputbubble>>$responseFile
225+
echo --out:$outputDir/$(basename $filename)>>$responseFile
226+
echo --targetarch:${__BuildArch}>>$responseFile
227+
echo $filename>>$responseFile
228+
for reference in $overlayDir/*.dll; do
229+
echo -r:$reference>>$responseFile
230+
done
222231
fi
223232

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

246255
if [[ "$__CompositeBuildMode" != 0 ]]; then
247256
# Compile the entire framework in composite build mode
257+
echo "Response file: $compositeResponseFile"
258+
cat $compositeResponseFile
248259
echo "Compiling composite R2R framework: $compositeCommandLine"
249260
$compositeCommandLine
250261
local exitCode="$?"

0 commit comments

Comments
 (0)