Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5a95caf

Browse files
author
Rahul Kumar
authored
Merge pull request #6130 from rahku/crossgen
ARM64: Fix incremental build problem for cross-components
2 parents 85574fc + 74870fa commit 5a95caf

File tree

3 files changed

+90
-64
lines changed

3 files changed

+90
-64
lines changed

CMakeLists.txt

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -542,43 +542,4 @@ if(CLR_CMAKE_BUILD_TESTS)
542542
add_subdirectory(tests)
543543
endif(CLR_CMAKE_BUILD_TESTS)
544544

545-
#----------------------------------------------------
546-
# Build the project again for cross target components
547-
# - intermediates will be placed at %__IntermediatesDir%\crosscomponents
548-
# - final binaries will be placed at %__CMakeBinDir%\<hostArch>
549-
#----------------------------------------------------
550-
551-
if(CLR_CMAKE_PLATFORM_ARCH_ARM64 AND WIN32)
552-
# Cross target component build only enabled for win arm64
553-
set(CLR_CROSS_COMPONENTS_BUILD_ENABLED 1)
554-
endif()
555-
556-
# To avoid recursion when building cross target components
557-
if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND CLR_CROSS_COMPONENTS_BUILD_ENABLED)
558-
559-
# Set host arch for cross target components
560-
if(CLR_CMAKE_PLATFORM_ARCH_ARM64)
561-
set(CLR_CROSS_BUILD_HOST_ARCH x64)
562-
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
563-
set(CLR_CROSS_BUILD_HOST_ARCH x86)
564-
endif()
565-
566-
include(ExternalProject)
567-
568-
# Add the source root again as external project but with CLR_CROSS_COMPONENTS_BUILD flag set
569-
ExternalProject_Add(
570-
crosscomponents
571-
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
572-
# Arm64 builds currently pollute the env by setting private toolset dirs. Get rid of that.
573-
CMAKE_COMMAND "$ENV{__VSToolsRoot}\\..\\..\\VC\\vcvarsall.bat" COMMAND cmake
574-
CMAKE_ARGS -DCLR_CROSS_COMPONENTS_BUILD=1
575-
-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}/${CLR_CROSS_BUILD_HOST_ARCH}
576-
-DCMAKE_USER_MAKE_RULES_OVERRIDE=${CLR_DIR}/src/pal/tools/windows-compiler-override.txt
577-
-DCLR_CMAKE_HOST_ARCH=${CLR_CROSS_BUILD_HOST_ARCH}
578-
-DCLR_CMAKE_TARGET_ARCH=${CLR_CMAKE_HOST_ARCH}
579-
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/crosscomponents
580-
INSTALL_DIR $ENV{__CMakeBinDir}/${CLR_CROSS_BUILD_HOST_ARCH}
581-
)
582-
endif()
583-
584545
include(definitionsconsistencycheck.cmake)

