Skip to content

Commit

Permalink
Handle cases when coreclr configuration is different from libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Oct 20, 2020
1 parent a6a03d3 commit cc481ef
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/installer/corehost/Windows/gen-buildsys-win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ 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% " "-DNATIVE_LIBS_ARTIFACTS=%__NativeLibsArtifacts%"
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"

Expand Down
1 change: 1 addition & 0 deletions src/installer/corehost/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop)
if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop)


shift
Expand Down
55 changes: 48 additions & 7 deletions src/installer/corehost/cli/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ set(SOURCES
../bundle_marker.cpp
./hostfxr_resolver.cpp
./hostpolicy_resolver.cpp
../../hostpolicy/static/coreclr_resolver.cpp
)

set(HEADERS
../bundle_marker.h
../../../hostfxr_resolver.h
)

list(APPEND SOURCES $<TARGET_OBJECTS:libhostfxr_static> $<TARGET_OBJECTS:libhostpolicy_static>)
add_definitions(-D_NO_ASYNCRTIMP)
add_definitions(-D_NO_PPLXIMP)
add_definitions(-DEXPORT_SHARED_API=1)
add_definitions(-DHOSTPOLICY_EMBEDDED)


include(../../fxr/files.cmake)
include(../../hostpolicy/files.cmake)
include(../../hostcommon/files.cmake)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
Expand All @@ -46,12 +55,47 @@ include(configure.cmake)
add_definitions(-DFEATURE_APPHOST=1)
add_definitions(-DFEATURE_STATIC_HOST=1)

# Disable manifest generation into the file .exe on Windows
if(CLR_CMAKE_TARGET_WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY
LINK_FLAGS "/MANIFEST:NO"
# Disable manifest generation into the file .exe on Windows
add_linker_flag("/MANIFEST:NO")

get_property(ALL_COMPILE_OPTIONS TARGET ${PROJECT_NAME} PROPERTY COMPILE_OPTIONS)
string(TOUPPER ${RUNTIME_CONFIG} UPPERCASE_RUNTIME_CONFIG)

# make sure that certain compiler and linker settings match the runtime config
# we need to ensure that to be able to link with coreclr in mixed builds (ex: Debug with Release runtime)
if(UPPERCASE_RUNTIME_CONFIG STREQUAL DEBUG OR UPPERCASE_RUNTIME_CONFIG STREQUAL CHECKED)
# add_compile_options(/MTd)
# per-config options will win, so we have to use this syntax to override
set_property(TARGET ${PROJECT_NAME} PROPERTY
COMPILE_OPTIONS "${ALL_COMPILE_OPTIONS};$<$<CONFIG:DEBUG>:/MTd>"
)

remove_definitions(-DNDEBUG)
add_definitions(-DDEBUG -D_DEBUG -D_DBG)

# ignore runtime libraries that could have been added so far based on the config
add_linker_flag("/NODEFAULTLIB:ucrt.lib")
add_linker_flag("/NODEFAULTLIB:libucrt.lib")
add_linker_flag("/NODEFAULTLIB:libcmt.lib")

# make sure we use statically linked crt
add_linker_flag("/DEFAULTLIB:libucrtd.lib")
else()
# add_compile_options(/MT)
# per-config options will win, so we have to use this syntax to override
set_property(TARGET ${PROJECT_NAME} PROPERTY
COMPILE_OPTIONS "${ALL_COMPILE_OPTIONS};$<$<CONFIG:DEBUG>:/MT>"
)

remove_definitions(-DDEBUG -D_DEBUG -D_DBG)
add_definitions(-DNDEBUG)

# Force uCRT to be dynamically linked for Release build
add_linker_flag("/NODEFAULTLIB:libucrt.lib")
add_linker_flag("/DEFAULTLIB:ucrt.lib")
endif()

# Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the
# invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page).
add_linker_flag("/INCREMENTAL:NO")
Expand All @@ -72,8 +116,6 @@ if(CLR_CMAKE_TARGET_WIN32)
set(CORECLR_LIBRARIES
${CORECLR_STATIC_LIB_LOCATION}/coreclr_static.lib
${CORECLR_STATIC_LIB_LOCATION}/System.Globalization.Native.lib
${STATIC_MT_CRT_LIB}
${STATIC_MT_VCRT_LIB}
kernel32.lib
advapi32.lib
ole32.lib
Expand Down Expand Up @@ -212,7 +254,6 @@ endif(NOT CLR_CMAKE_TARGET_LINUX)
set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1)

target_link_libraries(singlefilehost
libhostcommon
${CORECLR_LIBRARIES}

${START_WHOLE_ARCHIVE}
Expand Down
8 changes: 0 additions & 8 deletions src/installer/corehost/cli/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@

project(${DOTNET_PROJECT_NAME})

if(CLR_CMAKE_HOST_WIN32)
add_compile_options($<$<CONFIG:RelWithDebInfo>:/MT>)
add_compile_options($<$<CONFIG:Release>:/MT>)
add_compile_options($<$<CONFIG:Debug>:/MTd>)
else()
add_compile_options(-fvisibility=hidden)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/setup.cmake)

# Include directories
Expand Down
1 change: 0 additions & 1 deletion src/installer/corehost/cli/fxr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.

add_subdirectory(static)
add_subdirectory(standalone)
37 changes: 37 additions & 0 deletions src/installer/corehost/cli/fxr/files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.

# Include directories
include_directories(${CMAKE_CURRENT_LIST_DIR}/../json)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../fxr)

