未验证 提交 8c6a049c 编写于 作者: J Jeremy Koritzinsky 提交者: GitHub

Enable using the Ninja generator instead of Visual Studio on Windows builds. (#41897)

* Move DacTableGen out of the CMake build and into tools-local.

* Attempt: usenmakefiles means ninja.

* Make changes to Windows build to support non-VS generators like ninja.

* Use CMake 3.16 PCHs.

* Remove explicit process count.

* Build and run DacTableGen via the .NET CLI we pull down for the build instead of via CMake.

* Update configurecompiler.cmake to specify language (needed for Ninja).
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Get Ninja build working again.

* Pass configuration to cmake configure step for Ninja build.

* Rename flag

* Fix configure step for cross-arch native build
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Support building via Ninja for coreclr via an MSBuild property
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Implement support for opening the CoreCLR solution in VS via the -vs flag.

* Fix setting generator to Ninja.

* Merge libraries gen-buildsys-win.bat with runtime gen-buildsys.cmd to share windows cmake configure infra.

* Enable building libraries native build with ninja.

* Centralize setting CMAKE_SYSTEM_VERSION for windows builds.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Update host build to use shared gen-buildsys.cmd

* Fix multi-config generator detection.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Exit with success when we build successfully.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Enable and fix up Ninja build for hosts.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Only link delayimp.lib on Windows
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Remove "overriding /W3 with /W1" warning in Ninja build of hosts by turning on /W3 and disabling any new warnings we hit.

* Reduce command line override warnings by adopting the MSVC_RUNTIME_LIBRARY abstraction feature in CMake 3.14+ (below the minimum requirement on Windows).

* Use the delayed expansion syntax to correctly pass in the config to cmake.

* Move all usages of MSVC runtime library selection to the CMake abstraction to reduce console spew about overridden flags.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Condition the rest of the compiler options correctly so they don't show up as invalid parameter warnings for assembly builds.

* Correctly build DIALib and DacTableGen as AnyCPU

* Fix WRITE_BARRIER_CHECK define
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Fix passing arch for MSBuild build.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Configure ASM compiler command line format in configurecompiler.cmake and use CMake's assembly compilation step to build ASM files for ARM/ARM64 instead of manually building them and adding the generated files as additional sources.

* Cleanup after fixing ARM/ARM64 support.

* Rename variable

* Condition PCH's for C++-only as needed to fix using them on non-Windows (where we compile C as C instead of as C++).

* Fix CoreCLR native test build on windows to point to new gen-buildsys location.

* Add missing compilation options in Ninja build that are implicitly defined in the MSBuild build.

* Disable analyzers for DacTableGen. Remove /MAP linker flag (that's for local testing).

* Upgrade to CMake 3.16.4

* Don't warn on unused variables in CMake (these usually vary on platform/config)
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Manually compile ARM and ARM64 asm files when using the VS generator since it doesn't support emitting MARMASM item types in projects (and as a result cannot compile ARM or ARM64 asm without assistance).

* Enable CMake policy in test build to use CMAKE_MSVC_RUNTIME_LIBRARY variable.

* Update initially disabled warnings in host.

* Add -ninja arg to root scripts to enable using Ninja.

* Enable using Ninja in CoreCLR CI.

* Try to fix passing the -ninja arg in yaml.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Add ninja to the Windows invocation

* Fix 2-phase cross targeting to do one phase at a time and initialize the VC++ environment for the correct build tools each time instead of interleaving them and relying on Visual Studio to handle the differing targets.

* Restore old /Ox optimization setting for Release.

* Fix typos, don't pass exception flags to C files.

* Remove unneeded pragma.

* Fix .pgd file installation.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Add mention of the `-ninja` flag in the Building CoreCLR documentation.
Signed-off-by: NJeremy Koritzinsky <jekoritz@microsoft.com>

* Mention installation locations for Ninja and warn while building if CMake is older than 3.16.0.

* Update docs/workflow/requirements/windows-requirements.md
上级 33056a90
......@@ -22,6 +22,13 @@ CoreCLR also supports a 'checked' build type which has asserts enabled like 'deb
./build.sh -subset clr -configuration checked
```
If you want to use Ninja to drive the native build instead of Visual Studio MSBuild (on Windows) or Make (on non-Windows), you can pass the `-ninja` flag to the build script as follows:
```
./build.cmd -subset clr -ninja
```
We recommend using Ninja for building the project on Windows since it more efficiently uses the build machine's resources for the native runtime build in comparison to Visual Studio's MSBuild.
To pass extra compiler/linker flags to the coreclr build, set the environment variables `EXTRA_CFLAGS`, `EXTRA_CXXFLAGS` and `EXTRA_LDFLAGS` as needed. Don't set `CFLAGS`/`CXXFLAGS`/`LDFLAGS` directly as that might lead to configure-time tests failing.
This will produce outputs as follows:
......
......@@ -57,11 +57,12 @@ Install the following packages:
- lttng-ust
- krb5
- openssl (optional)
- ninja (optional, enables building native code with ninja instead of make)
The lines to install all the packages above using package manager.
```sh
sudo pkg install --yes libunwind icu libinotify lttng-ust krb5 cmake autoconf automake openssl
sudo pkg install --yes libunwind icu libinotify lttng-ust krb5 cmake autoconf automake openssl ninja
```
Additionally, working dotnet cli with SDK is needed. On other platforms this would be downloaded automatically during build but it is not currently available for FreeBSD.
......
......@@ -50,6 +50,7 @@ Install the following packages for the toolchain:
- libkrb5-dev
- libnuma-dev (optional, enables numa support)
- zlib1g-dev
- ninja (optional, enables building native code with ninja instead of make)
The following dependencies are needed if Mono Runtime is enabled (default behavior):
......@@ -61,7 +62,7 @@ The following dependencies are needed if Mono Runtime is enabled (default behavi
sudo apt-get install -y cmake llvm-9 clang-9 autoconf automake \
libtool build-essential python curl git lldb-6.0 liblldb-6.0-dev \
libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev \
libssl-dev libnuma-dev libkrb5-dev zlib1g-dev
libssl-dev libnuma-dev libkrb5-dev zlib1g-dev ninja
```
You now have all the required components.
......@@ -28,8 +28,9 @@ Install the following packages:
- openssl 1.1
- pkg-config
- python3
- ninja (optional, enables building native code with ninja instead of make)
You can install all the packages above using Homebrew by running this command in the repository root:
You can install all the required packages above using Homebrew by running this command in the repository root:
```
brew bundle --no-lock --file eng/Brewfile
......
......@@ -42,7 +42,13 @@ The dotnet/runtime repository requires at least Visual Studio 2019 16.6.
- Add its location (e.g. C:\Program Files (x86)\CMake\bin) to the PATH environment variable.
The installation script has a check box to do this, but you can do it yourself after the fact following the instructions at [Adding to the Default PATH variable](#adding-to-the-default-path-variable).
The dotnet/runtime repository requires at least CMake 3.15.5.
The dotnet/runtime repository recommends using CMake 3.16.0 or newer, but works with CMake 3.15.5.
## Ninja (optional)
- Install Ninja in one of the two following ways
- [Download the executable](https://github.com/ninja-build/ninja/releases) and add its location to [the Default PATH variable](#adding-to-the-default-path-variable).
- [Install via a package manager](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages), which should automatically add it to the PATH environment variable.
## Python
......
......@@ -86,6 +86,7 @@
<ItemGroup>
<!-- CoreClr -->
<SubsetName Include="Clr" Description="The CoreCLR runtime, LinuxDac, CoreLib (+ native), tools and packages." />
<SubsetName Include="Clr.DacTools" Description="Managed tools that support building a runtime that supports debugging (such as DacTableGen)." />
<SubsetName Include="Clr.Runtime" Description="The CoreCLR .NET runtime." />
<SubsetName Include="Clr.PalTests" Description="The CoreCLR PAL tests." />
<SubsetName Include="Clr.PalTestList" Description="Generate the list of the CoreCLR PAL tests. When using the command line, use Clr.PalTests instead." />
......@@ -148,6 +149,12 @@
<ProjectToBuild Include="$(CoreClrProjectRoot)src\System.Private.CoreLib\System.Private.CoreLib.csproj" Category="clr" />
</ItemGroup>
<ItemGroup Condition="'$(TargetOS)' == 'Windows_NT' and ($(_subset.Contains('+clr.dactools+')) or $(_subset.Contains('+clr.runtime+')))">
<ProjectToBuild Include="$(CoreClrProjectRoot)src\ToolBox\SOS\DacTableGen\DacTableGen.csproj;
$(CoreClrProjectRoot)src\ToolBox\SOS\DIALib\DIALib.ilproj"
Category="clr"/>
</ItemGroup>
<PropertyGroup Condition="$(_subset.Contains('+clr.runtime+'))">
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrRuntimeSubset=true;ClrJitSubset=true</ClrRuntimeBuildSubsets>
</PropertyGroup>
......
......@@ -16,6 +16,7 @@ Param(
[ValidateSet("Debug","Release","Checked")][string][Alias('rc')]$runtimeConfiguration,
[ValidateSet("Debug","Release")][string][Alias('lc')]$librariesConfiguration,
[ValidateSet("CoreCLR","Mono")][string][Alias('rf')]$runtimeFlavor,
[switch]$ninja,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)
......@@ -74,6 +75,9 @@ function Get-Help() {
Write-Host " -testscope Scope tests, allowed values: innerloop, outerloop, all."
Write-Host ""
Write-Host "Native build settings:"
Write-Host " -ninja Use Ninja instead of MSBuild to run the native build."
Write-Host "Command-line arguments not listed above are passed through to MSBuild."
Write-Host "The above arguments can be shortened as much as to be unambiguous."
Write-Host "(Example: -con for configuration, -t for test, etc.)."
......@@ -117,9 +121,28 @@ if ($subset -eq 'help') {
}
if ($vs) {
. $PSScriptRoot\common\tools.ps1
if (-Not (Test-Path $vs)) {
if ($vs -ieq "coreclr.sln") {
# If someone passes in coreclr.sln (case-insensitive),
# launch the generated CMake solution.
$archToOpen = $arch[0]
$configToOpen = $configuration[0]
if ($runtimeConfiguration) {
$configToOpen = $runtimeConfiguration
}
$vs = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "artifacts\obj\coreclr" | Join-Path -ChildPath "Windows_NT.$archToOpen.$((Get-Culture).TextInfo.ToTitleCase($configToOpen))" | 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"
if ($lastExitCode -ne 0) {
Write-Error "Failed to generate the CoreCLR solution file."
exit 1
}
if (-Not (Test-Path $vs)) {
Write-Error "Unable to find the CoreCLR solution file at $vs."
}
}
}
elseif (-Not (Test-Path $vs)) {
$solution = $vs
if ($runtimeFlavor -eq "Mono") {
......@@ -153,6 +176,8 @@ if ($vs) {
}
}
}
. $PSScriptRoot\common\tools.ps1
# This tells .NET Core to use the bootstrapped runtime
$env:DOTNET_ROOT=InitializeDotNetCli -install:$true -createSdkLocationFile:$true
......@@ -204,6 +229,7 @@ foreach ($argument in $PSBoundParameters.Keys)
"allconfigurations" { $arguments += " /p:BuildAllConfigurations=true" }
"properties" { $arguments += " " + $properties }
"verbosity" { $arguments += " -$argument " + $($PSBoundParameters[$argument]) }
"ninja" { $arguments += " /p:Ninja=$($PSBoundParameters[$argument])" }
# configuration and arch can be specified multiple times, so they should be no-ops here
"configuration" {}
"arch" {}
......
......@@ -77,6 +77,7 @@ usage()
echo " --gccx.y Optional argument to build using gcc version x.y."
echo " --portablebuild Optional argument: set to false to force a non-portable build."
echo " --keepnativesymbols Optional argument: set to true to keep native symbols/debuginfo in generated binaries."
echo " --ninja Optional argument: set to true to use Ninja instead of Make to run the native build."
echo ""
echo "Command line arguments starting with '/p:' are passed through to MSBuild."
......@@ -417,6 +418,26 @@ while [[ $# > 0 ]]; do
shift 2
;;
-ninja)
if [ -z ${2+x} ]; then
arguments="$arguments /p:Ninja=true"
shift 1
else
ninja="$(echo "$2" | awk '{print tolower($0)}')"
if [ "$ninja" = true ]; then
arguments="$arguments /p:Ninja=true"
shift 2
elif [ "$ninja" = false ]; then
arguments="$arguments /p:Ninja=false"
shift 2
else
arguments="$arguments /p:Ninja=true"
shift 1
fi
fi
;;
*)
extraargs="$extraargs $1"
shift 1
......
......@@ -451,27 +451,48 @@ endif(CLR_CMAKE_HOST_UNIX)
if (MSVC)
# Compile options for targeting windows
add_compile_options(/TP) # compile all files as C++
add_compile_options(/nologo) # Suppress Startup Banner
add_compile_options(/W3) # set warning level to 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
add_compile_options(/Gm-) # disable minimal rebuild
add_compile_options(/Zp8) # pack structs on 8-byte boundary
add_compile_options(/Gy) # separate functions for linker
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /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)
add_compile_options(/Zm200) # Specify Precompiled Header Memory Allocation Limit of 150MB
add_compile_options(/Zc:strictStrings) # Disable string-literal to char* or wchar_t* conversion
add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/TP>) # compile all files as C++
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/nologo>) # Suppress Startup Banner
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W3>) # set warning level to 3
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oi>) # enable intrinsics
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oy->) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gm->) # disable minimal rebuild
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zp8>) # pack structs on 8-byte boundary
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gy>) # separate functions for linker
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/GS>) # Explicitly enable the buffer security checks
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/fp:precise>) # Enable precise floating point
# disable C++ RTTI
# /GR is added by default by CMake, so remove it manually.
string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/FC>) # use full pathnames in diagnostics
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/MP>) # Build with Multiple Processes (number of processes equal to the number of processors)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zm200>) # Specify Precompiled Header Memory Allocation Limit of 150MB
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:strictStrings>) # Disable string-literal to char* or wchar_t* conversion
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:wchar_t>) # wchar_t is a built-in type.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:inline>) # All inline functions must have their definition available in the current translation unit.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:forScope>) # Enforce standards-compliant for scope.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4960>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4961>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4603>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4627>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4838>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4456>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4457>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4458>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4459>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4091>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4640>)
# Disable Warnings:
# 4291: Delete not defined for new, c++ exception may cause leak.
# 5105: Windows SDK headers use 'defined' operator in some macros
add_compile_options(/wd4291 /wd5105)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4291>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd5105>)
# Treat Warnings as Errors:
# 4007: 'main' : must be __cdecl.
......@@ -480,7 +501,12 @@ if (MSVC)
# 4551: Function call missing argument list.
# 4700: Local used w/o being initialized.
# 4806: Unsafe operation involving type 'bool'.
add_compile_options(/we4007 /we4013 /we4102 /we4551 /we4700 /we4806)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4007>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4013>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4102>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4551>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4700>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4806>)
# Set Warning Level 3:
# 4092: Sizeof returns 'unsigned long'.
......@@ -491,26 +517,32 @@ if (MSVC)
# 4212: Function declaration used ellipsis.
# 4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX.
# 35038: data member 'member1' will be initialized after data member 'member2'.
add_compile_options(/w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530 /w35038)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34092>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34121>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34125>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34130>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34132>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34212>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34530>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w35038>)
# Set Warning Level 4:
# 4177: Pragma data_seg s/b at global scope.
add_compile_options(/w44177)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w44177>)
add_compile_options(/Zi) # enable debugging information
add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files.
add_compile_options(/source-charset:utf-8) # Force MSVC to compile source as UTF-8.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zi>) # enable debugging information
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/ZH:SHA_256>) # use SHA256 for generating hashes of compiler processed source files.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/source-charset:utf-8>) # Force MSVC to compile source as UTF-8.
if (CLR_CMAKE_HOST_ARCH_I386)
add_compile_options(/Gz)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Gz>)
endif (CLR_CMAKE_HOST_ARCH_I386)
add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/GL>)
add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<CONFIG:Checked>>:/O1>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>>:/GL>)
if (CLR_CMAKE_HOST_ARCH_AMD64)
# The generator expression in the following command means that the /homeparams option is added only for debug builds
add_compile_options($<$<CONFIG:Debug>:/homeparams>) # Force parameters passed in registers to be written to the stack
# The generator expression in the following command means that the /homeparams option is added only for debug builds for C and C++ source files
add_compile_options($<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C,CXX>>:/homeparams>) # Force parameters passed in registers to be written to the stack
endif (CLR_CMAKE_HOST_ARCH_AMD64)
# enable control-flow-guard support for native components for non-Arm64 builds
......@@ -524,9 +556,7 @@ if (MSVC)
# For Release builds, we shall dynamically link into uCRT [ucrtbase.dll] (which is pushed down as a Windows Update on downlevel OS) but
# wont do the same for debug/checked builds since ucrtbased.dll is not redistributable and Debug/Checked builds are not
# production-time scenarios.
add_compile_options($<$<OR:$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>,$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:/MT>)
add_compile_options($<$<AND:$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:/MTd>)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<AND:$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>,$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>>:Debug>)
add_compile_options($<$<COMPILE_LANGUAGE:ASM_MASM>:/ZH:SHA_256>)
......@@ -535,6 +565,8 @@ if (MSVC)
add_definitions(-DDISABLE_CONTRACTS)
endif (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
# Don't display the output header when building RC files.
add_compile_options($<$<COMPILE_LANGUAGE:RC>:/nologo>)
endif (MSVC)
if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
......@@ -554,21 +586,14 @@ if(CLR_CMAKE_ENABLE_CODE_COVERAGE)
endif(CLR_CMAKE_ENABLE_CODE_COVERAGE)
if (CMAKE_BUILD_TOOL STREQUAL nmake)
if (CMAKE_GENERATOR MATCHES "(Makefile|Ninja)")
set(CMAKE_RC_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
endif(CMAKE_BUILD_TOOL STREQUAL nmake)
endif()
# Ensure other tools are present
if (CLR_CMAKE_HOST_WIN32)
if(CLR_CMAKE_HOST_ARCH_ARM)
# Confirm that Windows SDK is present
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
message(FATAL_ERROR "Windows SDK is required for the Arm32 build.")
else()
message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
# Explicitly specify the assembler to be used for Arm32 compile
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm\\armasm.exe" CMAKE_ASM_COMPILER)
......@@ -578,14 +603,13 @@ if (CLR_CMAKE_HOST_WIN32)
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
# use ml[64].exe as the assembler.
enable_language(ASM)
elseif(CLR_CMAKE_HOST_ARCH_ARM64)
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -g <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
# Confirm that Windows SDK is present
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
message(FATAL_ERROR "Windows SDK is required for the ARM64 build.")
else()
message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
elseif(CLR_CMAKE_HOST_ARCH_ARM64)
# Explicitly specify the assembler to be used for Arm64 compile
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)
......@@ -596,6 +620,11 @@ if (CLR_CMAKE_HOST_WIN32)
# Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly
# use ml[64].exe as the assembler.
enable_language(ASM)
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -g <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
else()
enable_language(ASM_MASM)
endif()
......
if(CLR_CMAKE_HOST_WIN32)
add_compile_options($<$<CONFIG:Debug>:/Od>)
add_compile_options($<$<CONFIG:Checked>:/O1>)
add_compile_options($<$<CONFIG:Release>:/Ox>)
add_compile_options($<$<CONFIG:RelWithDebInfo>:/O2>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Debug>>:/Od>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Checked>>:/O1>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Release>>:/Ox>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RelWithDebInfo>>:/O2>)
elseif(CLR_CMAKE_HOST_UNIX)
add_compile_options($<$<CONFIG:Debug>:-O0>)
add_compile_options($<$<CONFIG:Checked>:-O2>)
......
......@@ -126,7 +126,7 @@ function(preprocess_file inputFilename outputFilename)
if (MSVC)
add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${CMAKE_CXX_COMPILER} ${PREPROCESS_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename}
COMMAND ${CMAKE_CXX_COMPILER} ${PREPROCESS_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename} /nologo
DEPENDS ${inputFilename}
COMMENT "Preprocessing ${inputFilename}. Outputting to ${outputFilename}"
)
......@@ -143,8 +143,38 @@ function(preprocess_file inputFilename outputFilename)
PROPERTIES GENERATED TRUE)
endfunction()
# preprocess_compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
function(preprocess_compile_asm)
# preprocess_files(PreprocessedFilesList [fileToPreprocess1 [fileToPreprocess2 ...]])
function(preprocess_files PreprocessedFilesList)
set(FilesToPreprocess ${ARGN})
foreach(ASM_FILE IN LISTS FilesToPreprocess)
# Inserts a custom command in CMake build to preprocess each asm source file
get_filename_component(name ${ASM_FILE} NAME_WE)
file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
preprocess_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
list(APPEND PreprocessedFiles ${ASM_PREPROCESSED_FILE})
endforeach()
set(${PreprocessedFilesList} ${PreprocessedFiles} PARENT_SCOPE)
endfunction()
function(set_exports_linker_option exports_filename)
if(LD_GNU OR LD_SOLARIS)
# Add linker exports file option
if(LD_SOLARIS)
set(EXPORTS_LINKER_OPTION -Wl,-M,${exports_filename} PARENT_SCOPE)
else()
set(EXPORTS_LINKER_OPTION -Wl,--version-script=${exports_filename} PARENT_SCOPE)
endif()
elseif(LD_OSX)
# Add linker exports file option
set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${exports_filename} PARENT_SCOPE)
endif()
endfunction()
# compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName])
# CMake does not support the ARM or ARM64 assemblers on Windows when using the
# MSBuild generator. When the MSBuild generator is in use, we manually compile the assembly files
# using this function.
function(compile_asm)
set(options "")
set(oneValueArgs TARGET OUTPUT_OBJECTS)
set(multiValueArgs ASM_FILES)
......@@ -155,20 +185,16 @@ function(preprocess_compile_asm)
set (ASSEMBLED_OBJECTS "")
foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES})
# Inserts a custom command in CMake build to preprocess each asm source file
get_filename_component(name ${ASM_FILE} NAME_WE)
file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${name}.asm" ASM_PREPROCESSED_FILE)
preprocess_file(${ASM_FILE} ${ASM_PREPROCESSED_FILE})
# Produce object file where CMake would store .obj files for an OBJECT library.
# ex: artifacts\obj\coreclr\Windows_NT.arm64.Debug\src\vm\wks\cee_wks.dir\Debug\AsmHelpers.obj
set (OBJ_FILE "${CMAKE_CURRENT_BINARY_DIR}/${COMPILE_ASM_TARGET}.dir/${CMAKE_CFG_INTDIR}/${name}.obj")
# Need to compile asm file using custom command as include directories are not provided to asm compiler
add_custom_command(OUTPUT ${OBJ_FILE}
COMMAND "${CMAKE_ASM_MASM_COMPILER}" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_PREPROCESSED_FILE}
DEPENDS ${ASM_PREPROCESSED_FILE}
COMMENT "Assembling ${ASM_PREPROCESSED_FILE} ---> \"${CMAKE_ASM_MASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_PREPROCESSED_FILE}")
COMMAND "${CMAKE_ASM_COMPILER}" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}
DEPENDS ${ASM_FILE}
COMMENT "Assembling ${ASM_FILE} ---> \"${CMAKE_ASM_COMPILER}\" -g ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}")
# mark obj as source that does not require compile
set_source_files_properties(${OBJ_FILE} PROPERTIES EXTERNAL_OBJECT TRUE)
......@@ -180,20 +206,6 @@ function(preprocess_compile_asm)
set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE)
endfunction()
function(set_exports_linker_option exports_filename)
if(LD_GNU OR LD_SOLARIS)
# Add linker exports file option
if(LD_SOLARIS)
set(EXPORTS_LINKER_OPTION -Wl,-M,${exports_filename} PARENT_SCOPE)
else()
set(EXPORTS_LINKER_OPTION -Wl,--version-script=${exports_filename} PARENT_SCOPE)
endif()
elseif(LD_OSX)
# Add linker exports file option
set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${exports_filename} PARENT_SCOPE)
endif()
endfunction()
function(generate_exports_file)
set(INPUT_LIST ${ARGN})
list(GET INPUT_LIST -1 outputFilename)
......@@ -236,52 +248,6 @@ function(generate_exports_file_prefix inputFilename outputFilename prefix)
PROPERTIES GENERATED TRUE)
endfunction()
# target_precompile_header(TARGET targetName HEADER headerName [ADDITIONAL_INCLUDE_DIRECTORIES includeDirs])
function(target_precompile_header)
set(options "")
set(oneValueArgs TARGET HEADER)
set(multiValueArgs ADDITIONAL_INCLUDE_DIRECTORIES)
cmake_parse_arguments(PRECOMPILE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV})
if ("${PRECOMPILE_HEADERS_TARGET}" STREQUAL "")
message(SEND_ERROR "No target supplied to target_precompile_header.")
endif()
if ("${PRECOMPILE_HEADERS_HEADER}" STREQUAL "")
message(SEND_ERROR "No header supplied to target_precompile_header.")
endif()
if(MSVC)
get_filename_component(PCH_NAME ${PRECOMPILE_HEADERS_HEADER} NAME_WE)
# We need to use the $<TARGET_PROPERTY:NAME> generator here instead of the ${targetName} variable since
# CMake evaluates source file properties once per directory. If we just use ${targetName}, we end up sharing
# the same PCH between targets, which doesn't work.
set(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PCH_NAME}.$<TARGET_PROPERTY:NAME>.pch")
set(pchSourceFile "${CMAKE_CURRENT_BINARY_DIR}/${PCH_NAME}.${PRECOMPILE_HEADERS_TARGET}.cpp")
file(GENERATE OUTPUT ${pchSourceFile} CONTENT "#include \"${PRECOMPILE_HEADERS_HEADER}\"")
set(PCH_SOURCE_FILE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${PRECOMPILE_HEADERS_ADDITIONAL_INCLUDE_DIRECTORIES})
set_source_files_properties(${pchSourceFile}
PROPERTIES COMPILE_FLAGS "/Yc\"${PRECOMPILE_HEADERS_HEADER}\" /Fp\"${precompiledBinary}\""
OBJECT_OUTPUTS "${precompiledBinary}"
INCLUDE_DIRECTORIES "${PCH_SOURCE_FILE_INCLUDE_DIRECTORIES}")
get_target_property(TARGET_SOURCES ${PRECOMPILE_HEADERS_TARGET} SOURCES)
foreach (SOURCE ${TARGET_SOURCES})
get_source_file_property(SOURCE_LANG ${SOURCE} LANGUAGE)
if (("${SOURCE_LANG}" STREQUAL "C") OR ("${SOURCE_LANG}" STREQUAL "CXX"))
set_source_files_properties(${SOURCE}
PROPERTIES COMPILE_FLAGS "/Yu\"${PRECOMPILE_HEADERS_HEADER}\" /Fp\"${precompiledBinary}\""
OBJECT_DEPENDS "${precompiledBinary}")
endif()
endforeach()
# Add pchSourceFile to PRECOMPILE_HEADERS_TARGET target
target_sources(${PRECOMPILE_HEADERS_TARGET} PRIVATE ${pchSourceFile})
endif(MSVC)
endfunction()
function(strip_symbols targetName outputFilename)
if (CLR_CMAKE_HOST_UNIX)
set(strip_source_file $<TARGET_FILE:${targetName}>)
......@@ -331,7 +297,16 @@ function(strip_symbols targetName outputFilename)
set(${outputFilename} ${strip_destination_file} PARENT_SCOPE)
else(CLR_CMAKE_HOST_UNIX)
set(${outputFilename} ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb PARENT_SCOPE)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
# We can't use the $<TARGET_PDB_FILE> generator expression here since
# the generator expression isn't supported on resource DLLs.
set(${outputFilename} ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pdb PARENT_SCOPE)
else()
# We can't use the $<TARGET_PDB_FILE> generator expression here since
# the generator expression isn't supported on resource DLLs.
set(${outputFilename} ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pdb PARENT_SCOPE)
endif()
endif(CLR_CMAKE_HOST_UNIX)
endfunction()
......@@ -389,9 +364,14 @@ function(install_clr)
endif()
if(CLR_CMAKE_PGO_INSTRUMENT)
if(WIN32)
if(WIN32)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL)
else()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.pgd DESTINATION ${destination}/PGD OPTIONAL)
endif()
endif()
endif()
endforeach()
endif()
......@@ -430,6 +410,12 @@ if (CMAKE_VERSION VERSION_LESS "3.12")
endfunction()
endif()
if (CMAKE_VERSION VERSION_LESS "3.16")
# Provide a no-op polyfill for precompiled headers on old CMake versions
function(target_precompile_headers)
endfunction()
endif()
function(_add_executable)
if(NOT WIN32)
add_executable(${ARGV} ${VERSION_FILE_PATH})
......
......@@ -2,6 +2,8 @@
rem
rem This file invokes cmake and generates the build system for windows.
setlocal
set argC=0
for %%x in (%*) do Set /A argC+=1
......@@ -20,17 +22,36 @@ set __IntermediatesDir=%2
set __VSVersion=%3
set __Arch=%4
set __CmakeGenerator=Visual Studio
if /i "%__NMakeMakefiles%" == "1" (
set __CmakeGenerator=NMake Makefiles
set __UseEmcmake=0
if /i "%__Ninja%" == "1" (
set __CmakeGenerator=Ninja
) else (
if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019)
if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017)
if /i NOT "%__Arch%" == "wasm" (
if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019)
if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017)
if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%__Arch%" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
) else (
set __CmakeGenerator=NMake Makefiles
)
)
if /i "%__Arch%" == "wasm" (
if "%EMSDK_PATH%" == "" (
echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root.
exit /B 1
)
if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%__Arch%" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
if "%EMSCRIPTEN_ROOT%" == "" (
set EMSCRIPTEN_ROOT="%EMSDK_PATH/upstream/emscripten%"
)
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" "-DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/Emscripten.cmake"
set __UseEmcmake=1
) else (
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0"
)
:loop
......@@ -40,13 +61,19 @@ shift
goto loop
:end_loop
"%CMakePath%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams% -G "%__CmakeGenerator%" -S %__SourceDir% -B %__IntermediatesDir%
set __ExtraCmakeParams="-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams%
if /i "%__UseEmcmake%" == "1" (
emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
) else (
"%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
)
endlocal
exit /B !errorlevel!
exit /B %errorlevel%
:USAGE
echo "Usage..."
echo "gen-buildsys.cmd <path to top level CMakeLists.txt> <path to location for intermediate files> <VSVersion>"
echo "gen-buildsys.cmd <path to top level CMakeLists.txt> <path to location for intermediate files> <VSVersion> <arch>"
echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
echo "Specify the VSVersion to be used - VS2017 or VS2019"
EXIT /B 1
......@@ -103,6 +103,7 @@ pushd "$3"
# Include CMAKE_USER_MAKE_RULES_OVERRIDE as uninitialized since it will hold its value in the CMake cache otherwise can cause issues when branch switching
$cmake_command \
--no-warn-unused-cli \
-G "$generator" \
"-DCMAKE_BUILD_TYPE=$buildtype" \
"-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \
......
......@@ -64,7 +64,10 @@ try {
$version = [Version]$(& $cmakePath --version | Select-String -Pattern '\d+\.\d+\.\d+' | %{$_.Matches.Value})
if ($version -lt [Version]"3.14.0") {
Throw "This repository requires CMake 3.14. The newest version of CMake installed is $version. Please install CMake 3.14 or newer from https://cmake.org/download/ and ensure it is on your path."
Throw "This repository requires CMake 3.14 and recommends CMake 3.16. The newest version of CMake installed is $version. Please install CMake 3.16 or newer from https://cmake.org/download/ and ensure it is on your path."
}
elseif ($version -lt [Version]"3.16.0") {
[System.Console]::Error.WriteLine("CMake 3.16 or newer is recommended for building this repository. The newest version of CMake installed is $version. Please install CMake 3.16 or newer from https://cmake.org/download/ and ensure it is on your path.")
}
[System.Console]::WriteLine("set CMakePath=" + $cmakePath)
......
......@@ -118,6 +118,12 @@ jobs:
- name: clrBuildPALTestsBuildArg
value: '-paltests '
- name: ninjaArg
value: ''
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
- name: ninjaArg
value: '-ninja'
- ${{ parameters.variables }}
steps:
......@@ -147,12 +153,17 @@ jobs:
df -h
displayName: Disk Usage before Build
# Build DacTableGen (Windows-only)
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
- script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -subset clr.dactools $(crossArg) -arch $(archType) $(osArg) -c $(buildConfig) $(officialBuildIdArg) -ci /bl:$(Build.SourcesDirectory)artifacts/logs/$(buildConfig)/DacTools.binlog
displayName: Build managed product components and packages
# Build CoreCLR Runtime
- ${{ if ne(parameters.osGroup, 'Windows_NT') }}:
- script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(officialBuildIdArg) $(clrInterpreterBuildArg)
- script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(ninjaArg) $(officialBuildIdArg) $(clrInterpreterBuildArg)
displayName: Build CoreCLR Runtime
- ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
- script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(officialBuildIdArg) $(clrInterpreterBuildArg)
- script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(ninjaArg) $(enforcePgoArg) $(officialBuildIdArg) $(clrInterpreterBuildArg)
displayName: Build CoreCLR Runtime
- ${{ if in(parameters.osGroup, 'OSX', 'iOS','tvOS') }}:
......
......@@ -8,7 +8,7 @@
"dotnet": "5.0.100-rc.2.20479.15"
},
"native-tools": {
"cmake": "3.14.5",
"cmake": "3.16.4",
"python3": "3.7.1"
},
"msbuild-sdks": {
......
cmake_minimum_required(VERSION 3.6.2)
cmake_policy(SET CMP0042 NEW)
if (CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15)
cmake_policy(SET CMP0091 NEW)
endif()
# Set the project name
project(CoreCLR)
include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
if (CLR_CMAKE_HOST_WIN32)
message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}")
endif (CLR_CMAKE_HOST_WIN32)
if(MSVC)
add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions)
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/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)
......@@ -96,7 +95,7 @@ add_subdirectory(src/tools/aot/jitinterface)
# All of the compiler options are specified in file compileoptions.cmake
# Do not add any new options here. They should be added in compileoptions.cmake
if(CLR_CMAKE_HOST_WIN32)
add_compile_options(/Zl) # omit default library name in .OBJ
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zl>) # omit default library name in .OBJ
endif(CLR_CMAKE_HOST_WIN32)
#--------------------------------
......
......@@ -93,6 +93,7 @@ set __CrossArch2=
set __CrossOS=0
set __PgoOptDataPath=
set __CMakeArgs=
set __Ninja=0
@REM CMD has a nasty habit of eating "=" on the argument list, so passing:
@REM -priority=1
......@@ -166,7 +167,7 @@ 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" == "-usenmakemakefiles" (set __NMakeMakefiles=1&set __ConfigureOnly=1&set __BuildNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "-ninja" (set __Ninja=1&set __BuildNative=1&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)
......@@ -182,7 +183,8 @@ if /i "%1" == "skipnative" (set __BuildNative=0&set processedArgs=!proc
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" == "usenmakemakefiles" (set __NMakeMakefiles=1&set __ConfigureOnly=1&set __BuildNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
REM Keep around usenmakemakefiles for usage by the jit-format tool
if /i "%1" == "usenmakemakefiles" (set __Ninja=1&set __BuildNative=1&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" == "nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "enforcepgo" (set __EnforcePgo=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
......@@ -282,7 +284,7 @@ set "__IntermediatesDir=%__RootBinDir%\obj\coreclr\%__TargetOS%.%__BuildArch%.%_
set "__LogsDir=%__RootBinDir%\log\!__BuildType!"
set "__MsbuildDebugLogsDir=%__LogsDir%\MsbuildDebugLogs"
set "__ArtifactsIntermediatesDir=%__RepoRootDir%\artifacts\obj\coreclr\"
if "%__NMakeMakefiles%"=="1" (set "__IntermediatesDir=%__RootBinDir%\nmakeobj\%__TargetOS%.%__BuildArch%.%__BuildType%")
if "%__Ninja%"=="1" (set "__IntermediatesDir=%__RootBinDir%\nmakeobj\%__TargetOS%.%__BuildArch%.%__BuildType%")
set "__PackagesBinDir=%__BinDir%\.nuget"
set "__CrossComponentBinDir=%__BinDir%"
set "__CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen"
......@@ -317,7 +319,7 @@ set __CMakeNeeded=1
if %__BuildNative%==0 if %__BuildCrossArchNative%==0 set __CMakeNeeded=0
if %__CMakeNeeded%==1 (
REM Eval the output from set-cmake-path.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\set-cmake-path.ps1"""') do %%a
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__RepoRootDir%\eng\native\set-cmake-path.ps1"""') do %%a
echo %__MsgPrefix%Using CMake from !CMakePath!
)
......@@ -446,8 +448,13 @@ if %__BuildCrossArchNative% EQU 1 (
set __CMakeBinDir=%__CrossComponentBinDir%
set "__CMakeBinDir=!__CMakeBinDir:\=/!"
set __ExtraCmakeArgs=%__CMakeClrBuildSubsetArgs% "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" %__CMakeArgs%
call "%__SourceDir%\pal\tools\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs!
if %__Ninja% EQU 1 (
set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!"
)
set __ExtraCmakeArgs=!__ExtraCmakeArgs! %__CMakeClrBuildSubsetArgs% "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" %__CMakeArgs%
call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs!
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate cross architecture native component build project %__CrossArch%!
......@@ -455,39 +462,12 @@ if %__BuildCrossArchNative% EQU 1 (
)
@if defined _echo @echo on
if NOT "%__CrossArch2%" == "" (
if not exist "%__CrossComp2IntermediatesDir%" md "%__CrossComp2IntermediatesDir%"
if /i "%__CrossArch2%" == "x86" ( set __VCBuildArch=x86 )
if /i "%__CrossArch2%" == "x64" ( set __VCBuildArch=x86_amd64 )
set __CMakeBinDir="%__CrossComponent2BinDir%"
set "__CMakeBinDir=!__CMakeBinDir:\=/!"
set __ExtraCmakeArgs=%__CMakeClrBuildSubsetArgs% "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" %__CMakeArgs%
call "%__SourceDir%\pal\tools\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossComp2IntermediatesDir%" %__VSVersion% %__CrossArch2% !__ExtraCmakeArgs!
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate cross architecture native component build project %__CrossArch2%!
goto ExitWithError
)
set __VCBuildArch=x86_amd64
if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 )
@if defined _echo @echo on
)
:SkipConfigureCrossBuild
if not exist "%__CrossCompIntermediatesDir%\CMakeCache.txt" (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: unable to find generated cross architecture native component build project %__CrossArch%!
goto ExitWithError
)
if NOT "%__CrossArch2%" == "" (
if not exist "%__CrossComp2IntermediatesDir%\CMakeCache.txt" (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: unable to find generated cross architecture native component build project %__CrossArch2%!
goto ExitWithError
)
)
if defined __ConfigureOnly goto SkipCrossCompBuild
set __BuildLogRootName=Cross
......@@ -501,8 +481,16 @@ if %__BuildCrossArchNative% EQU 1 (
set "__MsbuildBinLog=/bl:!__BinLog!"
set "__Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! !__MsbuildBinLog! !__ConsoleLoggingParameters!"
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 "%__CrossCompIntermediatesDir%" --target install --config %__BuildType% -- /nologo /m !__Logging!
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!
)
"%CMakePath%" --build %__CrossCompIntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs!
if not !errorlevel! == 0 (
set __exitCode=!errorlevel!
......@@ -512,8 +500,51 @@ if %__BuildCrossArchNative% EQU 1 (
echo !__BuildErr!
goto ExitWithCode
)
:SkipCrossCompBuild
REM } Scope environment changes end
endlocal
if NOT "%__CrossArch2%" == "" (
REM Scope environment changes start {
setlocal
echo %__MsgPrefix%Commencing build of cross architecture native components for %__TargetOS%.%__BuildArch%.%__BuildType% hosted on %__CrossArch2%
if /i "%__CrossArch2%" == "x86" ( set __VCBuildArch=x86 )
if /i "%__CrossArch2%" == "x64" ( set __VCBuildArch=x86_amd64 )
echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch!
@if defined _echo @echo on
if not exist "%__CrossComp2IntermediatesDir%" md "%__CrossComp2IntermediatesDir%"
if defined __SkipConfigure goto SkipConfigureCrossBuild2
set __CMakeBinDir="%__CrossComponent2BinDir%"
set "__CMakeBinDir=!__CMakeBinDir:\=/!"
if %__Ninja% EQU 1 (
set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!"
)
set __ExtraCmakeArgs=!__ExtraCmakeArgs! %__CMakeClrBuildSubsetArgs% "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" %__CMakeArgs%
call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossComp2IntermediatesDir%" %__VSVersion% %__CrossArch2% !__ExtraCmakeArgs!
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate cross architecture native component build project %__CrossArch2%!
goto ExitWithError
)
set __VCBuildArch=x86_amd64
if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 )
@if defined _echo @echo on
if not exist "%__CrossComp2IntermediatesDir%\CMakeCache.txt" (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: unable to find generated cross architecture native component build project %__CrossArch2%!
goto ExitWithError
)
:SkipConfigureCrossBuild2
set __BuildLogRootName=Cross2
set "__BuildLog=%__LogsDir%\!__BuildLogRootName!_%__TargetOS%__%__BuildArch%__%__BuildType%.log"
set "__BuildWrn=%__LogsDir%\!__BuildLogRootName!_%__TargetOS%__%__BuildArch%__%__BuildType%.wrn"
......@@ -525,8 +556,16 @@ if %__BuildCrossArchNative% EQU 1 (
set "__MsbuildBinLog=/bl:!__BinLog!"
set "__Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! !__MsbuildBinLog! !__ConsoleLoggingParameters!"
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 "%__CrossComp2IntermediatesDir%" --target install --config %__BuildType% -- /nologo /m !__Logging!
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!
)
"%CMakePath%" --build %__CrossComp2IntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs!
if not !errorlevel! == 0 (
set __exitCode=!errorlevel!
......@@ -536,10 +575,10 @@ if %__BuildCrossArchNative% EQU 1 (
echo !__BuildErr!
goto ExitWithCode
)
:SkipCrossCompBuild2
REM } Scope environment changes end
endlocal
)
:SkipCrossCompBuild
REM } Scope environment changes end
endlocal
)
REM =========================================================================================
......@@ -580,9 +619,12 @@ if %__BuildNative% EQU 1 (
echo %__MsgPrefix%Regenerating the Visual Studio solution
set __ExtraCmakeArgs=%__CMakeClrBuildSubsetArgs% "-DCMAKE_SYSTEM_VERSION=10.0" !___CrossBuildDefine! "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" %__CMakeArgs%
if %__Ninja% EQU 1 (
set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!"
)
call "%__SourceDir%\pal\tools\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
set __ExtraCmakeArgs=!__ExtraCmakeArgs! !___CrossBuildDefine! %__CMakeClrBuildSubsetArgs% "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native" "-DCLR_REPO_ROOT_DIR=%__RepoRootDir%" %__CMakeArgs%
call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project!
goto ExitWithError
......@@ -609,8 +651,15 @@ if %__BuildNative% EQU 1 (
set "__MsbuildBinLog=/bl:!__BinLog!"
set "__Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! !__MsbuildBinLog! !__ConsoleLoggingParameters!"
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 "%__IntermediatesDir%" --target install --config %__BuildType% -- /nologo /m !__Logging!
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!
)
"%CMakePath%" --build %__IntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs!
if not !errorlevel! == 0 (
set __exitCode=!errorlevel!
......
......@@ -20,7 +20,7 @@
'$(NoPgoOptimize)' != 'true'"
Include="-enforcepgo" />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" />
<_CoreClrBuildArg Condition="'$(NoPgoOptimize)' == 'true'" Include="-nopgooptimize" />
<_CoreClrBuildArg Condition="'$(Ninja)' == 'true'" Include="-ninja" />
<_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' != 'true'" Include="-skipruntime" />
<_CoreClrBuildArg Condition="'$(ClrJitSubset)' != 'true'" Include="-skipjit" />
<_CoreClrBuildArg Condition="'$(ClrPalTestsSubset)' == 'true'" Include="-paltests" />
......
if(CLR_CMAKE_TARGET_WIN32)
if (CMAKE_GENERATOR MATCHES "Visual Studio .*")
add_subdirectory(DacTableGen)
endif()
endif(CLR_CMAKE_TARGET_WIN32)
_install(FILES SOS_README.md DESTINATION .)
此差异已折叠。
<Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<Platform>AnyCPU</Platform>
<IsShipping>false</IsShipping>
</PropertyGroup>
</Project>
\ No newline at end of file
cmake_minimum_required(VERSION 3.8)
# Quick note: The CMake C# support is using the CSC bundled with the MSBuild that the native build runs on, not the one supplied by the local .NET SDK.
project(DacTableGen LANGUAGES CSharp)
file(TO_CMAKE_PATH "$ENV{VSInstallDir}\\DIA SDK" DIASDK_DIR)
file(COPY "${DIASDK_DIR}/bin/msdia140.dll" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
set (DIALib "${CMAKE_CURRENT_BINARY_DIR}/DIALib.dll")
FIND_PROGRAM(TLBIMP tlbimp.exe)
FIND_PROGRAM(MIDL midl.exe)
add_custom_command(
OUTPUT "${DIALib}"
COMMAND ${MIDL} /no_stamp /I "${DIASDK_DIR}/include" "${DIASDK_DIR}/idl/dia2.idl" /tlb "${CMAKE_CURRENT_BINARY_DIR}/dia2.tlb"
COMMAND ${TLBIMP} dia2.tlb /out:"${DIALib}"
)
add_custom_target(gen_dialib DEPENDS "${DIALib}")
set(DACTABLEGEN_SOURCES
cvconst.cs
diautil.cs
main.cs
MapSymbolProvider.cs
)
# DacTableGen doesn't use the defines from the rest of the build tree, so clear all of the compile definitions
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "")
set(CMAKE_CSharp_FLAGS "/platform:anycpu32bitpreferred")
add_executable(dactablegen ${DACTABLEGEN_SOURCES})
add_dependencies(dactablegen gen_dialib)
set_target_properties(dactablegen PROPERTIES VS_DOTNET_REFERENCES "System")
set_target_properties(dactablegen PROPERTIES VS_DOTNET_REFERENCE_DIALib "${DIALib}")
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<Platform>AnyCPU</Platform>
<OutputPath>$(RuntimeBinDir)\DacTableGen</OutputPath>
<IsShipping>false</IsShipping>
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="vswhere" Version="$(VSWhereVersion)" IsImplicitlyDefined="true" GeneratePathProperty="true" />
</ItemGroup>
<Target Name="ResolveDIALibToCopy" BeforeTargets="AssignTargetPaths">
<PropertyGroup>
<VSWherePath>$([MSBuild]::NormalizePath('$(Pkgvswhere)','tools','vswhere.exe'))</VSWherePath>
</PropertyGroup>
<Exec
Command="$(VSWherePath) -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath"
EchoOff="true"
ConsoleToMsBuild="true"
StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="VSInstallationPath" />
</Exec>
<ItemGroup>
<Content Include="$(VSInstallationPath)\DIA SDK\bin\amd64\msdia140.dll" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
<ItemGroup>
<ProjectReference Include="../DIALib/DIALib.ilproj" />
</ItemGroup>
</Project>
\ No newline at end of file
<Project>
<PropertyGroup>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />
</Project>
\ No newline at end of file
......@@ -5,7 +5,7 @@ add_definitions(-DSELF_NO_HOST)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
include_directories(.)
......@@ -49,7 +49,7 @@ set(MCS_SOURCES
_add_executable(mcs
${MCS_SOURCES}
)
target_precompile_header(TARGET mcs HEADER standardpch.h)
target_precompile_headers(mcs PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:standardpch.h>")
if(CLR_CMAKE_HOST_UNIX)
target_link_libraries(mcs
......@@ -65,7 +65,7 @@ else()
${STATIC_MT_CPP_LIB}
)
_install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/mcs.pdb DESTINATION PDB)
_install (FILES $<TARGET_PDB_FILE:mcs> DESTINATION PDB)
endif(CLR_CMAKE_HOST_UNIX)
_install (TARGETS mcs DESTINATION .)
......@@ -8,7 +8,7 @@ add_definitions(-DSELF_NO_HOST)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
include_directories(.)
......@@ -44,7 +44,7 @@ _add_library(superpmi-shim-collector
${SUPERPMI_SHIM_COLLECTOR_SOURCES}
)
target_precompile_header(TARGET superpmi-shim-collector HEADER standardpch.h)
target_precompile_headers(superpmi-shim-collector PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:standardpch.h>")
if(CLR_CMAKE_HOST_UNIX)
target_link_libraries(superpmi-shim-collector
......@@ -60,7 +60,7 @@ else()
${STATIC_MT_CPP_LIB}
)
_install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/superpmi-shim-collector.pdb DESTINATION PDB)
_install (FILES $<TARGET_PDB_FILE:superpmi-shim-collector> DESTINATION PDB)
endif(CLR_CMAKE_HOST_UNIX)
_install (TARGETS superpmi-shim-collector DESTINATION .)
......@@ -8,7 +8,7 @@ add_definitions(-DSELF_NO_HOST)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
include_directories(.)
......@@ -46,7 +46,7 @@ _add_library(superpmi-shim-counter
${SUPERPMI_SHIM_COUNTER_SOURCES}
)
target_precompile_header(TARGET superpmi-shim-counter HEADER standardpch.h)
target_precompile_headers(superpmi-shim-counter PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:standardpch.h>")
if(CLR_CMAKE_HOST_UNIX)
target_link_libraries(superpmi-shim-counter
......@@ -62,7 +62,7 @@ else()
${STATIC_MT_CPP_LIB}
)
_install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/superpmi-shim-counter.pdb DESTINATION PDB)
_install (FILES $<TARGET_PDB_FILE:superpmi-shim-counter> DESTINATION PDB)
endif(CLR_CMAKE_HOST_UNIX)
_install (TARGETS superpmi-shim-counter DESTINATION .)
......@@ -8,7 +8,7 @@ add_definitions(-DSELF_NO_HOST)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
include_directories(.)
......@@ -45,7 +45,7 @@ _add_library(superpmi-shim-simple
${SUPERPMI_SHIM_SIMPLE_SOURCES}
)
target_precompile_header(TARGET superpmi-shim-simple HEADER standardpch.h)
target_precompile_headers(superpmi-shim-simple PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:standardpch.h>")
if(CLR_CMAKE_HOST_UNIX)
target_link_libraries(superpmi-shim-simple
......@@ -61,7 +61,7 @@ else()
${STATIC_MT_CPP_LIB}
)
_install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/superpmi-shim-simple.pdb DESTINATION PDB)
_install (FILES $<TARGET_PDB_FILE:superpmi-shim-simple> DESTINATION PDB)
endif(CLR_CMAKE_HOST_UNIX)
_install (TARGETS superpmi-shim-simple DESTINATION .)
......@@ -9,7 +9,7 @@ add_definitions(-DUSE_COREDISTOOLS)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
include_directories(.)
......@@ -45,7 +45,7 @@ _add_executable(superpmi
${SUPERPMI_SOURCES}
)
target_precompile_header(TARGET superpmi HEADER standardpch.h)
target_precompile_headers(superpmi PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:standardpch.h>")
if(CLR_CMAKE_HOST_UNIX)
target_link_libraries(superpmi
......@@ -62,7 +62,7 @@ else()
${STATIC_MT_CPP_LIB}
)
_install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/superpmi.pdb DESTINATION PDB)
_install (FILES $<TARGET_PDB_FILE:superpmi> DESTINATION PDB)
endif(CLR_CMAKE_HOST_UNIX)
_install (TARGETS superpmi DESTINATION .)
......@@ -38,7 +38,7 @@ convert_to_absolute_path(DACCESS_SOURCES ${DACCESS_SOURCES})
add_library_clr(daccess ${DACCESS_SOURCES})
set_target_properties(daccess PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET daccess HEADER stdafx.h)
target_precompile_headers(daccess PRIVATE [["stdafx.h"]])
add_dependencies(daccess eventing_headers)
......
......@@ -2,7 +2,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
......
......@@ -50,7 +50,7 @@ set(CORDBDI_HEADERS
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
if (CLR_CMAKE_TARGET_ARCH_AMD64 OR ((CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD))
......@@ -59,7 +59,10 @@ if(CLR_CMAKE_HOST_WIN32)
if ((CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64) AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
convert_to_absolute_path(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
preprocess_compile_asm(TARGET cordbdi ASM_FILES ${CORDBDI_SOURCES_ASM_FILE} OUTPUT_OBJECTS CORDBDI_SOURCES_ASM_FILE)
preprocess_files(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
if (CMAKE_GENERATOR MATCHES "Visual Studio")
compile_asm(TARGET cordbdi ASM_FILES ${CORDBDI_SOURCES_ASM_FILE} OUTPUT_OBJECTS CORDBDI_SOURCES_ASM_FILE)
endif()
endif()
elseif(CLR_CMAKE_HOST_UNIX)
......@@ -79,5 +82,5 @@ endif (CLR_CMAKE_TARGET_WIN32)
list(APPEND CORDBDI_SOURCES ${CORDBDI_SOURCES_ASM_FILE})
add_library_clr(cordbdi STATIC ${CORDBDI_SOURCES})
target_precompile_header(TARGET cordbdi HEADER stdafx.h)
target_precompile_headers(cordbdi PRIVATE stdafx.h)
add_dependencies(cordbdi eventing_headers)
......@@ -5,5 +5,5 @@ endif (CLR_CMAKE_TARGET_WIN32)
add_library_clr(cordbee_dac ${CORDBEE_SOURCES_DAC})
set_target_properties(cordbee_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET cordbee_dac HEADER stdafx.h)
target_precompile_headers(cordbee_dac PRIVATE [["stdafx.h"]])
add_dependencies(cordbee_dac eventing_headers)
......@@ -9,7 +9,10 @@ if (CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64)
preprocess_compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS)
preprocess_files(ASM_FILE ${ASM_FILE})
if (CMAKE_GENERATOR MATCHES "Visual Studio")
compile_asm(TARGET cordbee_wks_obj ASM_FILES ${ASM_FILE} OUTPUT_OBJECTS ASM_OBJECTS)
endif()
add_library_clr(cordbee_wks_obj OBJECT ${CORDBEE_SOURCES_WKS} ${ASM_FILE} ${ASM_OBJECTS})
......@@ -37,7 +40,7 @@ else ()
endif (CLR_CMAKE_TARGET_WIN32)
target_precompile_header(TARGET cordbee_wks_obj HEADER stdafx.h)
target_precompile_headers(cordbee_wks_obj PRIVATE [["stdafx.h"]])
add_dependencies(cordbee_wks_obj eventing_headers)
add_library(cordbee_wks INTERFACE)
target_sources(cordbee_wks INTERFACE $<TARGET_OBJECTS:cordbee_wks_obj>)
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
endif(CLR_CMAKE_HOST_WIN32)
set( ILDBSYMLIB_SOURCES
......
if(CLR_CMAKE_HOST_WIN32)
#use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_definitions(-DHOST_WINDOWS)
endif(CLR_CMAKE_HOST_WIN32)
......
......@@ -9,7 +9,7 @@ set(DBGSHIM_SOURCES
if(CLR_CMAKE_HOST_WIN32)
# Use static crt
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_definitions(-DFX_VER_INTERNALNAME_STR=dbgshim.dll)
endif(CLR_CMAKE_HOST_WIN32)
......
......@@ -133,13 +133,11 @@ if(CLR_CMAKE_HOST_WIN32)
# mscordac.def should be generated before mscordaccore.dll is built
add_dependencies(mscordaccore mscordaccore_def)
set(MSCORDAC_OBJ_PATH "${CMAKE_CURRENT_BINARY_DIR}/mscordacobj.dir/${CMAKE_CFG_INTDIR}/mscordac.obj")
# Generate export file
add_custom_command(
DEPENDS mscordaccore_def "${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" mscordacobj daccess
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp
COMMAND lib.exe /OUT:"${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.lib" /DEF:"${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" "$<TARGET_FILE:daccess>" $<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/LTCG> ${STATIC_LIBRARY_FLAGS} ${MSCORDAC_OBJ_PATH}
COMMAND lib.exe /OUT:"${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.lib" /DEF:"${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" "$<TARGET_FILE:daccess>" $<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/LTCG> ${STATIC_LIBRARY_FLAGS} $<TARGET_OBJECTS:mscordacobj>
COMMENT "Generating mscordaccore.exp export file"
)
......@@ -149,7 +147,8 @@ if(CLR_CMAKE_HOST_WIN32)
)
add_custom_target(mscordaccore_exp DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp)
add_dependencies(mscordaccore mscordaccore_exp)
add_dependencies(mscordaccore_exp mscordacobj)
add_dependencies(mscordaccore mscordaccore_exp mscordacobj)
set(COREDAC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp # export file
......
......@@ -10,6 +10,8 @@ if(CORECLR_SET_RPATH)
endif(CLR_CMAKE_HOST_OSX)
endif(CORECLR_SET_RPATH)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(MSCORDBI_SOURCES
mscordbi.cpp
)
......@@ -50,7 +52,7 @@ else(CLR_CMAKE_HOST_WIN32)
endif(CLR_CMAKE_HOST_WIN32)
add_library_clr(mscordbi SHARED ${MSCORDBI_SOURCES})
target_precompile_header(TARGET mscordbi HEADER stdafx.h)
target_precompile_headers(mscordbi PRIVATE $<$<COMPILE_LANGUAGE:CXX>:stdafx.h>)
if(CLR_CMAKE_HOST_UNIX)
add_custom_target(mscordbi_exports DEPENDS ${EXPORTS_FILE})
......
......@@ -125,6 +125,7 @@ if(CLR_CMAKE_TARGET_WIN32)
shlwapi.lib
bcrypt.lib
RuntimeObject.lib
delayimp.lib
)
else()
list(APPEND CORECLR_LIBRARIES
......@@ -179,51 +180,45 @@ if(FEATURE_SINGLE_FILE_DIAGNOSTICS)
endif(FEATURE_SINGLE_FILE_DIAGNOSTICS)
if(CLR_CMAKE_TARGET_WIN32)
if (NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
add_custom_target(inject_debug_resources ALL COMMAND UNABLE_TO_EMBED_DAC_ON_WINDOWS_NON_VS_GENERATOR)
add_dependencies(inject_debug_resources coreclr mscordaccore mscordbi)
# Add dac table & debug resource to coreclr
get_include_directories(INC_DIR)
get_compile_definitions(PREPROCESS_DEFINITIONS)
list(APPEND INC_DIR -I${CLR_DIR}/src/vm -I${CLR_DIR}/src/vm/${ARCH_SOURCES_DIR} -I${CLR_DIR}/src/debug/ee -I${CLR_DIR}/src/gc)
list(APPEND PREPROCESS_DEFINITIONS -DDACCESS_COMPILE -DTARGET_64BIT)
if (CLR_CMAKE_HOST_ARCH_AMD64)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_AMD64)
elseif (CLR_CMAKE_HOST_ARCH_ARM64)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_ARM64)
elseif (CLR_CMAKE_HOST_ARCH_ARM)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_ARM)
elseif (CLR_CMAKE_HOST_ARCH_I386)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_X86)
else()
# Add dac table & debug resource to coreclr
get_include_directories(INC_DIR)
get_compile_definitions(PREPROCESS_DEFINITIONS)
list(APPEND INC_DIR -I${CLR_DIR}/src/vm -I${CLR_DIR}/src/vm/${ARCH_SOURCES_DIR} -I${CLR_DIR}/src/debug/ee -I${CLR_DIR}/src/gc)
list(APPEND PREPROCESS_DEFINITIONS -DDACCESS_COMPILE -DTARGET_64BIT)
if (CLR_CMAKE_HOST_ARCH_AMD64)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_AMD64)
elseif (CLR_CMAKE_HOST_ARCH_ARM64)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_ARM64)
elseif (CLR_CMAKE_HOST_ARCH_ARM)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_ARM)
elseif (CLR_CMAKE_HOST_ARCH_I386)
list(APPEND PREPROCESS_DEFINITIONS -DTARGET_X86)
else()
clr_unknown_arch()
endif()
if (CLR_CMAKE_CROSS_ARCH)
clr_unknown_arch()
endif()
if (CLR_CMAKE_CROSS_ARCH)
include(${CMAKE_INSTALL_PREFIX}/${CLR_CMAKE_CROSS_HOST_ARCH}/dactabletools/dactabletools.cmake)
endif()
add_custom_command(
DEPENDS coreclr mscordaccore mscordbi ${CLR_DIR}/src/debug/daccess/daccess.cpp
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp
COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/src/debug/daccess/daccess.cpp
COMMAND dactablegen /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/coreclr.pdb /dll:$<TARGET_FILE:coreclr> /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin
COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$<TARGET_FILE:coreclr>
COMMAND GenClrDebugResource /dac:$<TARGET_FILE:mscordaccore> /dbi:$<TARGET_FILE:mscordbi> /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin
COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$<TARGET_FILE:coreclr> /name:CLRDEBUGINFO
COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$<TARGET_FILE:coreclr> /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
)
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)
endif()
endif()
add_custom_command(
DEPENDS coreclr mscordaccore mscordbi ${CLR_DIR}/src/debug/daccess/daccess.cpp
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp
COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/src/debug/daccess/daccess.cpp
COMMAND ${CLR_REPO_ROOT_DIR}/dotnet.cmd exec ${CMAKE_INSTALL_PREFIX}/DacTableGen/DacTableGen.dll /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:$<TARGET_PDB_FILE:coreclr> /dll:$<TARGET_FILE:coreclr> /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin
COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$<TARGET_FILE:coreclr>
COMMAND GenClrDebugResource /dac:$<TARGET_FILE:mscordaccore> /dbi:$<TARGET_FILE:mscordbi> /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin
COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$<TARGET_FILE:coreclr> /name:CLRDEBUGINFO
COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$<TARGET_FILE:coreclr> /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
)
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)
endif()
endif(CLR_CMAKE_TARGET_WIN32)
# add the install targets
......
......@@ -429,7 +429,8 @@ function(add_jit jitName)
target_compile_definitions(${jitName} PRIVATE FX_VER_INTERNALNAME_STR=${jitName}.dll)
endif(CLR_CMAKE_TARGET_WIN32)
target_precompile_header(TARGET ${jitName} HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
target_include_directories(${jitName} PRIVATE ${JIT_SOURCE_DIR})
target_precompile_headers(${jitName} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:jitpch.h>")
add_dependencies(${jitName} jit_exports)
......
......@@ -3,4 +3,4 @@ if(FEATURE_MERGE_JIT_AND_ENGINE)
target_link_libraries(clrjit_crossgen ${JIT_LINK_LIBRARIES} ${JIT_ARCH_LINK_LIBRARIES})
endif(FEATURE_MERGE_JIT_AND_ENGINE)
set_target_properties(clrjit_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET clrjit_crossgen HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
target_precompile_headers(clrjit_static PRIVATE [["jitpch.h"]])
......@@ -2,6 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
//===============================================================================
#ifndef JIT_RATIONALIZE_H
#define JIT_RATIONALIZE_H
#include "phase.h"
class Rationalizer final : public Phase
......@@ -64,3 +67,5 @@ inline Rationalizer::Rationalizer(Compiler* _comp) : Phase(_comp, PHASE_RATIONAL
comp->compNumStatementLinksTraversed = 0;
#endif
}
#endif
......@@ -12,7 +12,8 @@ if(CLR_CMAKE_HOST_UNIX)
add_dependencies(clrjit_obj coreclrpal gcinfo)
endif(CLR_CMAKE_HOST_UNIX)
target_precompile_header(TARGET clrjit_obj HEADER jitpch.h ADDITIONAL_INCLUDE_DIRECTORIES ${JIT_SOURCE_DIR})
target_include_directories(clrjit_obj PRIVATE ${JIT_SOURCE_DIR})
target_precompile_headers(clrjit_obj PRIVATE [["jitpch.h"]])
add_library(clrjit_static INTERFACE)
target_sources(clrjit_static INTERFACE $<TARGET_OBJECTS:clrjit_obj>)
......@@ -9,8 +9,7 @@ add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>:FEATURE_METAD
add_compile_definitions($<$<NOT:$<OR:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>,$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>>>:FEATURE_METADATA_VERIFY_LAYOUTS>)
if (CLR_CMAKE_HOST_WIN32)
add_compile_options($<$<AND:$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>,$<CONFIG:DEBUG>>:-MTd>)
add_compile_options($<$<AND:$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>,$<NOT:$<CONFIG:DEBUG>>>:-MT>)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<AND:$<BOOL:$<TARGET_PROPERTY:DBI_COMPONENT>>,$<CONFIG:DEBUG>>:Debug>)
endif()
add_subdirectory(compiler)
......
......@@ -29,7 +29,7 @@ add_library_clr(ceefgen_obj
OBJECT
${CEEFILEGEN_SOURCES}
)
target_precompile_header(TARGET ceefgen_obj HEADER stdafx.h)
target_precompile_headers(ceefgen_obj PRIVATE stdafx.h)
add_library(ceefgen INTERFACE)
target_sources(ceefgen INTERFACE $<TARGET_OBJECTS:ceefgen_obj>)
......@@ -64,22 +64,22 @@ endif()
add_library_clr(mdcompiler_dac ${MDCOMPILER_SOURCES})
set_target_properties(mdcompiler_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET mdcompiler_dac HEADER stdafx.h)
target_precompile_headers(mdcompiler_dac PRIVATE stdafx.h)
add_library_clr(mdcompiler_wks_obj OBJECT ${MDCOMPILER_WKS_SOURCES})
target_compile_definitions(mdcompiler_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL)
target_precompile_header(TARGET mdcompiler_wks_obj HEADER stdafx.h)
target_precompile_headers(mdcompiler_wks_obj PRIVATE stdafx.h)
add_library(mdcompiler_wks INTERFACE)
target_sources(mdcompiler_wks INTERFACE $<TARGET_OBJECTS:mdcompiler_wks_obj>)
add_library_clr(mdcompiler-dbi ${MDCOMPILER_SOURCES})
set_target_properties(mdcompiler-dbi PROPERTIES DBI_COMPONENT TRUE)
target_precompile_header(TARGET mdcompiler-dbi HEADER stdafx.h)
target_precompile_headers(mdcompiler-dbi PRIVATE stdafx.h)
add_library_clr(mdcompiler_crossgen ${MDCOMPILER_SOURCES})
set_target_properties(mdcompiler_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET mdcompiler_crossgen HEADER stdafx.h)
target_precompile_headers(mdcompiler_crossgen PRIVATE stdafx.h)
add_library_clr(mdcompiler_ppdb ${MDCOMPILER_SOURCES})
target_compile_definitions(mdcompiler_ppdb PRIVATE FEATURE_METADATA_EMIT_ALL FEATURE_METADATA_EMIT_PORTABLE_PDB)
target_precompile_header(TARGET mdcompiler_ppdb HEADER stdafx.h)
target_precompile_headers(mdcompiler_ppdb PRIVATE stdafx.h)
......@@ -22,4 +22,4 @@ endif (CLR_CMAKE_TARGET_WIN32)
add_library_clr(mddatasource_dbi STATIC ${MDDATASOURCE_SOURCES})
set_target_properties(mddatasource_dbi PROPERTIES DBI_COMPONENT TRUE)
target_precompile_header(TARGET mddatasource_dbi HEADER stdafx.h)
target_precompile_headers(mddatasource_dbi PRIVATE stdafx.h)
......@@ -50,22 +50,22 @@ convert_to_absolute_path(MDRUNTIMERW_SOURCES ${MDRUNTIMERW_SOURCES})
add_library_clr(mdruntimerw_dac ${MDRUNTIMERW_SOURCES})
set_target_properties(mdruntimerw_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET mdruntimerw_dac HEADER stdafx.h)
target_precompile_headers(mdruntimerw_dac PRIVATE stdafx.h)
add_library_clr(mdruntimerw_wks_obj OBJECT ${MDRUNTIMERW_SOURCES})
target_compile_definitions(mdruntimerw_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL)
target_precompile_header(TARGET mdruntimerw_wks_obj HEADER stdafx.h)
target_precompile_headers(mdruntimerw_wks_obj PRIVATE stdafx.h)
add_library(mdruntimerw_wks INTERFACE)
target_sources(mdruntimerw_wks INTERFACE $<TARGET_OBJECTS:mdruntimerw_wks_obj>)
add_library_clr(mdruntimerw-dbi ${MDRUNTIMERW_SOURCES})
set_target_properties(mdruntimerw-dbi PROPERTIES DBI_COMPONENT TRUE)
target_precompile_header(TARGET mdruntimerw-dbi HEADER stdafx.h)
target_precompile_headers(mdruntimerw-dbi PRIVATE stdafx.h)
add_library_clr(mdruntimerw_crossgen ${MDRUNTIMERW_SOURCES})
set_target_properties(mdruntimerw_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET mdruntimerw_crossgen HEADER stdafx.h)
target_precompile_headers(mdruntimerw_crossgen PRIVATE stdafx.h)
add_library_clr(mdruntimerw_ppdb ${MDRUNTIMERW_SOURCES})
target_compile_definitions(mdruntimerw_ppdb PRIVATE FEATURE_METADATA_EMIT_ALL FEATURE_METADATA_EMIT_PORTABLE_PDB)
target_precompile_header(TARGET mdruntimerw_ppdb HEADER stdafx.h)
\ No newline at end of file
target_precompile_headers(mdruntimerw_ppdb PRIVATE stdafx.h)
......@@ -31,22 +31,22 @@ endif (CLR_CMAKE_TARGET_WIN32)
add_library_clr(mdhotdata_dac ${MDHOTDATA_SOURCES})
set_target_properties(mdhotdata_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET mdhotdata_dac HEADER external.h)
target_precompile_headers(mdhotdata_dac PRIVATE external.h)
add_library_clr(mdhotdata_full_obj OBJECT ${MDHOTDATA_SOURCES})
target_precompile_header(TARGET mdhotdata_full_obj HEADER external.h)
target_precompile_headers(mdhotdata_full_obj PRIVATE external.h)
add_library(mdhotdata_full INTERFACE)
target_sources(mdhotdata_full INTERFACE $<TARGET_OBJECTS:mdhotdata_full_obj>)
add_library_clr(mdhotdata_crossgen ${MDHOTDATA_SOURCES})
set_target_properties(mdhotdata_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET mdhotdata_crossgen HEADER external.h)
target_precompile_headers(mdhotdata_crossgen PRIVATE external.h)
if(CLR_CMAKE_HOST_WIN32)
add_library_clr(mdhotdata-staticcrt ${MDHOTDATA_SOURCES})
target_precompile_header(TARGET mdhotdata-staticcrt HEADER external.h)
target_precompile_headers(mdhotdata-staticcrt PRIVATE external.h)
endif(CLR_CMAKE_HOST_WIN32)
add_library_clr(mdhotdata_ppdb ${MDHOTDATA_SOURCES})
target_compile_definitions(mdhotdata_ppdb PRIVATE FEATURE_METADATA_EMIT_PORTABLE_PDB)
target_precompile_header(TARGET mdhotdata_ppdb HEADER external.h)
\ No newline at end of file
target_precompile_headers(mdhotdata_ppdb PRIVATE external.h)
......@@ -47,22 +47,22 @@ endif (CLR_CMAKE_TARGET_WIN32)
add_library_clr(mdruntime_dac ${MDRUNTIME_SOURCES})
set_target_properties(mdruntime_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET mdruntime_dac HEADER stdafx.h)
target_precompile_headers(mdruntime_dac PRIVATE stdafx.h)
add_library_clr(mdruntime_wks_obj OBJECT ${MDRUNTIME_SOURCES})
target_compile_definitions(mdruntime_wks_obj PRIVATE FEATURE_METADATA_EMIT_ALL)
target_precompile_header(TARGET mdruntime_wks_obj HEADER stdafx.h)
target_precompile_headers(mdruntime_wks_obj PRIVATE stdafx.h)
add_library(mdruntime_wks INTERFACE)
target_sources(mdruntime_wks INTERFACE $<TARGET_OBJECTS:mdruntime_wks_obj>)
add_library_clr(mdruntime-dbi ${MDRUNTIME_SOURCES})
set_target_properties(mdruntime-dbi PROPERTIES DBI_COMPONENT TRUE)
target_precompile_header(TARGET mdruntime-dbi HEADER stdafx.h)
target_precompile_headers(mdruntime-dbi PRIVATE stdafx.h)
add_library_clr(mdruntime_crossgen ${MDRUNTIME_SOURCES})
set_target_properties(mdruntime_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET mdruntime_crossgen HEADER stdafx.h)
target_precompile_headers(mdruntime_crossgen PRIVATE stdafx.h)
add_library_clr(mdruntime_ppdb ${MDRUNTIME_SOURCES})
target_compile_definitions(mdruntime_ppdb PRIVATE FEATURE_METADATA_EMIT_ALL FEATURE_METADATA_EMIT_PORTABLE_PDB)
target_precompile_header(TARGET mdruntime_ppdb HEADER stdafx.h)
\ No newline at end of file
target_precompile_headers(mdruntime_ppdb PRIVATE stdafx.h)
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_executable(GenClrDebugResource GenClrDebugResource.cpp)
target_link_libraries(GenClrDebugResource
......
remove_definitions(-DUNICODE)
remove_definitions(-D_UNICODE)
add_definitions(-MT)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_executable(InjectResource InjectResource.cpp)
......
......@@ -124,7 +124,7 @@ add_dependencies(utilcode_dac ${UTILCODE_DEPENDENCIES})
add_dependencies(utilcode_obj ${UTILCODE_DEPENDENCIES})
add_dependencies(utilcode_crossgen ${UTILCODE_DEPENDENCIES})
add_dependencies(utilcodestaticnohost ${UTILCODE_DEPENDENCIES})
target_precompile_header(TARGET utilcode_dac HEADER stdafx.h)
target_precompile_header(TARGET utilcode_obj HEADER stdafx.h)
target_precompile_header(TARGET utilcode_crossgen HEADER stdafx.h)
target_precompile_header(TARGET utilcodestaticnohost HEADER stdafx.h)
target_precompile_headers(utilcode_dac PRIVATE [["stdafx.h"]])
target_precompile_headers(utilcode_obj PRIVATE [["stdafx.h"]])
target_precompile_headers(utilcode_crossgen PRIVATE [["stdafx.h"]])
target_precompile_headers(utilcodestaticnohost PRIVATE [["stdafx.h"]])
......@@ -9,18 +9,12 @@ add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)
if(FEATURE_AUTO_TRACE)
add_definitions(-DFEATURE_AUTO_TRACE)
add_definitions(-DFEATURE_AUTO_TRACE)
endif(FEATURE_AUTO_TRACE)
if(CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
foreach (Config DEBUG CHECKED)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:${Config}>:WRITE_BARRIER_CHECK=1>)
endforeach (Config)
else()
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
add_definitions(-DWRITE_BARRIER_CHECK)
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
endif(CMAKE_CONFIGURATION_TYPES)
foreach (Config DEBUG CHECKED)
add_compile_definitions($<$<CONFIG:${Config}>:WRITE_BARRIER_CHECK>)
endforeach (Config)
if(FEATURE_GDBJIT)
set(VM_SOURCES_GDBJIT
......@@ -941,12 +935,12 @@ convert_to_absolute_path(VM_SOURCES_DAC ${VM_SOURCES_DAC})
convert_to_absolute_path(VM_SOURCES_WKS_SPECIAL ${VM_SOURCES_WKS_SPECIAL})
if (CLR_CMAKE_BUILD_SUBSET_RUNTIME)
add_library_clr(cee_dac ${VM_SOURCES_DAC})
add_dependencies(cee_dac eventing_headers)
set_target_properties(cee_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_header(TARGET cee_dac HEADER common.h)
add_library_clr(cee_dac ${VM_SOURCES_DAC})
add_dependencies(cee_dac eventing_headers)
set_target_properties(cee_dac PROPERTIES DAC_COMPONENT TRUE)
target_precompile_headers(cee_dac PRIVATE [["common.h"]])
add_subdirectory(wks)
add_subdirectory(wks)
endif(CLR_CMAKE_BUILD_SUBSET_RUNTIME)
if(FEATURE_PERFTRACING)
......
......@@ -258,7 +258,7 @@ endif (CLR_CMAKE_HOST_LINUX)
add_library_clr(cee_crossgen ${VM_CROSSGEN_SOURCES})
add_dependencies(cee_crossgen eventing_headers)
set_target_properties(cee_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET cee_crossgen HEADER common.h)
target_precompile_headers(cee_crossgen PRIVATE [["common.h"]])
if (MSVC)
# corelib.cpp does not compile with precompiled header file
set_source_files_properties(../corelib.cpp PROPERTIES COMPILE_FLAGS "/Y-")
......
if (CLR_CMAKE_TARGET_WIN32)
if(CLR_CMAKE_HOST_ARCH_ARM OR CLR_CMAKE_HOST_ARCH_ARM64)
preprocess_compile_asm(TARGET cee_wks_core ASM_FILES ${VM_SOURCES_WKS_ARCH_ASM} OUTPUT_OBJECTS VM_WKS_ARCH_ASM_OBJECTS)
preprocess_files(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM})
if (CMAKE_GENERATOR MATCHES "Visual Studio")
compile_asm(TARGET cee_wks_core ASM_FILES ${VM_SOURCES_WKS_ARCH_ASM} OUTPUT_OBJECTS VM_WKS_ARCH_ASM_OBJECTS)
endif()
endif()
endif (CLR_CMAKE_TARGET_WIN32)
add_library_clr(cee_wks_core OBJECT ${VM_SOURCES_WKS} ${VM_SOURCES_WKS_ARCH_ASM})
add_library_clr(cee_wks_obj OBJECT ${VM_SOURCES_WKS_SPECIAL})
add_library_clr(cee_wks_mergeable_obj OBJECT ${VM_SOURCES_WKS_SPECIAL})
target_precompile_header(TARGET cee_wks_core HEADER common.h)
target_precompile_header(TARGET cee_wks_obj HEADER common.h)
target_precompile_header(TARGET cee_wks_mergeable_obj HEADER common.h)
target_precompile_headers(cee_wks_core PRIVATE [["common.h"]])
target_precompile_headers(cee_wks_obj PRIVATE [["common.h"]])
target_precompile_headers(cee_wks_mergeable_obj PRIVATE [["common.h"]])
if (MSVC)
# corelib.cpp does not compile with precompiled header file
......@@ -62,16 +63,16 @@ if (CLR_CMAKE_TARGET_WIN32)
endif (CLR_CMAKE_TARGET_WIN32)
add_custom_target(preprocessd_asm DEPENDS ${VM_WKS_ARCH_ASM_OBJECTS})
add_dependencies(cee_wks_core preprocessd_asm)
add_dependencies(cee_wks_obj preprocessd_asm)
add_dependencies(cee_wks_mergeable_obj preprocessd_asm)
add_custom_target(precompiled_asm DEPENDS ${VM_WKS_ARCH_ASM_OBJECTS})
add_dependencies(cee_wks_core precompiled_asm)
add_dependencies(cee_wks_obj precompiled_asm)
add_dependencies(cee_wks_mergeable_obj precompiled_asm)
target_compile_definitions(cee_wks_mergeable_obj PUBLIC FEATURE_MERGE_JIT_AND_ENGINE)
target_compile_definitions(cee_wks_mergeable_obj PUBLIC CORECLR_EMBEDDED)
add_library(cee_wks INTERFACE)
target_sources(cee_wks INTERFACE $<TARGET_OBJECTS:cee_wks_obj> ${VM_WKS_ARCH_ASM_OBJECTS})
target_sources(cee_wks INTERFACE $<TARGET_OBJECTS:cee_wks_obj> $<TARGET_OBJECTS:cee_wks_core> ${VM_WKS_ARCH_ASM_OBJECTS})
add_library(cee_wks_mergeable INTERFACE)
target_sources(cee_wks_mergeable INTERFACE $<TARGET_OBJECTS:cee_wks_mergeable_obj> $<TARGET_OBJECTS:cee_wks_core> ${VM_WKS_ARCH_ASM_OBJECTS})
......@@ -49,7 +49,7 @@ endif(CLR_CMAKE_TARGET_WIN32)
add_library_clr(corzap_crossgen STATIC ${ZAP_SOURCES})
set_target_properties(corzap_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)
target_precompile_header(TARGET corzap_crossgen HEADER common.h)
target_precompile_headers(corzap_crossgen PRIVATE [["common.h"]])
if(FEATURE_MERGE_JIT_AND_ENGINE)
target_link_libraries(corzap_crossgen clrjit_crossgen)
......
cmake_minimum_required(VERSION 3.6.2)
if (CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15)
cmake_policy(SET CMP0091 NEW)
endif()
project(corehost)
include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
if(MSVC)
add_compile_options(/W1)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4996>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4267>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4018>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4200>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4244>)
# Host components don't try to handle asynchronous exceptions
add_compile_options(/EHsc)
elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
......
@if "%_echo%" neq "on" echo off
rem
rem This file invokes cmake and generates the build system for windows.
set argC=0
for %%x in (%*) do Set /A argC+=1
if NOT %argC%==9 GOTO :USAGE
if %1=="/?" GOTO :USAGE
setlocal
set __sourceDir=%~dp0..
set __VSString=%2
:: Remove quotes
set __VSString=%__VSString:"=%
set __ExtraCmakeParams=
:: Set the target architecture to a format cmake understands. ANYCPU defaults to x64
set __Arch=%3
if /i "%__Arch%" == "x64" (set cm_BaseRid=win7&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%__Arch%" == "x86" (set cm_BaseRid=win7&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
if /i "%__Arch%" == "arm" (set cm_BaseRid=win8&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%__Arch%" == "arm64" (set cm_BaseRid=win10&&set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
set __LatestCommit=%4
set __HostVersion=%5
set __AppHostVersion=%6
set __HostFxrVersion=%7
set __HostPolicyVersion=%8
:: Form the base RID to be used if we are doing a portable build
if /i "%9" == "1" (set cm_BaseRid=win)
set cm_BaseRid=%cm_BaseRid%-%__Arch%
echo "Computed RID for native build is %cm_BaseRid%"
if defined CMakePath goto DoGen
:: Eval the output from probe-win1.ps1
pushd "%__sourceDir%"
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\Windows\probe-win.ps1"') do %%a
popd
:DoGen
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLI_CMAKE_HOST_VER=%__HostVersion%" "-DCLI_CMAKE_COMMON_HOST_VER=%__AppHostVersion%" "-DCLI_CMAKE_HOST_FXR_VER=%__HostFxrVersion%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_COMMIT_HASH=%__LatestCommit%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCORECLR_ARTIFACTS=%__CoreClrArtifacts% " "-DRUNTIME_CONFIG=%__RuntimeConfiguration%" "-DNATIVE_LIBS_ARTIFACTS=%__NativeLibsArtifacts%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% "
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCLR_ENG_NATIVE_DIR=%__sourceDir%\..\..\..\eng\native"
echo "%CMakePath%" %__sourceDir% -G "Visual Studio %__VSString%" %__ExtraCmakeParams%
"%CMakePath%" %__sourceDir% -G "Visual Studio %__VSString%" %__ExtraCmakeParams%
endlocal
GOTO :DONE
:USAGE
echo "Usage..."
echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion> <Target Architecture>"
echo "Specify the path to the top level CMake file"
echo "Specify the VSVersion to be used - VS2017 or VS2019"
echo "Specify the Target Architecture - AnyCPU, x86, x64, ARM, or ARM64."
echo "Specify latest commit hash"
echo "Specify the host version, apphost version, hostresolver version, hostpolicy version"
EXIT /B 1
:DONE
EXIT /B 0
# This file probes for the prerequisites for the build system, and outputs commands for eval'ing
# from the cmd scripts to set variables (and exit on error)
function GetCMakeVersions
{
$items = @()
$items += @(Get-ChildItem hklm:\SOFTWARE\Wow6432Node\Kitware -ErrorAction SilentlyContinue)
$items += @(Get-ChildItem hklm:\SOFTWARE\Kitware -ErrorAction SilentlyContinue)
return $items | where { $_.PSChildName.StartsWith("CMake") }
}
function GetCMakeInfo($regKey)
{
try {
$version = [System.Version] $regKey.PSChildName.Split(' ')[1]
}
catch {
return $null
}
$itemProperty = Get-ItemProperty $regKey.PSPath;
if (Get-Member -inputobject $itemProperty -name "InstallDir" -Membertype Properties) {
$cmakeDir = $itemProperty.InstallDir
}
else {
# For CMake prior to version 3.5
$cmakeDir = $itemProperty.'(default)'
}
$cmakePath = [System.IO.Path]::Combine($cmakeDir, "bin\cmake.exe")
if (![System.IO.File]::Exists($cmakePath)) {
return $null
}
return @{'version' = $version; 'path' = $cmakePath}
}
function LocateCMake
{
$errorMsg = "CMake is a pre-requisite to build this repository but it was not found on the path. Please install CMake from https://cmake.org/download/ and ensure it is on your path."
$inPathPath = (get-command cmake.exe -ErrorAction SilentlyContinue)
if ($inPathPath -ne $null) {
# Resolve the first version of CMake if multiple commands are found
if ($inPathPath.Length -gt 1) {
return $inPathPath[0].Path
}
return $inPathPath.Path
}
# Check the default installation directory
$inDefaultDir = [System.IO.Path]::Combine(${Env:ProgramFiles(x86)}, "CMake\bin\cmake.exe")
if ([System.IO.File]::Exists($inDefaultDir)) {
return $inDefaultDir
}
# If we're running in an x86 process, and a 64-bit CMake is installed, but is not on the PATH, we also
# won't see its installation information in the registry (below). Check the default installation directory
# in the 64-bit Program Files location.
$inDefaultDir = [System.IO.Path]::Combine(${Env:ProgramW6432}, "CMake\bin\cmake.exe")
if ([System.IO.File]::Exists($inDefaultDir)) {
return $inDefaultDir
}
# Let us hope that CMake keep using their current version scheme
$validVersions = @()
foreach ($regKey in GetCMakeVersions) {
$info = GetCMakeInfo($regKey)
if ($info -ne $null) {
$validVersions += @($info)
}
}
$newestCMakePath = ($validVersions |
Sort-Object -property @{Expression={$_.version}; Ascending=$false} |
select -first 1).path
if ($newestCMakePath -eq $null) {
Throw $errorMsg
}
return $newestCMakePath
}
try {
$cmakePath = LocateCMake
[System.Console]::WriteLine("set CMakePath=" + $cmakePath)
}
catch {
[System.Console]::Error.WriteLine($_.Exception.Message)
[System.Console]::WriteLine("exit /b 1")
}
......@@ -3,7 +3,11 @@ setlocal
:SetupArgs
:: Initialize the args that will be passed to cmake
set __nativeWindowsDir=%~dp0Windows
set "__sourceDir=%~dp0"
:: remove trailing slash
if %__sourceDir:~-1%==\ set "__ProjectDir=%__sourceDir:~0,-1%"
set __engNativeDir=%__sourceDir%\..\..\..\eng\native
set __CMakeBinDir=""
set __IntermediatesDir=""
set __BuildArch=x64
......@@ -14,6 +18,7 @@ set "__LinkArgs= "
set "__LinkLibraries= "
set __PortableBuild=0
set __IncrementalNativeBuild=0
set __Ninja=0
:Arg_Loop
if [%1] == [] goto :ToolsVersion
......@@ -40,6 +45,7 @@ if /i [%1] == [incremental-native-build] ( set __IncrementalNativeBuild=1&&shift
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] == [nativelibsartifacts] (set __NativeLibsArtifacts=%2&&shift&&shift&goto Arg_Loop)
if /i [%1] == [ninja] (set __Ninja=1)
if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop)
if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop)
......@@ -77,7 +83,7 @@ exit /b 1
:VS2019
:: Setup vars for VS2019
set __PlatformToolset=v142
set __VSVersion=16 2019
set __VSVersion=vs2019
:: Set the environment for the native build
call "%VS160COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%
goto :SetupDirs
......@@ -85,7 +91,7 @@ goto :SetupDirs
:VS2017
:: Setup vars for VS2017
set __PlatformToolset=v141
set __VSVersion=15 2017
set __VSVersion=vs2017
:: Set the environment for the native build
call "%VS150COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%
......@@ -121,7 +127,7 @@ if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%"
:CreateIntermediates
if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%"
if exist "%VSINSTALLDIR%DIA SDK" goto GenVSSolution
if exist "%VSINSTALLDIR%DIA SDK" goto FindCMake
echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
Did you install all the requirements for building on Windows, including the "Desktop Development with C++" workload? ^
Please see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md ^
......@@ -129,31 +135,52 @@ Another possibility is that you have a parallel installation of Visual Studio an
may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try again.
exit /b 1
:GenVSSolution
:: Regenerate the VS solution
:FindCMake
if defined CMakePath goto GenVSSolution
:: Find CMake
echo Calling "%__nativeWindowsDir%\gen-buildsys-win.bat %~dp0 "%__VSVersion%" %__BuildArch% %__CommitSha% %__HostVersion% %__AppHostVersion% %__HostFxrVersion% %__HostPolicyVersion% %__PortableBuild%"
pushd "%__IntermediatesDir%"
call "%__nativeWindowsDir%\gen-buildsys-win.bat" %~dp0 "%__VSVersion%" %__BuildArch% %__CommitSha% %__HostVersion% %__AppHostVersion% %__HostFxrVersion% %__HostPolicyVersion% %__PortableBuild%
popd
:: Eval the output from set-cmake-path.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__engNativeDir%\set-cmake-path.ps1"""') do %%a
:CheckForProj
:: Check that the project created by Cmake exists
if exist "%__IntermediatesDir%\INSTALL.vcxproj" goto BuildNativeProj
goto :Failure
:GenVSSolution
if /i "%__BuildArch%" == "x64" (set cm_BaseRid=win7)
if /i "%__BuildArch%" == "x86" (set cm_BaseRid=win7)
if /i "%__BuildArch%" == "arm" (set cm_BaseRid=win8)
if /i "%__BuildArch%" == "arm64" (set cm_BaseRid=win10)
:: Form the base RID to be used if we are doing a portable build
if /i "%__PortableBuild%" == "1" (set cm_BaseRid=win)
set cm_BaseRid=%cm_BaseRid%-%__BuildArch%
echo "Computed RID for native build is %cm_BaseRid%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_VER=%__HostVersion%" "-DCLI_CMAKE_COMMON_HOST_VER=%__AppHostVersion%" "-DCLI_CMAKE_HOST_FXR_VER=%__HostFxrVersion%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCORECLR_ARTIFACTS=%__CoreClrArtifacts% " "-DRUNTIME_CONFIG=%__RuntimeConfiguration%" "-DNATIVE_LIBS_ARTIFACTS=%__NativeLibsArtifacts%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% "
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCLR_ENG_NATIVE_DIR=%__engNativeDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%"
:: Regenerate the native build files
echo Calling "%__engNativeDir%\gen-buildsys.cmd "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__ExtraCmakeParams%"
call "%__engNativeDir%\gen-buildsys.cmd" "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__ExtraCmakeParams%
if NOT [%errorlevel%] == [0] goto :Failure
popd
:BuildNativeProj
:: Build the project created by Cmake
set __msbuildArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%"
SET __NativeBuildArgs=/t:rebuild
if /i "%__IncrementalNativeBuild%" == "1" SET __NativeBuildArgs=
set __generatorArgs=
if [%__Ninja%] == [1] (
set __generatorArgs=
) else if [%__BuildArch%] == [wasm] (
set __generatorArgs=-j
) else (
set __generatorArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065
)
echo msbuild "%__IntermediatesDir%\INSTALL.vcxproj" %__NativeBuildArgs% /m /p:Configuration=%CMAKE_BUILD_TYPE% %__msbuildArgs%
call msbuild "%__IntermediatesDir%\INSTALL.vcxproj" %__NativeBuildArgs% /m /p:Configuration=%CMAKE_BUILD_TYPE% %__msbuildArgs%
call "%CMakePath%" --build "%__IntermediatesDir%" --target install --config %CMAKE_BUILD_TYPE% -- %__generatorArgs%
IF ERRORLEVEL 1 (
goto :Failure
)
echo Done building Native components
exit /B 0
......
......@@ -33,8 +33,10 @@ convert_to_absolute_path(SOURCES ${SOURCES})
convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES})
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
preprocess_compile_asm(TARGET ijwhost ASM_FILES ${ASM_HELPERS_SOURCES} OUTPUT_OBJECTS ASM_HELPERS_OBJECTS)
list(APPEND ASM_HELPERS_SOURCES ${ASM_HELPERS_OBJECTS})
preprocess_files(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES})
if (CMAKE_GENERATOR MATCHES "Visual Studio")
compile_asm(TARGET ijwhost ASM_FILES ${ASM_HELPERS_SOURCES} OUTPUT_OBJECTS ASM_HELPERS_SOURCES)
endif()
endif ()
if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_I386)
......
......@@ -50,6 +50,10 @@ include(../testexe.cmake)
target_link_libraries(${DOTNET_PROJECT_NAME} nethost)
if (CLR_CMAKE_TARGET_WIN32)
target_link_libraries(${DOTNET_PROJECT_NAME} delayimp.lib)
endif()
# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
target_link_libraries(${DOTNET_PROJECT_NAME} Advapi32.lib Ole32.lib OleAut32.lib)
......
......@@ -7,6 +7,7 @@
-->
<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IncrementalNativeBuild Condition="'$(IncrementalNativeBuild)' == ''">true</IncrementalNativeBuild>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
......@@ -36,6 +37,7 @@
<BuildArgs Condition="'$(CMakeArgs)' != ''">$(BuildArgs) $(CMakeArgs)</BuildArgs>
<BuildArgs>$(BuildArgs) -coreclrartifacts $(CoreCLRArtifactsPath)</BuildArgs>
<BuildArgs>$(BuildArgs) -nativelibsartifacts $(LibrariesArtifactsPath)/bin/native/$(NetCoreAppCurrent)-$(TargetOS)-$(LibrariesConfiguration)-$(TargetArchitecture)</BuildArgs>
<BuildArgs Condition="'$(Ninja)' == 'true'">$(BuildArgs) -ninja</BuildArgs>
<BuildArgs>$(BuildArgs) -runtimeflavor $(RuntimeFlavor)</BuildArgs>
</PropertyGroup>
......@@ -91,6 +93,7 @@
<BuildArgs>$(BuildArgs) rootdir $(RepoRoot)</BuildArgs>
<BuildArgs>$(BuildArgs) coreclrartifacts $(CoreCLRArtifactsPath)</BuildArgs>
<BuildArgs>$(BuildArgs) nativelibsartifacts $(LibrariesArtifactsPath)/bin/native/$(NetCoreAppCurrent)-$(TargetOS)-$(LibrariesConfiguration)-$(TargetArchitecture)</BuildArgs>
<BuildArgs Condition="'$(Ninja)' == 'true'">$(BuildArgs) ninja</BuildArgs>
<BuildArgs>$(BuildArgs) runtimeflavor $(RuntimeFlavor)</BuildArgs>
<BuildArgs>$(BuildArgs) runtimeconfiguration $(RuntimeConfiguration)</BuildArgs>
</PropertyGroup>
......
......@@ -33,11 +33,13 @@ add_compile_options(/Oy-) # disable suppressing of the creation of frame
add_compile_options(/U_MT) # undefine the predefined _MT macro
add_compile_options(/GF) # enable read-only string pooling
add_compile_options(/Gm-) # disable minimal rebuild
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}")
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)
......@@ -52,14 +54,6 @@ if ($ENV{__BuildArch} STREQUAL "x86")
add_compile_options(/Gz)
endif ()
if (($ENV{__BuildArch} STREQUAL "arm") OR ($ENV{__BuildArch} STREQUAL "arm64"))
if(NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION OR CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION STREQUAL "" )
message(FATAL_ERROR "Windows SDK is required for the ARM32 or ARM64 build.")
else()
message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
endif ()
# enable control-flow-guard support for native components
add_compile_options(/guard:cf)
list(APPEND __SharedLinkArgs /GUARD:CF)
......
......@@ -104,5 +104,5 @@ GENERATE_EXPORT_HEADER( clrcompression
install (TARGETS clrcompression DESTINATION .)
install (TARGETS clrcompression-static DESTINATION .)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/clrcompression.pdb DESTINATION .)
install (FILES $<TARGET_PDB_FILE:clrcompression> DESTINATION .)
@if "%_echo%" neq "on" echo off
rem
rem This file invokes cmake and generates the build system for windows.
set argC=0
for %%x in (%*) do Set /A argC+=1
if NOT %argC%==3 GOTO :USAGE
if %1=="/?" GOTO :USAGE
setlocal
set __sourceDir=%~dp0
set __ExtraCmakeParams=
if "%__VSVersion%" == "vs2019" (
:: CMAKE 3.14 or later is required to use VS2019
set __VSString=16 2019
) else (
:: VS 2017 is the minimum supported toolset
set __VSString=15 2017
)
if /i "%3" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%3" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
if /i "%3" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%3" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%3" == "wasm" (set __sourceDir=%~dp0..\Unix && goto DoGen)
:: cmake requires forward slashes in paths
set __cmakeRepoRoot=%__repoRoot:\=/%
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%"
if defined CMakePath goto DoGen
:: Eval the output from probe-win1.ps1
pushd "%__sourceDir%"
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\probe-win.ps1"') do %%a
popd
:DoGen
if "%3" == "wasm" (
if "%EMSDK_PATH%" == "" (
echo "Error: Should set EMSDK_PATH environment variable pointing to emsdk root."
exit /B 1
)
if "%EMSCRIPTEN_ROOT%" == "" (
set EMSCRIPTEN_ROOT="%EMSDK_PATH/upstream/emscripten%"
)
emcmake cmake "-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" "-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%" "-DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/Emscripten.cmake" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" -G "NMake Makefiles" %__sourceDir%
) else (
"%CMakePath%" "-DCMAKE_SYSTEM_VERSION=10.0" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" -G "Visual Studio %__VSString%" -B. -H%1 %__ExtraCmakeParams%
)
endlocal
GOTO :DONE
:USAGE
echo "Usage..."
echo "gen-buildsys-win.bat <path to top level CMakeLists.txt> <VSVersion> <Target Architecture>"
echo "Specify the path to the top level CMake file"
echo "Specify the VSVersion to be used - VS2017"
echo "Specify the Target Architecture - AnyCPU, x86, x64, ARM, or ARM64."
EXIT /B 1
:DONE
EXIT /B 0
# This file probes for the prerequisites for the build system, and outputs commands for eval'ing
# from the cmd scripts to set variables (and exit on error)
function GetCMakeVersions
{
$items = @()
$items += @(Get-ChildItem hklm:\SOFTWARE\Wow6432Node\Kitware -ErrorAction SilentlyContinue)
$items += @(Get-ChildItem hklm:\SOFTWARE\Kitware -ErrorAction SilentlyContinue)
return $items | where { $_.PSChildName.StartsWith("CMake") }
}
function GetCMakeInfo($regKey)
{
try {
$version = [System.Version] $regKey.PSChildName.Split(' ')[1]
}
catch {
return $null
}
$itemProperty = Get-ItemProperty $regKey.PSPath;
if (Get-Member -inputobject $itemProperty -name "InstallDir" -Membertype Properties) {
$cmakeDir = $itemProperty.InstallDir
}
else {
# For CMake prior to version 3.5
$cmakeDir = $itemProperty.'(default)'
}
$cmakePath = [System.IO.Path]::Combine($cmakeDir, "bin\cmake.exe")
if (![System.IO.File]::Exists($cmakePath)) {
return $null
}
return @{'version' = $version; 'path' = $cmakePath}
}
function LocateCMake
{
$errorMsg = "CMake is a pre-requisite to build this repository but it was not found on the path. Please install CMake from https://cmake.org/download/ and ensure it is on your path."
$inPathPath = (get-command cmake.exe -ErrorAction SilentlyContinue)
if ($inPathPath -ne $null) {
# Resolve the first version of CMake if multiple commands are found
if ($inPathPath.Length -gt 1) {
return $inPathPath[0].Path
}
return $inPathPath.Path
}
# Check the default installation directory
$inDefaultDir = [System.IO.Path]::Combine(${Env:ProgramFiles(x86)}, "CMake\bin\cmake.exe")
if ([System.IO.File]::Exists($inDefaultDir)) {
return $inDefaultDir
}
# If we're running in an x86 process, and a 64-bit CMake is installed, but is not on the PATH, we also
# won't see its installation information in the registry (below). Check the default installation directory
# in the 64-bit Program Files location.
$inDefaultDir = [System.IO.Path]::Combine(${Env:ProgramW6432}, "CMake\bin\cmake.exe")
if ([System.IO.File]::Exists($inDefaultDir)) {
return $inDefaultDir
}
# Let us hope that CMake keep using their current version scheme
$validVersions = @()
foreach ($regKey in GetCMakeVersions) {
$info = GetCMakeInfo($regKey)
if ($info -ne $null) {
$validVersions += @($info)
}
}
$newestCMakePath = ($validVersions |
Sort-Object -property @{Expression={$_.version}; Ascending=$false} |
select -first 1).path
if ($newestCMakePath -eq $null) {
Throw $errorMsg
}
return $newestCMakePath
}
try {
$cmakePath = LocateCMake
[System.Console]::WriteLine("set CMakePath=" + $cmakePath)
}
catch {
[System.Console]::Error.WriteLine($_.Exception.Message)
[System.Console]::WriteLine("exit /b 1")
}
......@@ -3,8 +3,9 @@ setlocal
:SetupArgs
:: Initialize the args that will be passed to cmake
set __nativeWindowsDir=%~dp0\Windows
set __sourceDir=%~dp0\Windows
set __repoRoot=%~dp0..\..\..
set __engNativeDir=%__repoRoot%\eng\native
set __artifactsDir=%__repoRoot%\artifacts
set __CMakeBinDir=""
set __IntermediatesDir=""
......@@ -15,6 +16,7 @@ set __TargetOS=Windows_NT
set CMAKE_BUILD_TYPE=Debug
set "__LinkArgs= "
set "__LinkLibraries= "
set __Ninja=0
:Arg_Loop
:: Since the native build requires some configuration information before msbuild is called, we have to do some manual args parsing
......@@ -36,6 +38,8 @@ 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)
shift
goto :Arg_Loop
......@@ -93,6 +97,7 @@ goto :SetupDirs
echo Commencing build of native components
echo.
if /i "%__BuildArch%" == "wasm" set __sourceDir=%~dp0..\Unix
if [%__outConfig%] == [] set __outConfig=%__TargetOS%-%__BuildArch%-%CMAKE_BUILD_TYPE%
......@@ -117,7 +122,7 @@ set MSBUILD_EMPTY_PROJECT_CONTENT= ^
echo %MSBUILD_EMPTY_PROJECT_CONTENT% > "%__artifactsDir%\obj\native\Directory.Build.props"
echo %MSBUILD_EMPTY_PROJECT_CONTENT% > "%__artifactsDir%\obj\native\Directory.Build.targets"
if exist "%VSINSTALLDIR%DIA SDK" goto GenVSSolution
if exist "%VSINSTALLDIR%DIA SDK" goto FindCMake
echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
Did you install all the requirements for building on Windows, including the "Desktop Development with C++" workload? ^
Please see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md ^
......@@ -125,44 +130,45 @@ Another possibility is that you have a parallel installation of Visual Studio an
may help to copy its "DIA SDK" folder into "%VSINSTALLDIR%" manually, then try again.
exit /b 1
:FindCMake
if defined CMakePath goto GenVSSolution
:: Find CMake
:: Eval the output from set-cmake-path.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__repoRoot%\eng\native\set-cmake-path.ps1"""') do %%a
:GenVSSolution
:: generate version file
powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File "%__repoRoot%\eng\common\msbuild.ps1" /clp:nosummary %__ArcadeScriptArgs%^
"%__repoRoot%\eng\empty.csproj" /p:NativeVersionFile="%__artifactsDir%\obj\_version.h"^
/t:GenerateNativeVersionFile /restore
:: Regenerate the VS solution
:: cmake requires forward slashes in paths
set __cmakeRepoRoot=%__repoRoot:\=/%
pushd "%__IntermediatesDir%"
call "%__nativeWindowsDir%\gen-buildsys-win.bat" "%__nativeWindowsDir%" %__VSVersion% %__BuildArch%
call "%__repoRoot%\eng\native\gen-buildsys.cmd" "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% "-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%"
if NOT [%errorlevel%] == [0] goto :Failure
popd
:CheckForProj
:: Check that the project created by Cmake exists
if exist "%__IntermediatesDir%\install.vcxproj" goto BuildNativeProj
if exist "%__IntermediatesDir%\Makefile" goto BuildNativeEmscripten
goto :Failure
:BuildNativeProj
:: Build the project created by Cmake
set __msbuildArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065
call msbuild "%__IntermediatesDir%\install.vcxproj" /t:%__BuildTarget% /p:Configuration=%CMAKE_BUILD_TYPE% %__msbuildArgs%
IF ERRORLEVEL 1 (
goto :Failure
set __generatorArgs=
if [%__Ninja%] == [1] (
set __generatorArgs=
) else if [%__BuildArch%] == [wasm] (
set __generatorArgs=-j
) else (
set __generatorArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065
)
echo Done building Native components
exit /B 0
:BuildNativeEmscripten
pushd "%__IntermediatesDir%"
nmake install
popd
call "%CMakePath%" --build "%__IntermediatesDir%" --target install --config %CMAKE_BUILD_TYPE% -- %__generatorArgs%
IF ERRORLEVEL 1 (
goto :Failure
)
echo Done building Native components
exit /B 0
:Failure
......
......@@ -6,6 +6,7 @@
<TargetFramework>$(BuildTargetFramework)</TargetFramework>
<TargetFramework Condition="'$(TargetFramework)' == ''">$(NetCoreAppCurrent)</TargetFramework>
<_BuildNativeArgs>$(TargetArchitecture) $(Configuration) outconfig $(TargetFramework)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) -os $(TargetOS)</_BuildNativeArgs>
<_BuildNativeArgs Condition="'$(Ninja)' == 'true'">$(_BuildNativeArgs) ninja</_BuildNativeArgs>
</PropertyGroup>
<ItemGroup>
......@@ -15,7 +16,7 @@
<Target Name="BuildNativeUnix"
BeforeTargets="Build"
Condition="'$(TargetOS)' != 'Windows_NT'">
Condition="!$([MSBuild]::IsOsPlatform(Windows))">
<PropertyGroup>
<!--
MSBuildNodeCount should a good approximation for how many procs to use for native build, if we find that doesn't work
......@@ -41,7 +42,7 @@
<Target Name="BuildNativeWindows"
BeforeTargets="Build"
Condition="'$(TargetOS)' == 'Windows_NT' and
Condition="$([MSBuild]::IsOsPlatform(Windows)) and
'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
<!-- Run script that invokes Cmake to create VS files, and then calls msbuild to compile them -->
<Message Text="&quot;$(MSBuildThisFileDirectory)build-native.cmd&quot; $(_BuildNativeArgs)" Importance="High"/>
......
cmake_minimum_required(VERSION 3.6.2)
cmake_policy(SET CMP0042 NEW)
if (CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15)
cmake_policy(SET CMP0091 NEW)
endif()
project(Tests)
include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
......@@ -30,6 +33,8 @@ if (CLR_CMAKE_HOST_WIN32)
# 5027 - move assignment operator was implicitly defined as deleted
# 5039 - pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception.
add_compile_options(-wd4100 -wd4514 -wd4625 -wd4626 -wd4668 -wd4710 -wd4711 -wd4774 -wd4820 -wd5025 -wd5026 -wd5027 -wd5039)
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions)
endif()
......
......@@ -6,7 +6,7 @@ if (CLR_CMAKE_HOST_WIN32)
add_compile_options(/clr)
# IJW requires the CRT as a dll, not linked in
add_compile_options(/MD$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:d>)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:Debug>DLL)
# CMake enables /RTC1 and /EHsc by default, but they're not compatible with /clr, so remove them
if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1")
......
......@@ -34,7 +34,6 @@ set __BuildType=Debug
set __TargetOS=Windows_NT
set "__ProjectFilesDir=%__TestDir%"
set "__SourceDir=%__RepoRootDir%\src\coreclr\src"
set "__RootBinDir=%__RepoRootDir%\artifacts"
set "__LogsDir=%__RootBinDir%\log"
set "__MsbuildDebugLogsDir=%__LogsDir%\MsbuildDebugLogs"
......@@ -225,7 +224,7 @@ echo %__MsgPrefix%Commencing build of native test components for %__BuildArch%/%
REM Set the environment for the native build
REM Eval the output from set-cmake-path.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\set-cmake-path.ps1"""') do %%a
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__RepoRootDir%\eng\native\set-cmake-path.ps1"""') do %%a
echo %__MsgPrefix%Using CMake from !CMakePath!
REM NumberOfCores is an WMI property providing number of physical cores on machine
......@@ -256,7 +255,7 @@ if not defined VSINSTALLDIR (
if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_ENG_NATIVE_DIR=%__RepoRootDir%/eng/native"
call "%__SourceDir%\pal\tools\gen-buildsys.cmd" "%__ProjectFilesDir%" "%__NativeTestIntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectFilesDir%" "%__NativeTestIntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册