diff --git a/build.psm1 b/build.psm1 index a4b5bcd..3f63aff 100644 --- a/build.psm1 +++ b/build.psm1 @@ -222,13 +222,7 @@ function Start-BuildNativeWindowsBinaries { $atlBaseFound = $false - if ($vcPath) { - $atlMfcIncludePath = Join-Path -Path $vcPath -ChildPath 'atlmfc/include' - if(Test-Path -Path "$atlMfcIncludePath\atlbase.h") { - Write-Verbose -Verbose "ATLF MFC found under $atlMfcIncludePath\atlbase.h" - $atlBaseFound = $true - } - } elseif ($alternateVCPath) { + if ($alternateVCPath) { foreach($candidatePath in $alternateVCPath) { Write-Verbose -Verbose "Looking under $candidatePath" $atlMfcIncludePath = @(Get-ChildItem -Path $candidatePath -Recurse -Filter 'atlbase.h' -File) @@ -241,6 +235,12 @@ function Start-BuildNativeWindowsBinaries { } } } + } elseif ($vcPath) { + $atlMfcIncludePath = Join-Path -Path $vcPath -ChildPath 'atlmfc/include' + if(Test-Path -Path "$atlMfcIncludePath\atlbase.h") { + Write-Verbose -Verbose "ATLF MFC found under $atlMfcIncludePath\atlbase.h" + $atlBaseFound = $true + } } else { Write-Verbose -Verbose "PATH: $env:PATH" throw "Visual Studio tools not found in PATH." diff --git a/src/powershell-native/coreclr_defs.cmake b/src/powershell-native/coreclr_defs.cmake index 1b6ea3e..fe70a14 100644 --- a/src/powershell-native/coreclr_defs.cmake +++ b/src/powershell-native/coreclr_defs.cmake @@ -47,11 +47,11 @@ set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWIT set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS}") -# Force uCRT to be dynamically linked for Release build -set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") -set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") -set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") +# Force uCRT to be dynamically linked for Release build +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") +set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") #------------------------------------ # Definitions (for platform) @@ -133,16 +133,18 @@ if (BUILD_ARCH_AMD64) endif (BUILD_ARCH_AMD64) # enable control-flow-guard support for native components for non-Arm64 builds -add_compile_options(/guard:cf) - -# Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid -# linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST. -# -# 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($<$,$>:/MT>) -add_compile_options($<$,$>:/MTd>) +add_compile_options(/guard:cf) + +# Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid +# linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST. +# +# 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($<$,$>:/MT>) +add_compile_options($<$,$>:/MTd>) + +add_compile_options(/Qspectre) # add Spectre mitigation compiler option. (https://docs.microsoft.com/en-us/cpp/build/reference/qspectre?view=vs-2017) #set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256")