# CMake does not recommend using globbing since it messes with the freshness checks
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/command_line.cpp
${CMAKE_CURRENT_LIST_DIR}/corehost_init.cpp
${CMAKE_CURRENT_LIST_DIR}/hostfxr.cpp
${CMAKE_CURRENT_LIST_DIR}/fx_muxer.cpp
${CMAKE_CURRENT_LIST_DIR}/fx_resolver.cpp
${CMAKE_CURRENT_LIST_DIR}/fx_resolver.messages.cpp
${CMAKE_CURRENT_LIST_DIR}/framework_info.cpp
${CMAKE_CURRENT_LIST_DIR}/host_context.cpp
${CMAKE_CURRENT_LIST_DIR}/sdk_info.cpp
${CMAKE_CURRENT_LIST_DIR}/sdk_resolver.cpp
)

list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/../corehost_context_contract.h
${CMAKE_CURRENT_LIST_DIR}/../hostpolicy.h
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.h
${CMAKE_CURRENT_LIST_DIR}/../fx_reference.h
${CMAKE_CURRENT_LIST_DIR}/../roll_fwd_on_no_candidate_fx_option.h
${CMAKE_CURRENT_LIST_DIR}/command_line.h
${CMAKE_CURRENT_LIST_DIR}/corehost_init.h
${CMAKE_CURRENT_LIST_DIR}/fx_muxer.h
${CMAKE_CURRENT_LIST_DIR}/fx_resolver.h
${CMAKE_CURRENT_LIST_DIR}/framework_info.h
${CMAKE_CURRENT_LIST_DIR}/host_context.h
${CMAKE_CURRENT_LIST_DIR}/sdk_info.h
${CMAKE_CURRENT_LIST_DIR}/sdk_resolver.h
)

15 changes: 2 additions & 13 deletions src/installer/corehost/cli/fxr/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,17 @@ project(hostfxr)

set(DOTNET_PROJECT_NAME "hostfxr")

# Include directories
include_directories(../../json)
include_directories(../../fxr)

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
./hostpolicy_resolver.cpp
$<TARGET_OBJECTS:libhostfxr_static>
)

set(HEADERS
../command_line.h
../corehost_init.h
../fx_muxer.h
../fx_resolver.h
../framework_info.h
../host_context.h
../sdk_info.h
../sdk_resolver.h
../hostpolicy_resolver.h
)

include(../files.cmake)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
hostfxr.def)
Expand Down
44 changes: 0 additions & 44 deletions src/installer/corehost/cli/fxr/static/CMakeLists.txt

This file was deleted.

39 changes: 1 addition & 38 deletions src/installer/corehost/cli/hostcommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,7 @@ project(hostcommon)

set(DOTNET_PROJECT_NAME "hostcommon")