build.cmd

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if /i "%1" == "osxmscorlib" (set __CoreLibOnly=1&set __BuildOS=OSX&set p
113113
if /i "%1" == "windowsmscorlib" (set __CoreLibOnly=1&set __BuildOS=Windows_NT&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
114114

115115
if /i "%1" == "vs2015" (set __VSVersion=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
116-
if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __SkipCoreLibBuild=1&set __SkipTestBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
116+
if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __SkipCoreLibBuild=1&set __SkipBuildPackages=1&set __SkipTestBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
117117
if /i "%1" == "skipconfigure" (set __SkipConfigure=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
118118
if /i "%1" == "skipmscorlib" (set __SkipCoreLibBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
119119
if /i "%1" == "skipnative" (set __SkipNativeBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
@@ -187,7 +187,7 @@ set "__TestRootDir=%__RootBinDir%\tests"
187187
set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
188188
set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
189189
set "__CrossComponentBinDir=%__BinDir%"
190-
if defined __CrossArch set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch%
190+
if NOT "%__CrossArch%" == "" set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch%
191191

192192
:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
193193
set "__CMakeBinDir=%__BinDir%"
@@ -379,10 +379,77 @@ if errorlevel 1 (
379379
exit /b 1
380380
)
381381

382+
:SkipNativeBuild
383+
382384
REM endlocal to rid us of environment changes from vcvarsall.bat
383385
endlocal
384386

385-
:SkipNativeBuild
387+
REM =========================================================================================
388+
REM ===
389+
REM === Build Cross-Architecture Native Components (if applicable)
390+
REM ===
391+
REM =========================================================================================
392+
393+
REM cross-arch build only enabled for arm64
394+
if "%__CrossArch%" == "" goto SkipCrossCompBuild
395+
396+
echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType%
397+
398+
REM Use setlocal to restrict environment changes form vcvarsall.bat and more to just this native components build section.
399+
setlocal EnableDelayedExpansion EnableExtensions
400+
401+
:: Set the environment for the native build
402+
set __VCBuildArch=x86_amd64
403+
if /i "%__CrossArch%" == "x86" (set __VCBuildArch=x86)
404+
call "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" %__VCBuildArch%
405+
@if defined __echo @echo on
406+
407+
set __CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen
408+
if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%"
409+
410+
pushd "%__CrossCompIntermediatesDir%"
411+
412+
set __CMakeBinDir=%__CrossComponentBinDir%
413+
set "__CMakeBinDir=%__CMakeBinDir:\=/%"
414+
set __ExtraCmakeArgs="-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%"
415+
call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% %__ExtraCmakeArgs%
416+
@if defined __echo @echo on
417+
popd
418+
419+
if not exist "%__CrossCompIntermediatesDir%\install.vcxproj" (
420+
echo %__MsgPrefix%Error: failed to generate cross-arch components build project!
421+
exit /b 1
422+
)
423+
424+
if defined __ConfigureOnly goto SkipCrossCompBuild
425+
426+
echo %__MsgPrefix%Invoking msbuild
427+
428+
set "__BuildLog=%__LogsDir%\CrossComp_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
429+
set "__BuildWrn=%__LogsDir%\CrossComp_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
430+
set "__BuildErr=%__LogsDir%\CrossComp_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
431+
set __msbuildLogArgs=^
432+
/fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" ^
433+
/fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
434+
/fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
435+
/consoleloggerparameters:Summary ^
436+
/verbosity:minimal
437+
438+
set __msbuildArgs="%__CrossCompIntermediatesDir%\install.vcxproj" %__msbuildCommonArgs% %__msbuildLogArgs% /p:Configuration=%__BuildType% /p:Platform=%__CrossArch%
439+
440+
%_msbuildexe% %__msbuildArgs%
441+
if errorlevel 1 (
442+
echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details:
443+
echo %__BuildLog%
444+
echo %__BuildWrn%
445+
echo %__BuildErr%
446+
exit /b 1
447+
)
448+
449+
REM endlocal to rid us of environment changes from vcvarsall.bat
450+
endlocal
451+
452+
:SkipCrossCompBuild
386453

387454
REM =========================================================================================
388455
REM ===
@@ -445,7 +512,7 @@ echo %__MsgPrefix%Generating native image of System.Private.CoreLib for %__Build
445512
set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
446513
set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe"
447514
"%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\System.Private.CoreLib.ni.dll" "%__BinDir%\System.Private.CoreLib.dll" > "%__CrossGenCoreLibLog%" 2>&1
448-
if %errorlevel% NEQ 0 (
515+
if NOT %errorlevel% == 0 (
449516
echo %__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to the build log file for details:
450517
echo %__CrossGenCoreLibLog%
451518
exit /b 1
@@ -456,7 +523,7 @@ echo %__MsgPrefix%Generating native image of MScorlib facade for %__BuildOS%.%__
456523
set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenMSCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
457524
set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe"
458525
"%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\mscorlib.ni.dll" "%__BinDir%\mscorlib.dll" > "%__CrossGenCoreLibLog%" 2>&1
459-
if %errorlevel% NEQ 0 (
526+
if NOT %errorlevel% == 0 (
460527
echo %__MsgPrefix%Error: CrossGen mscorlib facade build failed. Refer to the build log file for details:
461528
echo %__CrossGenCoreLibLog%
462529
exit /b 1
@@ -465,7 +532,7 @@ if %errorlevel% NEQ 0 (
465532
:SkipCoreLibBuild
466533

467534
:GenerateNuget
468-
if /i "%__SkipBuildPackages%" == 1 goto :SkipNuget
535+
if /i "%__SkipBuildPackages%" == "1" goto :SkipNuget
469536

470537
set "__BuildLog=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
471538
set "__BuildWrn=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"

src/pal/tools/gen-buildsys-win.bat

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rem This file invokes cmake and generates the build system for windows.
55
set argC=0
66
for %%x in (%*) do Set /A argC+=1
77

8-
if NOT %argC%==3 if NOT %argC%==4 GOTO :USAGE
8+
if %argC% lss 3 GOTO :USAGE
99
if %1=="/?" GOTO :USAGE
1010

1111
setlocal
@@ -15,25 +15,29 @@ set "basePath=%basePath:"=%"
1515
:: remove trailing slash
1616
if %basePath:~-1%==\ set "basePath=%basePath:~0,-1%"
1717

18-
set __VSString=12 2013
19-
set __UseVS=1
20-
if /i "%2" == "vs2015" (set __VSString=14 2015)
21-
if /i "%3" == "x64" (set __VSString=%__VSString% Win64)
22-
if /i "%3" == "arm64" (set UseVS=0)
23-
24-
set __BuildJit32=%4
18+
set __SourceDir=%1
19+
set __VSVersion=%2
20+
set __Arch=%3
21+
set __CmakeGenerator=Visual Studio
22+
if /i "%__VSVersion%" == "vs2015" (set __CmakeGenerator=%__CmakeGenerator% 14 2015)
23+
if /i "%__Arch%" == "x64" (set __CmakeGenerator=%__CmakeGenerator% Win64)
24+
if /i "%__Arch%" == "arm64" (set __CmakeGenerator=%__CmakeGenerator% Win64)
25+
if /i "%__Arch%" == "arm" (set __CmakeGenerator=%__CmakeGenerator% ARM)
26+
27+
:loop
28+
if [%4] == [] goto end_loop
29+
set __ExtraCmakeParams=%__ExtraCmakeParams% %4
30+
shift
31+
goto loop
32+
:end_loop
2533

2634
if defined CMakePath goto DoGen
2735

2836
:: Eval the output from probe-win1.ps1
2937
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& "%basePath%\probe-win.ps1""') do %%a
3038

3139
:DoGen
32-
if "%UseVS%" == "0" (
33-
"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}" "-DCLR_CMAKE_HOST_ARCH=%3" -G "Visual Studio %__VSString% Win64" %1
34-
) else (
35-
"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}" "-DCLR_CMAKE_HOST_ARCH=%3" %__BuildJit32% -G "Visual Studio %__VSString%" %1
36-
)
40+
"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams% -G "%__CmakeGenerator%" %__SourceDir%
3741
endlocal
3842
GOTO :DONE
3943

@@ -46,9 +50,3 @@ GOTO :DONE
4650

4751
:DONE
4852
EXIT /B 0
49-
50-
51-
52-
53-
54-

0 commit comments

Comments
 (0)