From b4b482006bf76a79acb6bf07e698b3bc97bd89e3 Mon Sep 17 00:00:00 2001 From: schellap Date: Wed, 13 Jan 2016 21:35:31 -0800 Subject: [PATCH] Fix host name, debuggability and embed CRT --- packaging/osx/scripts/postinstall | 2 +- scripts/compile/compile-corehost.ps1 | 20 ++++++---- scripts/compile/compile-corehost.sh | 4 +- scripts/compile/compile-stage.ps1 | 2 +- scripts/compile/compile-stage.sh | 4 +- src/Microsoft.DotNet.Cli.Utils/Constants.cs | 2 +- src/corehost/cli/CMakeLists.txt | 7 +++- src/corehost/cli/dll/CMakeLists.txt | 14 +++++-- .../cli/{clihost.cpp => hostpolicy.cpp} | 0 src/corehost/cli/libhost.h | 2 +- src/corehost/cli/setup.cmake | 37 +++++++++++++++++++ 11 files changed, 73 insertions(+), 21 deletions(-) rename src/corehost/cli/{clihost.cpp => hostpolicy.cpp} (100%) create mode 100644 src/corehost/cli/setup.cmake diff --git a/packaging/osx/scripts/postinstall b/packaging/osx/scripts/postinstall index e7d0706bc..ec1b3ec28 100755 --- a/packaging/osx/scripts/postinstall +++ b/packaging/osx/scripts/postinstall @@ -26,7 +26,7 @@ ln -s $INSTALL_DESTINATION/bin/dotnet-run /usr/local/bin/ ln -s $INSTALL_DESTINATION/bin/dotnet-test /usr/local/bin/ ln -s $INSTALL_DESTINATION/bin/dotnet-dnx /usr/local/bin/ ln -s $INSTALL_DESTINATION/bin/csc /usr/local/bin/ -ln -s $INSTALL_DESTINATION/bin/libclihost.dylib /usr/local/bin/ +ln -s $INSTALL_DESTINATION/bin/libhostpolicy.dylib /usr/local/bin/ # A temporary solution to unblock dotnet compile cp $INSTALL_DESTINATION/bin/corehost /usr/local/bin/ diff --git a/scripts/compile/compile-corehost.ps1 b/scripts/compile/compile-corehost.ps1 index 572087d63..ec2f88234 100644 --- a/scripts/compile/compile-corehost.ps1 +++ b/scripts/compile/compile-corehost.ps1 @@ -17,25 +17,29 @@ try { if (Test-Path "env:\ProgramFiles(x86)") { $pf = (cat "env:\ProgramFiles(x86)") } - & "$pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$Configuration" + $BuildConfiguration = $Configuration + if ($Configuration -eq "Release") { + $BuildConfiguration = "RelWithDebInfo" + } + & "$pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$BuildConfiguration" if (!$?) { - Write-Host "Command failed: $pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$Configuration" + Write-Host "Command failed: $pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$BuildConfiguration" Exit 1 } if (!(Test-Path $HostDir)) { mkdir $HostDir | Out-Null } - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\$Configuration\corehost.exe" $HostDir - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$Configuration\clihost.dll" $HostDir + cp "$RepoRoot\src\corehost\cmake\$Rid\cli\$BuildConfiguration\corehost.exe" $HostDir + cp "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$BuildConfiguration\hostpolicy.dll" $HostDir - if (Test-Path "$RepoRoot\src\corehost\cmake\$Rid\cli\$Configuration\corehost.pdb") + if (Test-Path "$RepoRoot\src\corehost\cmake\$Rid\cli\$BuildConfiguration\corehost.pdb") { - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\$Configuration\corehost.pdb" $HostDir + cp "$RepoRoot\src\corehost\cmake\$Rid\cli\$BuildConfiguration\corehost.pdb" $HostDir } - if (Test-Path "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$Configuration\clihost.pdb") + if (Test-Path "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$BuildConfiguration\hostpolicy.pdb") { - cp "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$Configuration\clihost.pdb" $HostDir + cp "$RepoRoot\src\corehost\cmake\$Rid\cli\dll\$BuildConfiguration\hostpolicy.pdb" $HostDir } } finally { popd diff --git a/scripts/compile/compile-corehost.sh b/scripts/compile/compile-corehost.sh index 195f5ee58..109e5a655 100755 --- a/scripts/compile/compile-corehost.sh +++ b/scripts/compile/compile-corehost.sh @@ -26,9 +26,9 @@ make # Publish to artifacts [ -d "$HOST_DIR" ] || mkdir -p $HOST_DIR if [[ "$OSNAME" == "osx" ]]; then - COREHOST_LIBNAME=libclihost.dylib + COREHOST_LIBNAME=libhostpolicy.dylib else - COREHOST_LIBNAME=libclihost.so + COREHOST_LIBNAME=libhostpolicy.so fi cp "$REPOROOT/src/corehost/cmake/$RID/cli/corehost" $HOST_DIR cp "$REPOROOT/src/corehost/cmake/$RID/cli/dll/${COREHOST_LIBNAME}" $HOST_DIR diff --git a/scripts/compile/compile-stage.ps1 b/scripts/compile/compile-stage.ps1 index a12167b4e..c90628aaf 100644 --- a/scripts/compile/compile-stage.ps1 +++ b/scripts/compile/compile-stage.ps1 @@ -78,7 +78,7 @@ cp -rec "$RuntimeOutputDir\*" "$OutputDir\bin" # Deploy the CLR host to the output cp "$HostDir\corehost.exe" "$OutputDir\bin" -cp "$HostDir\clihost.dll" "$OutputDir\bin" +cp "$HostDir\hostpolicy.dll" "$OutputDir\bin" # corehostify externally-provided binaries (csc, vbc, etc.) $BinariesForCoreHost | ForEach-Object { diff --git a/scripts/compile/compile-stage.sh b/scripts/compile/compile-stage.sh index 993a5c912..41f56ea99 100755 --- a/scripts/compile/compile-stage.sh +++ b/scripts/compile/compile-stage.sh @@ -77,9 +77,9 @@ cp -R $RUNTIME_OUTPUT_DIR/* $OUTPUT_DIR/bin # Deploy CLR host to the output if [[ "$OSNAME" == "osx" ]]; then - COREHOST_LIBNAME=libclihost.dylib + COREHOST_LIBNAME=libhostpolicy.dylib else - COREHOST_LIBNAME=libclihost.so + COREHOST_LIBNAME=libhostpolicy.so fi cp "$HOST_DIR/corehost" "$OUTPUT_DIR/bin" cp "$HOST_DIR/${COREHOST_LIBNAME}" "$OUTPUT_DIR/bin" diff --git a/src/Microsoft.DotNet.Cli.Utils/Constants.cs b/src/Microsoft.DotNet.Cli.Utils/Constants.cs index 78b4019ae..943fdb7c4 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Constants.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Constants.cs @@ -34,7 +34,7 @@ namespace Microsoft.DotNet.Cli.Utils public static readonly string HostExecutableName = "corehost" + ExeSuffix; public static readonly string[] HostBinaryNames = new string[] { HostExecutableName, - (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "clihost" : "libclihost") + DynamicLibSuffix + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "hostpolicy" : "libhostpolicy") + DynamicLibSuffix }; } } diff --git a/src/corehost/cli/CMakeLists.txt b/src/corehost/cli/CMakeLists.txt index e5bc544f1..5e2942c5c 100644 --- a/src/corehost/cli/CMakeLists.txt +++ b/src/corehost/cli/CMakeLists.txt @@ -5,10 +5,13 @@ cmake_minimum_required (VERSION 2.6) project (corehost) if(WIN32) -set(CMAKE_CXX_FLAGS_DEBUG "/MTd") -set(CMAKE_CXX_FLAGS_RELEASE "/MT") + add_compile_options($<$:/MT>) + add_compile_options($<$:/MT>) + add_compile_options($<$:/MTd>) endif() +include(setup.cmake) + set (CMAKE_CXX_STANDARD 11) include_directories(../common) diff --git a/src/corehost/cli/dll/CMakeLists.txt b/src/corehost/cli/dll/CMakeLists.txt index 649be8aa3..80fb8964a 100644 --- a/src/corehost/cli/dll/CMakeLists.txt +++ b/src/corehost/cli/dll/CMakeLists.txt @@ -2,7 +2,15 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. cmake_minimum_required (VERSION 2.6) -project(clihost) +project(hostpolicy) + +if(WIN32) + add_compile_options($<$:/MD>) + add_compile_options($<$:/MD>) + add_compile_options($<$:/MDd>) +endif() + +include(../setup.cmake) include_directories(../../common) @@ -12,7 +20,7 @@ set(SOURCES ../../common/utils.cpp ../args.cpp - ../clihost.cpp + ../hostpolicy.cpp ../coreclr.cpp ../deps_resolver.cpp ../servicing_index.cpp) @@ -26,5 +34,5 @@ endif() add_definitions(-DCOREHOST_MAKE_DLL=1) -add_library(clihost SHARED ${SOURCES}) +add_library(hostpolicy SHARED ${SOURCES}) diff --git a/src/corehost/cli/clihost.cpp b/src/corehost/cli/hostpolicy.cpp similarity index 100% rename from src/corehost/cli/clihost.cpp rename to src/corehost/cli/hostpolicy.cpp diff --git a/src/corehost/cli/libhost.h b/src/corehost/cli/libhost.h index 28cc39cae..0b8ea823a 100644 --- a/src/corehost/cli/libhost.h +++ b/src/corehost/cli/libhost.h @@ -1,4 +1,4 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#define LIBHOST_NAME MAKE_LIBNAME("clihost") +#define LIBHOST_NAME MAKE_LIBNAME("hostpolicy") diff --git a/src/corehost/cli/setup.cmake b/src/corehost/cli/setup.cmake new file mode 100644 index 000000000..3cc0115c5 --- /dev/null +++ b/src/corehost/cli/setup.cmake @@ -0,0 +1,37 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. + +if(WIN32) + add_definitions(-DWIN32) + add_definitions(-D_WIN32=1) + if(IS_64BIT_BUILD) + add_definitions(-D_WIN64=1) + endif() + add_compile_options($<$:-DDEBUG>) + add_compile_options($<$:/Od>) + add_compile_options($<$:/Gm>) + add_compile_options(/DEBUG) + add_compile_options(/GS) + add_compile_options(/W1) + add_compile_options(/Zc:inline) + add_compile_options(/fp:precise) + add_compile_options(/EHsc) + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL:NO") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /PDBCOMPRESS") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864") + + # Debug build specific flags + set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NOVCFEATURE") + + # Release build specific flags + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") + + # RelWithDebInfo specific flags + set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF") + set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DEBUG /OPT:REF /OPT:ICF") +endif()