# Include directories
include_directories(../fxr)
include_directories(../json)

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
../json_parser.cpp
../deps_format.cpp
../deps_entry.cpp
../host_startup_info.cpp
../roll_forward_option.cpp
../fx_definition.cpp
../fx_reference.cpp
../fxr/fx_ver.cpp
../version.cpp
../version_compatibility_range.cpp
../runtime_config.cpp
../bundle/info.cpp
../bundle/reader.cpp
../bundle/header.cpp
)

set(HEADERS
../json_parser.h
../deps_format.h
../deps_entry.h
../host_startup_info.h
../roll_forward_option.h
../fx_definition.h
../fx_reference.h
../fxr/fx_ver.h
../version.h
../version_compatibility_range.h
../runtime_config.h
../bundle/info.h
../bundle/reader.h
../bundle/header.h
)
include(files.cmake)

set(SKIP_VERSIONING 1)
include(../lib_static.cmake)
Expand Down
43 changes: 43 additions & 0 deletions src/installer/corehost/cli/hostcommon/files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.

# Include directories
include_directories(${CMAKE_CURRENT_LIST_DIR}/../fxr)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../json)

# CMake does not recommend using globbing since it messes with the freshness checks
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/../json_parser.cpp
${CMAKE_CURRENT_LIST_DIR}/../deps_format.cpp
${CMAKE_CURRENT_LIST_DIR}/../deps_entry.cpp
${CMAKE_CURRENT_LIST_DIR}/../host_startup_info.cpp
${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.cpp
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.cpp
${CMAKE_CURRENT_LIST_DIR}/../fx_reference.cpp
${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.cpp
${CMAKE_CURRENT_LIST_DIR}/../version.cpp
${CMAKE_CURRENT_LIST_DIR}/../version_compatibility_range.cpp
${CMAKE_CURRENT_LIST_DIR}/../runtime_config.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/info.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/reader.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/header.cpp
)

list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/../json_parser.h
${CMAKE_CURRENT_LIST_DIR}/../deps_format.h
${CMAKE_CURRENT_LIST_DIR}/../deps_entry.h
${CMAKE_CURRENT_LIST_DIR}/../host_startup_info.h
${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.h
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.h
${CMAKE_CURRENT_LIST_DIR}/../fx_reference.h
${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.h
${CMAKE_CURRENT_LIST_DIR}/../version.h
${CMAKE_CURRENT_LIST_DIR}/../version_compatibility_range.h
${CMAKE_CURRENT_LIST_DIR}/../runtime_config.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/info.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/reader.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/header.h
)


1 change: 0 additions & 1 deletion src/installer/corehost/cli/hostpolicy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.

add_subdirectory(static)
add_subdirectory(standalone)
40 changes: 40 additions & 0 deletions src/installer/corehost/cli/hostpolicy/files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.

# Include directories
include_directories(${CMAKE_CURRENT_LIST_DIR}/../fxr)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../json)

# CMake does not recommend using globbing since it messes with the freshness checks
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/args.cpp
${CMAKE_CURRENT_LIST_DIR}/breadcrumbs.cpp
${CMAKE_CURRENT_LIST_DIR}/coreclr.cpp
${CMAKE_CURRENT_LIST_DIR}/deps_resolver.cpp
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_context.cpp
${CMAKE_CURRENT_LIST_DIR}/hostpolicy.cpp
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_init.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/dir_utils.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/extractor.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/file_entry.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/manifest.cpp
${CMAKE_CURRENT_LIST_DIR}/../bundle/runner.cpp
)

list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/args.h
${CMAKE_CURRENT_LIST_DIR}/breadcrumbs.h
${CMAKE_CURRENT_LIST_DIR}/coreclr.h
${CMAKE_CURRENT_LIST_DIR}/deps_resolver.h
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_context.h
${CMAKE_CURRENT_LIST_DIR}/hostpolicy_init.h
${CMAKE_CURRENT_LIST_DIR}/../hostpolicy.h
${CMAKE_CURRENT_LIST_DIR}/../corehost_context_contract.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/dir_utils.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/extractor.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/file_entry.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/manifest.h
${CMAKE_CURRENT_LIST_DIR}/../bundle/runner.h
${CMAKE_CURRENT_LIST_DIR}/../../coreclr_resolver.h
)

Loading

0 comments on commit cc481ef

Please sign in to comment.