From f4cb7bc5338a319e8d8f25e5c10c695a965b3522 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 10:47:42 -0700 Subject: [PATCH 01/20] Make ninja the default generator for product builds. --- eng/build.ps1 | 12 ++++++++++-- src/coreclr/build-runtime.cmd | 10 +++++++--- src/coreclr/runtime.proj | 3 ++- src/installer/corehost.proj | 2 +- src/libraries/Native/build-native.cmd | 7 +++++-- src/libraries/Native/build-native.proj | 7 +++++-- src/native/corehost/build.cmd | 7 +++++-- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index 4d6c6fe5b2d4e7..5d49fa71718e5f 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -17,6 +17,7 @@ Param( [ValidateSet("Debug","Release")][string][Alias('lc')]$librariesConfiguration, [ValidateSet("CoreCLR","Mono")][string][Alias('rf')]$runtimeFlavor, [switch]$ninja, + [switch]$msbuild, [string]$cmakeargs, [switch]$pgoinstrument, [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties @@ -79,7 +80,8 @@ function Get-Help() { Write-Host "Native build settings:" Write-Host " -cmakeargs User-settable additional arguments passed to CMake." - Write-Host " -ninja Use Ninja instead of MSBuild to run the native build." + Write-Host " -ninja Use Ninja to drive the native build. (default)" + Write-Host " -msbuild Use MSBuild to drive the native build." Write-Host " -pgoinstrument Build the CLR with PGO instrumentation." Write-Host "Command-line arguments not listed above are passed through to MSBuild." @@ -234,7 +236,9 @@ foreach ($argument in $PSBoundParameters.Keys) "properties" { $arguments += " " + $properties } "verbosity" { $arguments += " -$argument " + $($PSBoundParameters[$argument]) } "cmakeargs" { $arguments += " /p:CMakeArgs=`"$($PSBoundParameters[$argument])`"" } - "ninja" { $arguments += " /p:Ninja=$($PSBoundParameters[$argument])" } + # The -ninja switch is a no-op since Ninja is the default generator on Windows. + "ninja" { } + "msbuild" { $arguments += " /p:Ninja=false" } "pgoinstrument" { $arguments += " /p:PgoInstrument=$($PSBoundParameters[$argument])"} # configuration and arch can be specified multiple times, so they should be no-ops here "configuration" {} @@ -265,4 +269,8 @@ if ($failedBuilds.Count -ne 0) { exit 1 } +if ($ninja) { + Write-Host "The -ninja option has no effect on Windows builds since the Ninja generator is the default generator." +} + exit 0 diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 18a7f392354800..9a128ecbec350b 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -77,7 +77,8 @@ set __CrossArch2= set __CrossOS=0 set __PgoOptDataPath= set __CMakeArgs= -set __Ninja=0 +set __Ninja=1 +set __NinjaOptInDeprecated=0 @REM CMD has a nasty habit of eating "=" on the argument list, so passing: @REM -priority=1 @@ -151,7 +152,9 @@ if /i "%1" == "-skipnative" (set __BuildNative=0&set processedArgs=!pro if /i "%1" == "-skipcrossarchnative" (set __SkipCrossArchNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-skipgenerateversion" (set __SkipGenerateVersion=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-skiprestoreoptdata" (set __RestoreOptData=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-ninja" (set __Ninja=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +REM -ninja is a no-op option since Ninja is now the default generator on Windows. +if /i "%1" == "-ninja" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-msbuild" (set __Ninja=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-pgoinstrument" (set __PgoInstrument=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-enforcepgo" (set __EnforcePgo=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -279,7 +282,7 @@ set "__IntermediatesDir=%__RootBinDir%\obj\coreclr\%__TargetOS%.%__BuildArch%.%_ set "__LogsDir=%__RootBinDir%\log\!__BuildType!" set "__MsbuildDebugLogsDir=%__LogsDir%\MsbuildDebugLogs" set "__ArtifactsIntermediatesDir=%__RepoRootDir%\artifacts\obj\coreclr\" -if "%__Ninja%"=="1" (set "__IntermediatesDir=%__RootBinDir%\nmakeobj\%__TargetOS%.%__BuildArch%.%__BuildType%") +if "%__Ninja%"=="0" (set "__IntermediatesDir=%__IntermediatesDir%\ide") set "__PackagesBinDir=%__BinDir%\.nuget" set "__CrossComponentBinDir=%__BinDir%" set "__CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen" @@ -700,6 +703,7 @@ REM ============================================================================ echo %__MsgPrefix%Build succeeded. Finished at %TIME% echo %__MsgPrefix%Product binaries are available at !__BinDir! + exit /b 0 REM ========================================================================================= diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 502090b0c5f89f..cd069d6a50bb67 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -26,7 +26,8 @@ '$(PgoInstrument)' != 'true'" Include="-enforcepgo" /> <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" /> - <_CoreClrBuildArg Condition="'$(Ninja)' == 'true'" Include="-ninja" /> + <_CoreClrBuildArg Condition="'$(Ninja)' == 'true' and !$([MSBuild]::IsOsPlatform(Windows))" Include="-ninja" /> + <_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" /> <_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' != 'true'" Include="-skipruntime" /> <_CoreClrBuildArg Condition="'$(ClrJitSubset)' != 'true'" Include="-skipjit" /> <_CoreClrBuildArg Condition="'$(ClrPalTestsSubset)' == 'true'" Include="-paltests" /> diff --git a/src/installer/corehost.proj b/src/installer/corehost.proj index 6ba56f27aec807..09d6bc7ebb6bf2 100644 --- a/src/installer/corehost.proj +++ b/src/installer/corehost.proj @@ -84,7 +84,7 @@ $(BuildArgs) incremental-native-build $(BuildArgs) rootdir $(RepoRoot) $(BuildArgs) coreclrartifacts $(CoreCLRArtifactsPath) - $(BuildArgs) ninja + $(BuildArgs) msbuild $(BuildArgs) runtimeflavor $(RuntimeFlavor) $(BuildArgs) runtimeconfiguration $(RuntimeConfiguration) diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index 8cbe62d9c3858f..7e9a36ac75424f 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -15,7 +15,7 @@ set __TargetOS=windows set CMAKE_BUILD_TYPE=Debug set "__LinkArgs= " set "__LinkLibraries= " -set __Ninja=0 +set __Ninja=1 :Arg_Loop :: Since the native build requires some configuration information before msbuild is called, we have to do some manual args parsing @@ -37,7 +37,7 @@ if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) -if /i [%1] == [ninja] ( set __Ninja=1&&shift&goto Arg_Loop) +if /i [%1] == [msbuild] ( set __Ninja=0&&shift&goto Arg_Loop) shift goto :Arg_Loop @@ -60,6 +60,9 @@ if %__CMakeBinDir% == "" ( if %__IntermediatesDir% == "" ( set "__IntermediatesDir=%__artifactsDir%\obj\native\%__outConfig%" ) +if %__Ninja% == 0 ( + set "__IntermediatesDir=%__IntermediatesDir%\ide" +) set "__CMakeBinDir=%__CMakeBinDir:\=/%" set "__IntermediatesDir=%__IntermediatesDir:\=/%" diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj index 900d7f0ad7262a..edba5f1fbddb75 100644 --- a/src/libraries/Native/build-native.proj +++ b/src/libraries/Native/build-native.proj @@ -6,7 +6,6 @@ $(BuildTargetFramework) $(NetCoreAppCurrent) <_BuildNativeArgs>$(TargetArchitecture) $(Configuration) outconfig $(TargetFramework)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) -os $(TargetOS) - <_BuildNativeArgs Condition="'$(Ninja)' == 'true'">$(_BuildNativeArgs) ninja @@ -18,6 +17,7 @@ BeforeTargets="Build" Condition="!$([MSBuild]::IsOsPlatform(Windows))"> + <_BuildNativeArgs Condition="'$(Ninja)' == 'true'">$(_BuildNativeArgs) ninja + + <_BuildNativeArgs Condition="'$(Ninja)' == 'false'">$(_BuildNativeArgs) msbuild + + diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 9e44ccc93625c8..377aa0f880aa14 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -17,7 +17,7 @@ set "__LinkArgs= " set "__LinkLibraries= " set __PortableBuild=0 set __IncrementalNativeBuild=0 -set __Ninja=0 +set __Ninja=1 :Arg_Loop if [%1] == [] goto :InitVSEnv @@ -43,7 +43,7 @@ if /i [%1] == [commit] (set __CommitSha=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [incremental-native-build] ( set __IncrementalNativeBuild=1&&shift&goto Arg_Loop) if /i [%1] == [rootDir] ( set __rootDir=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [coreclrartifacts] (set __CoreClrArtifacts=%2&&shift&&shift&goto Arg_Loop) -if /i [%1] == [ninja] (set __Ninja=1) +if /i [%1] == [msbuild] (set __Ninja=0) if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop) @@ -73,6 +73,9 @@ if %__CMakeBinDir% == "" ( if %__IntermediatesDir% == "" ( set "__IntermediatesDir=%__objDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%\corehost" ) +if %__Ninja% == 0 ( + set "__IntermediatesDir=%__IntermediatesDir%\ide" +) set "__ResourcesDir=%__objDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%\hostResourceFiles" set "__CMakeBinDir=%__CMakeBinDir:\=/%" set "__IntermediatesDir=%__IntermediatesDir:\=/%" From 42b79c6538765c81aa5eeb5c8381833f95efdb18 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 10:55:06 -0700 Subject: [PATCH 02/20] Make ninja the default of the test build as well. --- src/tests/build.cmd | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/tests/build.cmd b/src/tests/build.cmd index 3366e25d3e33d2..9d8e331bb231ed 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -57,6 +57,7 @@ set __SkipGenerateLayout=0 set __LocalCoreFXConfig=%__BuildType% set __SkipFXRestoreArg= set __GenerateLayoutOnly=0 +set __Ninja=1 @REM CMD has a nasty habit of eating "=" on the argument list, so passing: @REM -priority=1 @@ -99,6 +100,7 @@ if /i "%1" == "copynativeonly" (set __CopyNativeTestBinaries=1&set __Skip if /i "%1" == "generatelayoutonly" (set __SkipManaged=1&set __SkipNative=1&set __CopyNativeProjectsAfterCombinedTestBuild=false&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "buildtestwrappersonly" (set __SkipNative=1&set __SkipManaged=1&set __BuildTestWrappersOnly=1&set __SkipGenerateLayout=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-msbuild" (set __Ninja=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "buildagainstpackages" (echo error: Remove /BuildAgainstPackages switch&&exit /b1) if /i "%1" == "crossgen" (set __DoCrossgen=1&set __TestBuildMode=crossgen&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "crossgen2" (set __DoCrossgen2=1&set __TestBuildMode=crossgen2&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -161,6 +163,7 @@ if not defined __TestIntermediateDir ( set "__TestIntermediateDir=tests\coreclr\obj\%__TargetOS%.%__BuildArch%.%__BuildType%" ) set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Native" +if "%__Ninja%"=="0" (set "__NativeTestIntermediatesDir=%__NativeTestIntermediatesDir%\ide") set "__ManagedTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Managed" REM Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash @@ -213,7 +216,13 @@ echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildA call "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch% @if defined _echo @echo on -set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" +set __ExtraCmakeArgs= + +if %__Ninja% EQU 1 ( + set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=!__BuildType!" +) else ( + set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" +) call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectFilesDir%" "%__NativeTestIntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( @@ -239,8 +248,17 @@ set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn! set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr! set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! +set __CmakeBuildToolArgs= + +if %__Ninja% EQU 1 ( + set __CmakeBuildToolArgs= +) else ( + REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. + set __CmakeBuildToolArgs=/nologo /m !__Logging! +) + REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. -"%CMakePath%" --build %__NativeTestIntermediatesDir% --target install --config %__BuildType% -- /nologo /m !__Logging! +"%CMakePath%" --build %__NativeTestIntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs! if errorlevel 1 ( echo %__ErrMsgPrefix%%__MsgPrefix%Error: native test build failed. From 1293ccd27751b16650e0cd465a4ee4dfcb66153c Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 10:59:32 -0700 Subject: [PATCH 03/20] Change over the CI scripts to use ninja by default but preserve the MSBuild generator in a dev-innerloop job --- eng/pipelines/coreclr/templates/build-job.yml | 10 ++-------- eng/pipelines/global-build.yml | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index 349cdfd0bb2155..9663abb3203a3c 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -132,12 +132,6 @@ jobs: - name: clrBuildPALTestsBuildArg value: '-paltests ' - - name: ninjaArg - value: '' - - ${{ if eq(parameters.osGroup, 'windows') }}: - - name: ninjaArg - value: '-ninja' - - name: pgoInstrumentArg value: '' - ${{ if eq(parameters.pgoType, 'PGO' )}}: @@ -194,10 +188,10 @@ jobs: # Build CoreCLR Runtime - ${{ if ne(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(ninjaArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) + - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) displayName: Build CoreCLR Runtime - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(ninjaArg) $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) + - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) displayName: Build CoreCLR Runtime - ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}: diff --git a/eng/pipelines/global-build.yml b/eng/pipelines/global-build.yml index 239f8bb0b9de7b..0d8aedc98d8d2c 100644 --- a/eng/pipelines/global-build.yml +++ b/eng/pipelines/global-build.yml @@ -45,6 +45,21 @@ jobs: buildArgs: -c release -runtimeConfiguration debug timeoutInMinutes: 90 +# +# Build with Release config and runtimeConfiguration with MSBuild generator +# +- template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + buildConfig: release + platforms: + - windows_x86 + jobParameters: + testGroup: innerloop + nameSuffix: MSBuild_CMake + buildArgs: -c Release -msbuild + timeoutInMinutes: 90 + # # Build with Debug config and Release runtimeConfiguration # From 1718b5733f38861b0736ed6e1f266d5a3b9bdea9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 11:15:29 -0700 Subject: [PATCH 04/20] Update src/coreclr/build-runtime.cmd --- src/coreclr/build-runtime.cmd | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 9a128ecbec350b..fbdea30e3dd00d 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -78,7 +78,6 @@ set __CrossOS=0 set __PgoOptDataPath= set __CMakeArgs= set __Ninja=1 -set __NinjaOptInDeprecated=0 @REM CMD has a nasty habit of eating "=" on the argument list, so passing: @REM -priority=1 From 9a02908d2d429cedf3e9c95f76603f14846a053e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 13:09:35 -0700 Subject: [PATCH 05/20] Fix -vs CoreCLR.sln to match new path. --- eng/build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index 5d49fa71718e5f..fd22ca1926769b 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -135,10 +135,10 @@ if ($vs) { if ($runtimeConfiguration) { $configToOpen = $runtimeConfiguration } - $vs = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "artifacts\obj\coreclr" | Join-Path -ChildPath "windows.$archToOpen.$((Get-Culture).TextInfo.ToTitleCase($configToOpen))" | Join-Path -ChildPath "CoreCLR.sln" + $vs = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "artifacts\obj\coreclr" | Join-Path -ChildPath "windows.$archToOpen.$((Get-Culture).TextInfo.ToTitleCase($configToOpen))" | Join-Path -ChildPath "ide" | Join-Path -ChildPath "CoreCLR.sln" if (-Not (Test-Path $vs)) { $repoRoot = Split-Path $PSScriptRoot -Parent - Invoke-Expression "& `"$repoRoot/src/coreclr/build-runtime.cmd`" -configureonly -$archToOpen -$configToOpen" + Invoke-Expression "& `"$repoRoot/src/coreclr/build-runtime.cmd`" -configureonly -$archToOpen -$configToOpen -msbuild" if ($lastExitCode -ne 0) { Write-Error "Failed to generate the CoreCLR solution file." exit 1 From ec50dc0eccf9a9511652a6a32e8519c1b1fcbb67 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 13:16:33 -0700 Subject: [PATCH 06/20] Update help for -msbuild flag. --- eng/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index fd22ca1926769b..dc1883ae26bd30 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -81,7 +81,7 @@ function Get-Help() { Write-Host "Native build settings:" Write-Host " -cmakeargs User-settable additional arguments passed to CMake." Write-Host " -ninja Use Ninja to drive the native build. (default)" - Write-Host " -msbuild Use MSBuild to drive the native build." + Write-Host " -msbuild Use MSBuild to drive the native build. This is a no-op for Mono." Write-Host " -pgoinstrument Build the CLR with PGO instrumentation." Write-Host "Command-line arguments not listed above are passed through to MSBuild." From a20b54dc56fc1591d69ea0dbe58935df9412bfb3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 13:19:17 -0700 Subject: [PATCH 07/20] Fix /EHsc flag in the host build. --- src/native/corehost/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 3ce1d78bec72cd..d7784410ed03d1 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -16,7 +16,7 @@ if (MSVC) add_compile_options($<$:/wd4200>) add_compile_options($<$:/wd4244>) # Host components don't try to handle asynchronous exceptions - add_compile_options(/EHsc) + add_compile_options($<$:/EHsc>) elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) # Prevents libc from calling pthread_cond_destroy on static objects in # dlopen()'ed library which we dlclose() in pal::unload_library. From 394742aa0c5d4d86a3989ee5c8237d3a4ae51975 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 18:07:11 -0700 Subject: [PATCH 08/20] Update the mechanism for copying the native test binaries into the right place to understand the Ninja vs VS layout for the native test binaries and use the Ninja=false switch on Windows to switch to expecting the MSBuild layout (same as the rest of the build scripts). --- src/tests/Directory.Build.targets | 82 +++++++++++++++++-------------- src/tests/build.cmd | 9 +++- 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 80bda0ec6fc5bc..f27cabecc1e965 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -87,6 +87,7 @@ <_CopyNativeProjectBinaries>$(CopyNativeProjectBinaries) <_CopyNativeProjectBinaries Condition="'$(_WillCLRTestProjectBuild)' != 'true'">false <_CopyNativeProjectBinaries Condition="'$(_CopyNativeProjectBinaries)' == ''">true + true @@ -114,48 +115,57 @@ + + + + + + + + + + + + + + - - + + - - - - - - - - - - - + + - - + + - - - - + + - - + + - - + + - - + + - - + + - - - - + + - + + + + + + + + + - - + + @@ -271,7 +281,7 @@ %(Identity) - + @@ -367,7 +377,7 @@ - + diff --git a/src/tests/build.cmd b/src/tests/build.cmd index 9d8e331bb231ed..e62e2d60d92a60 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -331,6 +331,12 @@ echo %__MsgPrefix%Building tests divided into %__NumberOfTestGroups% test groups set __CommonMSBuildCmdPrefix=powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -Command "!__RepoRootDir!\eng\common\msbuild.ps1" !__ArcadeScriptArgs! +set __NativeBinariesLayoutTypeArg= + +if %__Ninja% EQ 0 ( + set __NativeBinariesLayoutTypeArg=/p:UseVisualStudioNativeBinariesLayout=true +) + for /l %%G in (1, 1, %__NumberOfTestGroups%) do ( set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%";Append=!__AppendToLog! @@ -352,6 +358,7 @@ for /l %%G in (1, 1, %__NumberOfTestGroups%) do ( set __MSBuildBuildArgs=!__MSBuildBuildArgs! /p:CopyNativeProjectBinaries=!__CopyNativeProjectsAfterCombinedTestBuild! set __MSBuildBuildArgs=!__MSBuildBuildArgs! /p:__SkipPackageRestore=true set __MSBuildBuildArgs=!__MSBuildBuildArgs! !__SkipFXRestoreArg! + set __MSBuildBuildArgs=!__MSBuildBuildArgs! !__NativeBinariesLayoutTypeArg! echo Running: msbuild !__MSBuildBuildArgs! !__CommonMSBuildCmdPrefix! !__MSBuildBuildArgs! @@ -366,7 +373,7 @@ for /l %%G in (1, 1, %__NumberOfTestGroups%) do ( goto :Exit_Failure ) ) else ( - set __MSBuildBuildArgs=!__RepoRootDir!\src\tests\build.proj -warnAsError:0 /nodeReuse:false !__Logging! !TargetsWindowsMsbuildArg! !__msbuildArgs! !__PriorityArg! !__BuildNeedTargetArg! !__SkipFXRestoreArg! !__UnprocessedBuildArgs! "/t:CopyAllNativeProjectReferenceBinaries" + set __MSBuildBuildArgs=!__RepoRootDir!\src\tests\build.proj -warnAsError:0 /nodeReuse:false !__Logging! !TargetsWindowsMsbuildArg! !__msbuildArgs! !__PriorityArg! !__BuildNeedTargetArg! !__SkipFXRestoreArg! !__NativeBinariesLayoutTypeArg! !__UnprocessedBuildArgs! "/t:CopyAllNativeProjectReferenceBinaries" echo Running: msbuild !__MSBuildBuildArgs! !__CommonMSBuildCmdPrefix! !__MSBuildBuildArgs! From 8d0768a3c48f90eb0b6d24d2e5a244038136bc4b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 17 Mar 2021 09:29:17 -0700 Subject: [PATCH 09/20] Fix batch syntax --- src/tests/build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/build.cmd b/src/tests/build.cmd index e62e2d60d92a60..b9b41837a7490e 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -333,7 +333,7 @@ set __CommonMSBuildCmdPrefix=powershell -NoProfile -ExecutionPolicy ByPass -NoLo set __NativeBinariesLayoutTypeArg= -if %__Ninja% EQ 0 ( +if %__Ninja% == 0 ( set __NativeBinariesLayoutTypeArg=/p:UseVisualStudioNativeBinariesLayout=true ) From 1cb5694f8a9e71c8c5955fb44c9aa36b07f71784 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 17 Mar 2021 09:34:14 -0700 Subject: [PATCH 10/20] Fixes for CI. --- src/tests/Directory.Build.targets | 2 +- src/tests/build.cmd | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index f27cabecc1e965..1aee5179207f07 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -131,7 +131,7 @@ - + diff --git a/src/tests/build.cmd b/src/tests/build.cmd index b9b41837a7490e..8024fe5b54fc95 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -257,7 +257,6 @@ if %__Ninja% EQU 1 ( set __CmakeBuildToolArgs=/nologo /m !__Logging! ) -REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. "%CMakePath%" --build %__NativeTestIntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs! if errorlevel 1 ( From 7df58999b2e97506269cb08e6463ccc08a4c47be Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 17 Mar 2021 13:57:13 -0700 Subject: [PATCH 11/20] Include the mainfest files for the COM tests. --- src/tests/Directory.Build.targets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 1aee5179207f07..d6a972f31ff1ac 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -139,6 +139,9 @@ + + + @@ -165,6 +168,7 @@ + From 47f4f2261e1ecdd54771ecb7c5b77c5f69fff4c4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 18 Mar 2021 09:57:01 -0700 Subject: [PATCH 12/20] Fix compiler command line warnings. --- eng/native/configurecompiler.cmake | 6 +++++- src/coreclr/CMakeLists.txt | 21 +++++++++++++++------ src/coreclr/jit/CMakeLists.txt | 3 +-- src/libraries/Native/Windows/CMakeLists.txt | 3 +-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index a5dac887902eb3..cdc480989fcd55 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -479,7 +479,11 @@ if (MSVC) # Compile options for targeting windows add_compile_options($<$:/nologo>) # Suppress Startup Banner - add_compile_options($<$:/W3>) # set warning level to 3 + # /W3 is added by default by CMake, so remove it + string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "/W3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + # set default warning level to 3 but allow targets to override it. + add_compile_options($<$:/W$>,$,3>>>) add_compile_options($<$:/WX>) # treat warnings as errors add_compile_options($<$:/Oi>) # enable intrinsics add_compile_options($<$:/Oy->) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 28ecbf7f16296e..0261b3799dbd4f 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -12,8 +12,6 @@ include(../../eng/native/configurepaths.cmake) include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) if(MSVC) - string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_compile_options($<$:/EHa>) # enable C++ EH (w/ SEH exceptions) set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc. endif (MSVC) @@ -48,6 +46,21 @@ endif(CLR_CROSS_COMPONENTS_BUILD) #------------------- include(pgosupport.cmake) +#--------------------------- +# Build the single file host +#--------------------------- +if(CLR_CMAKE_BUILD_SUBSET_RUNTIME AND NOT CLR_CROSS_COMPONENTS_BUILD) + add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) +endif() + +#------------------------- +# Enable C++ EH with SEH +#------------------------- +if (MSVC) + string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options($<$:/EHa>) # enable C++ EH (w/ SEH exceptions) +endif() + #------------------------------- # Include libraries native shims #------------------------------- @@ -126,10 +139,6 @@ if(FEATURE_STANDALONE_GC) endif (CLR_CMAKE_BUILD_SUBSET_RUNTIME) endif(FEATURE_STANDALONE_GC) -if(CLR_CMAKE_BUILD_SUBSET_RUNTIME AND NOT CLR_CROSS_COMPONENTS_BUILD) - add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) -endif() - if (CLR_CMAKE_HOST_UNIX) include_directories("pal/inc") include_directories("pal/inc/rt") diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index f5c5429a77c19a..ecb3a257e67fdb 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -8,8 +8,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-error) endif() -add_compile_options($<$:-W4>) - function(create_standalone_jit) set(oneValueArgs TARGET OS ARCH) @@ -447,6 +445,7 @@ function(add_jit jitName) set_property(TARGET ${jitName} APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION}) set_property(TARGET ${jitName} APPEND_STRING PROPERTY LINK_DEPENDS ${JIT_EXPORTS_FILE}) + set_target_properties(${jitName} PROPERTIES MSVC_WARNING_LEVEL 4) target_link_libraries(${jitName} ${JIT_LINK_LIBRARIES} diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index 3f9924adb0a9d2..a4020ae824e167 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -49,9 +49,8 @@ string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions) add_compile_options(/Zp8) # pack structs on 8-byte boundary add_compile_options(/Gy) # separate functions for linker -add_compile_options(/Zc:wchar_t-) # C++ language conformance: wchar_t is NOT the native type, but a typedef add_compile_options(/Zc:forScope) # C++ language conformance: enforce Standard C++ for scoping rules -string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +string(REPLACE "/GR " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_compile_options(/GR-) # disable C++ RTTI add_compile_options(/FC) # use full pathnames in diagnostics add_compile_options(/MP) # Build with Multiple Processes (number of processes equal to the number of processors) From 02863a5dfd3b4177a1f2ab250ed8b96ed50028f5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 18 Mar 2021 12:27:12 -0700 Subject: [PATCH 13/20] Fix incremental module index generation with Ninja. --- eng/native/functions.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index f39fb67bd0cf53..880693b6d9f4c0 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -468,12 +468,9 @@ function(generate_module_index Target ModuleIndexFile) set(scriptExt ".sh") endif() - set(index_timestamp ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${Target}_index.timestamp) - add_custom_command( - OUTPUT ${index_timestamp} + OUTPUT ${ModuleIndexFile} COMMAND ${CLR_ENG_NATIVE_DIR}/genmoduleindex${scriptExt} $ ${ModuleIndexFile} - COMMAND ${CMAKE_COMMAND} -E touch ${index_timestamp} DEPENDS ${Target} COMMENT "Generating ${Target} module index file -> ${ModuleIndexFile}" ) @@ -485,7 +482,6 @@ function(generate_module_index Target ModuleIndexFile) add_custom_target( ${Target}_module_index_header - DEPENDS ${index_timestamp} ) endfunction(generate_module_index) From c64fd1aa140abc145d4e6bbe3d461ba837fa1510 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 18 Mar 2021 15:27:53 -0700 Subject: [PATCH 14/20] Fix MSBuild test build native files location. --- src/tests/Common/dir.common.props | 8 +++++--- src/tests/Directory.Build.targets | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tests/Common/dir.common.props b/src/tests/Common/dir.common.props index 617bf746d118a1..99c763a741e2d0 100644 --- a/src/tests/Common/dir.common.props +++ b/src/tests/Common/dir.common.props @@ -24,7 +24,9 @@ for the lock file, and props/targets from nuget packages. --> $(BaseOutputPath)/obj/$(OSPlatformConfig)/Managed/$(BuildProjectRelativeDir) $(BaseIntermediateOutputPath) - <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$(BaseOutputPath)\obj\$(OSPlatformConfig)\Native\ + true + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == '' and '$(UseVisualStudioNativeBinariesLayout)' != 'true'">$(BaseOutputPath)\obj\$(OSPlatformConfig)\Native\ + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == '' and '$(UseVisualStudioNativeBinariesLayout)' == 'true'">$(BaseOutputPath)\obj\$(OSPlatformConfig)\Native\ide\ $(BaseOutputPath)\packages\$(BuildProjectRelativeDir) $([System.IO.Path]::GetFullPath($(IntermediateOutputPath)\$(PackageRuntimeIdentifier))) @@ -37,7 +39,7 @@ $(BaseOutputPathWithConfig)$(BuildProjectRelativeDir) - + true @@ -45,5 +47,5 @@ - + diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index d6a972f31ff1ac..cf36a8cdf61b02 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -87,7 +87,6 @@ <_CopyNativeProjectBinaries>$(CopyNativeProjectBinaries) <_CopyNativeProjectBinaries Condition="'$(_WillCLRTestProjectBuild)' != 'true'">false <_CopyNativeProjectBinaries Condition="'$(_CopyNativeProjectBinaries)' == ''">true - true @@ -139,8 +138,9 @@ - + + From f81d6292da4959b3dcbbf13ea4c82549986158c3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 18 Mar 2021 15:28:12 -0700 Subject: [PATCH 15/20] Fix manifest/tlb copying to copy to the right folder. --- src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt | 4 ++-- .../COM/NativeClients/DefaultInterfaces/CMakeLists.txt | 2 +- src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt | 2 +- src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt | 2 +- src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt | 2 +- src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt | 2 +- src/tests/Interop/COM/NativeServer/CMakeLists.txt | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt b/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt index 2708ce303ae6ff..51c8ecd4aed44a 100644 --- a/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt +++ b/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt @@ -11,7 +11,7 @@ add_custom_command( COMMAND ${MIDL} ${MIDL_INCLUDE_DIRECTORIES} /h ${IDL_OUTPUT_DIRECTORY}/${IDL_NAME}.h ${MIDL_DEFINITIONS} /out ${IDL_OUTPUT_DIRECTORY} - /tlb ${CMAKE_CURRENT_BINARY_DIR}/$/DynamicTestServer.tlb + /tlb $/DynamicTestServer.tlb ${IDL_SOURCE} DEPENDS ${IDL_SOURCE} COMMENT "Compiling ${IDL_SOURCE}") @@ -37,7 +37,7 @@ add_library (${PROJECT_NAME} SHARED ${SOURCES}) target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES_ADDITIONAL}) # Copy manifest file to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/DynamicTestServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/DynamicTestServer.X.manifest) +file(GENERATE OUTPUT $/DynamicTestServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/DynamicTestServer.X.manifest) # add the install targets install (TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt index 38954f3d1d2352..b5eb8e0a557f97 100644 --- a/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable (COMClientDefaultInterfaces ${SOURCES}) target_link_libraries(COMClientDefaultInterfaces ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientDefaultInterfaces DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt index a8a8bba03ccfa0..d377599d0856e8 100644 --- a/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt @@ -10,7 +10,7 @@ add_executable (COMClientDispatch ${SOURCES}) target_link_libraries(COMClientDispatch ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientDispatch DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt index 43063bd532d3af..d80b993c18f3c2 100644 --- a/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable (COMClientEvents ${SOURCES}) target_link_libraries(COMClientEvents ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientEvents DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt index d850c7ee067a16..70b85b0cb0e59a 100644 --- a/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable (COMClientLicensing ${SOURCES}) target_link_libraries(COMClientLicensing ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientLicensing DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt index 57af5d8af9b7bd..62ca91cd4288c2 100644 --- a/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt @@ -16,7 +16,7 @@ add_executable (COMClientPrimitives ${SOURCES}) target_link_libraries(COMClientPrimitives ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientPrimitives DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeServer/CMakeLists.txt b/src/tests/Interop/COM/NativeServer/CMakeLists.txt index 9f661bfb9e6227..1f757d8e9cdf6c 100644 --- a/src/tests/Interop/COM/NativeServer/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeServer/CMakeLists.txt @@ -13,7 +13,7 @@ add_library (COMNativeServer SHARED ${SOURCES}) target_link_libraries(COMNativeServer ${LINK_LIBRARIES_ADDITIONAL}) # Copy manifest file to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/COMNativeServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/COMNativeServer.X.manifest) +file(GENERATE OUTPUT $/COMNativeServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/COMNativeServer.X.manifest) # add the install targets install (TARGETS COMNativeServer DESTINATION bin) From 7070c2c48183ec430d4f8877c321214cb66f0db1 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 19 Mar 2021 11:48:26 -0700 Subject: [PATCH 16/20] Update docs that point to CoreCLR.sln to point to the new path for CoreCLR.sln and update the docs of the -vs coreclr feature. --- docs/workflow/debugging/coreclr/debugging.md | 26 +++++++++++--------- docs/workflow/editing-and-debugging.md | 5 ++-- eng/build.ps1 | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/docs/workflow/debugging/coreclr/debugging.md b/docs/workflow/debugging/coreclr/debugging.md index 0eda9dc3727381..da379ceb264534 100644 --- a/docs/workflow/debugging/coreclr/debugging.md +++ b/docs/workflow/debugging/coreclr/debugging.md @@ -8,25 +8,29 @@ SOS has moved to the diagnostics repo. For more information on SOS, installation Debugging CoreCLR on Windows ============================ -1. Perform a build of the repo. -2. Open solution \\artifacts\obj\coreclr\windows.\.\\CoreCLR.sln in Visual Studio. \ and \ are based +1. Open the CoreCLR solution in Visual Studio. + - Method 1: Use the build scripts to open the solution. + 1. Run `./build.cmd -vs coreclr.sln -a -c `. This will create and launch the CoreCLR solution in VS for the specified architecture and configuration. + - Method 2: Manually build and open the solution. + 1. Perform a build of the repo with the `-msbuild` flag. + 2. Open solution \\artifacts\obj\coreclr\windows.\.\\ide\CoreCLR.sln in Visual Studio. \ and \ are based on type of build you did. By default they are 'x64' and 'Debug'. -3. Right-click the INSTALL project and choose ‘Set as StartUp Project’ -4. Bring up the properties page for the INSTALL project -5. Select Configuration Properties->Debugging from the left side tree control -6. Set Command=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)\corerun.exe` +2. Right-click the INSTALL project and choose ‘Set as StartUp Project’ +3. Bring up the properties page for the INSTALL project +4. Select Configuration Properties->Debugging from the left side tree control +5. Set Command=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)\corerun.exe` 1. This points to the folder where the built runtime binaries are present. -7. Set Command Arguments=`` (e.g. HelloWorld.dll) -8. Set Working Directory=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)` +6. Set Command Arguments=`` (e.g. HelloWorld.dll) +7. Set Working Directory=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)` 1. This points to the folder containing CoreCLR binaries. -9. Set Environment=`CORE_LIBRARIES=$(SolutionDir)\..\..\..\bin\runtime\-windows-$(Configuration)-$(Platform)`, +8. Set Environment=`CORE_LIBRARIES=$(SolutionDir)\..\..\..\bin\runtime\-windows-$(Configuration)-$(Platform)`, where '\' is the target framework of current branch, for example `netcoreapp3.1` `net5.0`. 1. This points to the folder containing core libraries except `System.Private.CoreLib`. 2. This step can be skipped if you are debugging CLR tests that references only `System.Private.CoreLib`. Otherwise, it's required to debug a realworld application that references anything else, including `System.Runtime`. -10. Right-click the INSTALL project and choose 'Build' +9. Right-click the INSTALL project and choose 'Build' 1. This will load necessary information from cmake to Visual Studio. -11. Press F11 to start debugging at wmain in corerun (or set a breakpoint in source and press F5 to run to it) +10. Press F11 to start debugging at wmain in corerun (or set a breakpoint in source and press F5 to run to it) 1. As an example, set a breakpoint for the EEStartup function in ceemain.cpp to break into CoreCLR startup. Steps 1-10 only need to be done once, and then (11) can be repeated whenever you want to start debugging. The above can be done with Visual Studio 2019 as writing. diff --git a/docs/workflow/editing-and-debugging.md b/docs/workflow/editing-and-debugging.md index 50213150e4b9de..46e3d0b5e58fbc 100644 --- a/docs/workflow/editing-and-debugging.md +++ b/docs/workflow/editing-and-debugging.md @@ -19,19 +19,20 @@ The repository has a number of Visual Studio Solutions files (`*.sln`) that are * `src\coreclr\System.Private.CoreLib\System.Private.CorLib.sln` - This solution is for all managed (C#) code that is defined in the runtime itself. This is all class library support of one form or another. - * `artifacts\obj\coreclr\windows..\CoreCLR.sln` - this solution contains most native (C++) projects + * `artifacts\obj\coreclr\windows..\ide\CoreCLR.sln` - this solution contains most native (C++) projects associated with the repository, including * `coreclr` - This is the main runtime DLL (the GC, class loader, interop are all here) * `corjit` - This is the Just In Time (JIT) compiler that compiles .NET Intermediate language to native code. * `corerun` - This is the simple host program that can run a .NET application * `crossgen` - This is the host program that runs the JIT compiler and produces .NET Native images (`*.ni.dll`) for C# code. + * This project can be automatically generated and opened in Visual Studio by running `./build.cmd -vs CoreCLR.sln -a -c ` from the root of the repository. Thus opening one of these two solution files (double clicking on them in Explorer) is typically all you need to do most editing. Notice that the CoreCLR solution is under the `artifacts` directory. This is because it is created as part of the build. -Thus you can only launch this solution after you have built at least once. +Thus you can only launch this solution after you have built at least once with the `-msbuild` flag or run the `./build.cmd -vs CoreCLR.sln` command line with the specified architecture and configuration. * See [Debugging CoreCLR](debugging/coreclr/debugging.md) diff --git a/eng/build.ps1 b/eng/build.ps1 index dc1883ae26bd30..c3429a032bd410 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -52,7 +52,7 @@ function Get-Help() { Write-Host " [Default: Minimal]" Write-Host " -vs Open the solution with Visual Studio using the locally acquired SDK." Write-Host " Path or any project or solution name is accepted." - Write-Host " (Example: -vs Microsoft.CSharp)" + Write-Host " (Example: -vs Microsoft.CSharp or -vs CoreCLR.sln)" Write-Host "" Write-Host "Actions (defaults to -restore -build):" From 201e3f24ff973b3ee881a4b711db21763bb90b04 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 19 Mar 2021 12:33:35 -0700 Subject: [PATCH 17/20] Fix generating runtimeinfo. Centralize the setup in runtimeinfo/CMakeLists.txt. Add dependency on inject_debug_resources since that's what was touching coreclr.dll, making it dirty and leading to a rebuild/link of the single file host. --- eng/native/functions.cmake | 24 ----------- src/coreclr/debug/runtimeinfo/CMakeLists.txt | 30 +++++++++++-- src/coreclr/dlls/mscordac/CMakeLists.txt | 6 --- src/coreclr/dlls/mscordbi/CMakeLists.txt | 6 --- .../dlls/mscoree/coreclr/CMakeLists.txt | 42 ++++++++++++------- 5 files changed, 53 insertions(+), 55 deletions(-) diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 61ebbc82709fcf..ae4c66091d3838 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -466,30 +466,6 @@ function(add_executable_clr) _add_executable(${ARGV}) endfunction() -function(generate_module_index Target ModuleIndexFile) - if(CLR_CMAKE_HOST_WIN32) - set(scriptExt ".cmd") - else() - set(scriptExt ".sh") - endif() - - add_custom_command( - OUTPUT ${ModuleIndexFile} - COMMAND ${CLR_ENG_NATIVE_DIR}/genmoduleindex${scriptExt} $ ${ModuleIndexFile} - DEPENDS ${Target} - COMMENT "Generating ${Target} module index file -> ${ModuleIndexFile}" - ) - - set_source_files_properties( - ${ModuleIndexFile} - PROPERTIES GENERATED TRUE - ) - - add_custom_target( - ${Target}_module_index_header - ) -endfunction(generate_module_index) - # add_linker_flag(Flag [Config1 Config2 ...]) function(add_linker_flag Flag) if (ARGN STREQUAL "") diff --git a/src/coreclr/debug/runtimeinfo/CMakeLists.txt b/src/coreclr/debug/runtimeinfo/CMakeLists.txt index a7811d6ce2c2e0..5c1f0b1798eaf2 100644 --- a/src/coreclr/debug/runtimeinfo/CMakeLists.txt +++ b/src/coreclr/debug/runtimeinfo/CMakeLists.txt @@ -6,11 +6,35 @@ set(RUNTIMEINFO_SOURCES add_library_clr(runtimeinfo STATIC ${RUNTIMEINFO_SOURCES}) -add_dependencies(runtimeinfo coreclr_module_index_header) +function(generate_module_index Target ModuleIndexFile) + if(CLR_CMAKE_HOST_WIN32) + set(scriptExt ".cmd") + else() + set(scriptExt ".sh") + endif() + + add_custom_command( + OUTPUT ${ModuleIndexFile} + COMMAND ${CLR_ENG_NATIVE_DIR}/genmoduleindex${scriptExt} $ ${ModuleIndexFile} + DEPENDS ${Target} + COMMENT "Generating ${Target} module index file -> ${ModuleIndexFile}" + ) + + set_source_files_properties( + ${ModuleIndexFile} + PROPERTIES GENERATED TRUE + ) + + add_dependencies(runtimeinfo ${Target}) + target_sources(runtimeinfo PRIVATE ${ModuleIndexFile}) +endfunction(generate_module_index) + +generate_module_index(coreclr ${CMAKE_CURRENT_BINARY_DIR}/runtimemoduleindex.h) +add_dependencies(runtimeinfo inject_debug_resources_coreclr) if (NOT (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM) AND CLR_CMAKE_HOST_ARCH_AMD64)) - add_dependencies(runtimeinfo mscordaccore_module_index_header) - add_dependencies(runtimeinfo mscordbi_module_index_header) + generate_module_index(mscordaccore ${CMAKE_CURRENT_BINARY_DIR}/dacmoduleindex.h) + generate_module_index(mscordbi ${CMAKE_CURRENT_BINARY_DIR}/dbimoduleindex.h) endif() # publish runtimeinfo lib diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 91e4d66c9244ef..3ec2b96445421c 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -192,12 +192,6 @@ endif(CLR_CMAKE_HOST_UNIX) target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES}) -# Create the DAC module index header file containing the DAC build id -# for xplat and the timestamp/size on Windows. -if(FEATURE_SINGLE_FILE_DIAGNOSTICS) - generate_module_index(mscordaccore ${GENERATED_INCLUDE_DIR}/dacmoduleindex.h) -endif(FEATURE_SINGLE_FILE_DIAGNOSTICS) - # add the install targets install_clr(TARGETS mscordaccore ADDITIONAL_DESTINATIONS sharedFramework) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index a0fae4948469ff..f000748bee0d4c 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -119,11 +119,5 @@ elseif(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_WIN32) -# Create the DBI module index header file containing the DBI build id -# for xplat and the timestamp/size on Windows. -if(FEATURE_SINGLE_FILE_DIAGNOSTICS) - generate_module_index(mscordbi ${GENERATED_INCLUDE_DIR}/dbimoduleindex.h) -endif(FEATURE_SINGLE_FILE_DIAGNOSTICS) - # add the install targets install_clr(TARGETS mscordbi ADDITIONAL_DESTINATIONS sharedFramework) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index b22ccf1a6bc580..09897cd7753819 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -173,12 +173,6 @@ target_sources(coreclr_static PUBLIC $) target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} clrjit_static cee_wks_mergeable) target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED) -# Create the runtime module index header file containing the coreclr build id -# for xplat and the timestamp/size on Windows. -if(FEATURE_SINGLE_FILE_DIAGNOSTICS) - generate_module_index(coreclr ${GENERATED_INCLUDE_DIR}/runtimemoduleindex.h) -endif(FEATURE_SINGLE_FILE_DIAGNOSTICS) - if(CLR_CMAKE_TARGET_WIN32) # Add dac table & debug resource to coreclr get_include_directories(INC_DIR) @@ -204,32 +198,48 @@ if(CLR_CMAKE_TARGET_WIN32) endif() add_custom_command( - DEPENDS coreclr singlefilehost mscordaccore mscordbi ${CLR_DIR}/debug/daccess/daccess.cpp - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp + DEPENDS coreclr mscordaccore mscordbi ${CLR_DIR}/debug/daccess/daccess.cpp + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/debug/daccess/daccess.cpp # make and inject dactable for coreclr COMMAND cmd /c ${CLR_REPO_ROOT_DIR}/dotnet.cmd exec ${CMAKE_INSTALL_PREFIX}/DacTableGen/DacTableGen.dll /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:$ /dll:$ /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$ + # make CLRDEBUGINFO resource and inject into coreclr + COMMAND GenClrDebugResource /dac:$ /dbi:$ /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin + COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$ /name:CLRDEBUGINFO + + # inject MINIDUMP_AUXILIARY_PROVIDER into coreclr + COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$ /name:MINIDUMP_AUXILIARY_PROVIDER + + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp + COMMENT Add dactable, debug resources, and dump helper resources to coreclr + ) + + if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) + add_custom_target(inject_debug_resources_coreclr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp) + endif() + + add_custom_command( + DEPENDS singlefilehost mscordaccore mscordbi ${CLR_DIR}/debug/daccess/daccess.cpp + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp + COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/debug/daccess/daccess.cpp + # make and inject dactable for singlefilehost COMMAND cmd /c ${CLR_REPO_ROOT_DIR}/dotnet.cmd exec ${CMAKE_INSTALL_PREFIX}/DacTableGen/DacTableGen.dll /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:$ /dll:$ /bin:${CMAKE_CURRENT_BINARY_DIR}/sfh.bin COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/sfh.bin /dll:$ - # make CLRDEBUGINFO resource and inject into coreclr and singlefilehost + # make CLRDEBUGINFO resource and inject into singlefilehost COMMAND GenClrDebugResource /dac:$ /dbi:$ /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin - COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$ /name:CLRDEBUGINFO COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$ /name:CLRDEBUGINFO - # inject MINIDUMP_AUXILIARY_PROVIDER into coreclr - COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$ /name:MINIDUMP_AUXILIARY_PROVIDER - - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp - COMMENT Add dactable, debug resources, and dump helper resources to coreclr and singlefilehost + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp + COMMENT Add dactable, debug resources, and dump helper resources to singlefilehost ) if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) - add_custom_target(inject_debug_resources ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp) + add_custom_target(inject_debug_resources_singlefilehost ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp) endif() endif(CLR_CMAKE_TARGET_WIN32) From f15c8970abde53459082f2a14ee224f1fe9ca0db Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 19 Mar 2021 12:37:30 -0700 Subject: [PATCH 18/20] Fix cross-component build. --- src/coreclr/debug/runtimeinfo/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coreclr/debug/runtimeinfo/CMakeLists.txt b/src/coreclr/debug/runtimeinfo/CMakeLists.txt index 5c1f0b1798eaf2..8f0de9992e6fb2 100644 --- a/src/coreclr/debug/runtimeinfo/CMakeLists.txt +++ b/src/coreclr/debug/runtimeinfo/CMakeLists.txt @@ -30,7 +30,9 @@ function(generate_module_index Target ModuleIndexFile) endfunction(generate_module_index) generate_module_index(coreclr ${CMAKE_CURRENT_BINARY_DIR}/runtimemoduleindex.h) -add_dependencies(runtimeinfo inject_debug_resources_coreclr) +if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) + add_dependencies(runtimeinfo inject_debug_resources_coreclr) +endif() if (NOT (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM) AND CLR_CMAKE_HOST_ARCH_AMD64)) generate_module_index(mscordaccore ${CMAKE_CURRENT_BINARY_DIR}/dacmoduleindex.h) From b4563e069d0242267e0daecf8274a752b6f42f13 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 22 Mar 2021 10:20:49 -0700 Subject: [PATCH 19/20] Don't double-specify optimization levels. We already specify a level higher up in this file for Release builds. --- src/libraries/Native/Windows/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index a4020ae824e167..77b6d979c7a82c 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -79,7 +79,6 @@ list(APPEND __SharedLinkArgs /GUARD:CF) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") add_compile_options($<$:/GL>) -add_compile_options($<$:/O1>) list(APPEND __LinkLibraries $<$:libcmtd.lib>) list(APPEND __LinkLibraries $<$:libcmt.lib>) From 6b617aad203ac398af8bc1bbf2f3e9a6a860f1ed Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 24 Mar 2021 10:03:32 -0700 Subject: [PATCH 20/20] Apply suggestions from code review Co-authored-by: Juan Hoyos --- docs/workflow/debugging/coreclr/debugging.md | 4 ++-- src/coreclr/debug/runtimeinfo/CMakeLists.txt | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/workflow/debugging/coreclr/debugging.md b/docs/workflow/debugging/coreclr/debugging.md index da379ceb264534..4e8d8c00b95dbc 100644 --- a/docs/workflow/debugging/coreclr/debugging.md +++ b/docs/workflow/debugging/coreclr/debugging.md @@ -13,7 +13,7 @@ Debugging CoreCLR on Windows 1. Run `./build.cmd -vs coreclr.sln -a -c `. This will create and launch the CoreCLR solution in VS for the specified architecture and configuration. - Method 2: Manually build and open the solution. 1. Perform a build of the repo with the `-msbuild` flag. - 2. Open solution \\artifacts\obj\coreclr\windows.\.\\ide\CoreCLR.sln in Visual Studio. \ and \ are based + 2. Open solution `\\artifacts\obj\coreclr\windows.\.\\ide\CoreCLR.sln` in Visual Studio. `` and `` are based on type of build you did. By default they are 'x64' and 'Debug'. 2. Right-click the INSTALL project and choose ‘Set as StartUp Project’ 3. Bring up the properties page for the INSTALL project @@ -33,7 +33,7 @@ Debugging CoreCLR on Windows 10. Press F11 to start debugging at wmain in corerun (or set a breakpoint in source and press F5 to run to it) 1. As an example, set a breakpoint for the EEStartup function in ceemain.cpp to break into CoreCLR startup. -Steps 1-10 only need to be done once, and then (11) can be repeated whenever you want to start debugging. The above can be done with Visual Studio 2019 as writing. +Steps 1-9 only need to be done once as long as there's been no changes to the CMake files in the repository. Afterwards, step 10 can be repeated whenever you want to start debugging. The above can be done with Visual Studio 2019 as writing. Keeping with latest version of Visual Studio is recommended. ### Using SOS with windbg or cdb on Windows ### diff --git a/src/coreclr/debug/runtimeinfo/CMakeLists.txt b/src/coreclr/debug/runtimeinfo/CMakeLists.txt index 8f0de9992e6fb2..c4ad348e6b736f 100644 --- a/src/coreclr/debug/runtimeinfo/CMakeLists.txt +++ b/src/coreclr/debug/runtimeinfo/CMakeLists.txt @@ -32,9 +32,6 @@ endfunction(generate_module_index) generate_module_index(coreclr ${CMAKE_CURRENT_BINARY_DIR}/runtimemoduleindex.h) if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) add_dependencies(runtimeinfo inject_debug_resources_coreclr) -endif() - -if (NOT (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM) AND CLR_CMAKE_HOST_ARCH_AMD64)) generate_module_index(mscordaccore ${CMAKE_CURRENT_BINARY_DIR}/dacmoduleindex.h) generate_module_index(mscordbi ${CMAKE_CURRENT_BINARY_DIR}/dbimoduleindex.h) endif()