Skip to content

Commit cc481ef

Browse files
committed
Handle cases when coreclr configuration is different from libraries
1 parent a6a03d3 commit cc481ef

File tree

15 files changed

+175
-197
lines changed

15 files changed

+175
-197
lines changed

src/installer/corehost/Windows/gen-buildsys-win.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ popd
4343
:DoGen
4444
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%"
4545
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%"
46-
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCORECLR_ARTIFACTS=%__CoreClrArtifacts% " "-DNATIVE_LIBS_ARTIFACTS=%__NativeLibsArtifacts%"
46+
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCORECLR_ARTIFACTS=%__CoreClrArtifacts% " "-DRUNTIME_CONFIG=%__RuntimeConfiguration%" "-DNATIVE_LIBS_ARTIFACTS=%__NativeLibsArtifacts%"
4747
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% "
4848
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCLR_ENG_NATIVE_DIR=%__sourceDir%\..\..\..\eng\native"
4949

src/installer/corehost/build.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ if /i [%1] == [rootDir] ( set __rootDir=%2&&shift&&shift&goto Arg_Loop)
4141
if /i [%1] == [coreclrartifacts] (set __CoreClrArtifacts=%2&&shift&&shift&goto Arg_Loop)
4242
if /i [%1] == [nativelibsartifacts] (set __NativeLibsArtifacts=%2&&shift&&shift&goto Arg_Loop)
4343
if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop)
44+
if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop)
4445

4546

4647
shift

src/installer/corehost/cli/apphost/static/CMakeLists.txt

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ set(SOURCES
2323
../bundle_marker.cpp
2424
./hostfxr_resolver.cpp
2525
./hostpolicy_resolver.cpp
26+
../../hostpolicy/static/coreclr_resolver.cpp
2627
)
2728

2829
set(HEADERS
2930
../bundle_marker.h
3031
../../../hostfxr_resolver.h
3132
)
3233

33-
list(APPEND SOURCES $<TARGET_OBJECTS:libhostfxr_static> $<TARGET_OBJECTS:libhostpolicy_static>)
34+
add_definitions(-D_NO_ASYNCRTIMP)
35+
add_definitions(-D_NO_PPLXIMP)
36+
add_definitions(-DEXPORT_SHARED_API=1)
37+
add_definitions(-DHOSTPOLICY_EMBEDDED)
38+
39+
40+
include(../../fxr/files.cmake)
41+
include(../../hostpolicy/files.cmake)
42+
include(../../hostcommon/files.cmake)
3443

3544
if(CLR_CMAKE_TARGET_WIN32)
3645
list(APPEND SOURCES
@@ -46,12 +55,47 @@ include(configure.cmake)
4655
add_definitions(-DFEATURE_APPHOST=1)
4756
add_definitions(-DFEATURE_STATIC_HOST=1)
4857

49-
# Disable manifest generation into the file .exe on Windows
5058
if(CLR_CMAKE_TARGET_WIN32)
51-
set_property(TARGET ${PROJECT_NAME} PROPERTY
52-
LINK_FLAGS "/MANIFEST:NO"
59+
# Disable manifest generation into the file .exe on Windows
60+
add_linker_flag("/MANIFEST:NO")
61+
62+
get_property(ALL_COMPILE_OPTIONS TARGET ${PROJECT_NAME} PROPERTY COMPILE_OPTIONS)
63+
string(TOUPPER ${RUNTIME_CONFIG} UPPERCASE_RUNTIME_CONFIG)
64+
65+
# make sure that certain compiler and linker settings match the runtime config
66+
# we need to ensure that to be able to link with coreclr in mixed builds (ex: Debug with Release runtime)
67+
if(UPPERCASE_RUNTIME_CONFIG STREQUAL DEBUG OR UPPERCASE_RUNTIME_CONFIG STREQUAL CHECKED)
68+
# add_compile_options(/MTd)
69+
# per-config options will win, so we have to use this syntax to override
70+
set_property(TARGET ${PROJECT_NAME} PROPERTY
71+
COMPILE_OPTIONS "${ALL_COMPILE_OPTIONS};$<$<CONFIG:DEBUG>:/MTd>"
72+
)
73+
74+
remove_definitions(-DNDEBUG)
75+
add_definitions(-DDEBUG -D_DEBUG -D_DBG)
76+
77+
# ignore runtime libraries that could have been added so far based on the config
78+
add_linker_flag("/NODEFAULTLIB:ucrt.lib")
79+
add_linker_flag("/NODEFAULTLIB:libucrt.lib")
80+
add_linker_flag("/NODEFAULTLIB:libcmt.lib")
81+
82+
# make sure we use statically linked crt
83+
add_linker_flag("/DEFAULTLIB:libucrtd.lib")
84+
else()
85+
# add_compile_options(/MT)
86+
# per-config options will win, so we have to use this syntax to override
87+
set_property(TARGET ${PROJECT_NAME} PROPERTY
88+
COMPILE_OPTIONS "${ALL_COMPILE_OPTIONS};$<$<CONFIG:DEBUG>:/MT>"
5389
)
5490

91+
remove_definitions(-DDEBUG -D_DEBUG -D_DBG)
92+
add_definitions(-DNDEBUG)
93+
94+
# Force uCRT to be dynamically linked for Release build
95+
add_linker_flag("/NODEFAULTLIB:libucrt.lib")
96+
add_linker_flag("/DEFAULTLIB:ucrt.lib")
97+
endif()
98+
5599
# Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the
56100
# invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page).
57101
add_linker_flag("/INCREMENTAL:NO")
@@ -72,8 +116,6 @@ if(CLR_CMAKE_TARGET_WIN32)
72116
set(CORECLR_LIBRARIES
73117
${CORECLR_STATIC_LIB_LOCATION}/coreclr_static.lib
74118
${CORECLR_STATIC_LIB_LOCATION}/System.Globalization.Native.lib
75-
${STATIC_MT_CRT_LIB}
76-
${STATIC_MT_VCRT_LIB}
77119
kernel32.lib
78120
advapi32.lib
79121
ole32.lib
@@ -212,7 +254,6 @@ endif(NOT CLR_CMAKE_TARGET_LINUX)
212254
set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1)
213255

214256
target_link_libraries(singlefilehost
215-
libhostcommon
216257
${CORECLR_LIBRARIES}
217258

218259
${START_WHOLE_ARCHIVE}

src/installer/corehost/cli/common.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33

44
project(${DOTNET_PROJECT_NAME})
55

6-
if(CLR_CMAKE_HOST_WIN32)
7-
add_compile_options($<$<CONFIG:RelWithDebInfo>:/MT>)
8-
add_compile_options($<$<CONFIG:Release>:/MT>)
9-
add_compile_options($<$<CONFIG:Debug>:/MTd>)
10-
else()
11-
add_compile_options(-fvisibility=hidden)
12-
endif()
13-
146
include(${CMAKE_CURRENT_LIST_DIR}/setup.cmake)
157

168
# Include directories
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Licensed to the .NET Foundation under one or more agreements.
22
# The .NET Foundation licenses this file to you under the MIT license.
33

4-
add_subdirectory(static)
54
add_subdirectory(standalone)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Licensed to the .NET Foundation under one or more agreements.
2+
# The .NET Foundation licenses this file to you under the MIT license.
3+
4+
# Include directories
5+
include_directories(${CMAKE_CURRENT_LIST_DIR}/../json)
6+
include_directories(${CMAKE_CURRENT_LIST_DIR}/../fxr)
7+
8+
# CMake does not recommend using globbing since it messes with the freshness checks
9+
list(APPEND SOURCES
10+
${CMAKE_CURRENT_LIST_DIR}/command_line.cpp
11+
${CMAKE_CURRENT_LIST_DIR}/corehost_init.cpp
12+
${CMAKE_CURRENT_LIST_DIR}/hostfxr.cpp
13+
${CMAKE_CURRENT_LIST_DIR}/fx_muxer.cpp
14+
${CMAKE_CURRENT_LIST_DIR}/fx_resolver.cpp
15+
${CMAKE_CURRENT_LIST_DIR}/fx_resolver.messages.cpp
16+
${CMAKE_CURRENT_LIST_DIR}/framework_info.cpp
17+
${CMAKE_CURRENT_LIST_DIR}/host_context.cpp
18+
${CMAKE_CURRENT_LIST_DIR}/sdk_info.cpp
19+
${CMAKE_CURRENT_LIST_DIR}/sdk_resolver.cpp
20+
)
21+
22+
list(APPEND HEADERS
23+
${CMAKE_CURRENT_LIST_DIR}/../corehost_context_contract.h
24+
${CMAKE_CURRENT_LIST_DIR}/../hostpolicy.h
25+
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.h
26+
${CMAKE_CURRENT_LIST_DIR}/../fx_reference.h
27+
${CMAKE_CURRENT_LIST_DIR}/../roll_fwd_on_no_candidate_fx_option.h
28+
${CMAKE_CURRENT_LIST_DIR}/command_line.h
29+
${CMAKE_CURRENT_LIST_DIR}/corehost_init.h
30+
${CMAKE_CURRENT_LIST_DIR}/fx_muxer.h
31+
${CMAKE_CURRENT_LIST_DIR}/fx_resolver.h
32+
${CMAKE_CURRENT_LIST_DIR}/framework_info.h
33+
${CMAKE_CURRENT_LIST_DIR}/host_context.h
34+
${CMAKE_CURRENT_LIST_DIR}/sdk_info.h
35+
${CMAKE_CURRENT_LIST_DIR}/sdk_resolver.h
36+
)
37+

src/installer/corehost/cli/fxr/standalone/CMakeLists.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,17 @@ project(hostfxr)
55

66
set(DOTNET_PROJECT_NAME "hostfxr")
77

8-
# Include directories
9-
include_directories(../../json)
10-
include_directories(../../fxr)
11-
128
# CMake does not recommend using globbing since it messes with the freshness checks
139
set(SOURCES
1410
./hostpolicy_resolver.cpp
15-
$<TARGET_OBJECTS:libhostfxr_static>
1611
)
1712

1813
set(HEADERS
19-
../command_line.h
20-
../corehost_init.h
21-
../fx_muxer.h
22-
../fx_resolver.h
23-
../framework_info.h
24-
../host_context.h
25-
../sdk_info.h
26-
../sdk_resolver.h
2714
../hostpolicy_resolver.h
2815
)
2916

17+
include(../files.cmake)
18+
3019
if(CLR_CMAKE_TARGET_WIN32)
3120
list(APPEND SOURCES
3221
hostfxr.def)

src/installer/corehost/cli/fxr/static/CMakeLists.txt

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/installer/corehost/cli/hostcommon/CMakeLists.txt

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,7 @@ project(hostcommon)
55

66
set(DOTNET_PROJECT_NAME "hostcommon")
77

8-
# Include directories
9-
include_directories(../fxr)
10-
include_directories(../json)
11-
12-
# CMake does not recommend using globbing since it messes with the freshness checks
13-
set(SOURCES
14-
../json_parser.cpp
15-
../deps_format.cpp
16-
../deps_entry.cpp
17-
../host_startup_info.cpp
18-
../roll_forward_option.cpp
19-
../fx_definition.cpp
20-
../fx_reference.cpp
21-
../fxr/fx_ver.cpp
22-
../version.cpp
23-
../version_compatibility_range.cpp
24-
../runtime_config.cpp
25-
../bundle/info.cpp
26-
../bundle/reader.cpp
27-
../bundle/header.cpp
28-
)
29-
30-
set(HEADERS
31-
../json_parser.h
32-
../deps_format.h
33-
../deps_entry.h
34-
../host_startup_info.h
35-
../roll_forward_option.h
36-
../fx_definition.h
37-
../fx_reference.h
38-
../fxr/fx_ver.h
39-
../version.h
40-
../version_compatibility_range.h
41-
../runtime_config.h
42-
../bundle/info.h
43-
../bundle/reader.h
44-
../bundle/header.h
45-
)
8+
include(files.cmake)
469

4710
set(SKIP_VERSIONING 1)
4811
include(../lib_static.cmake)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Licensed to the .NET Foundation under one or more agreements.
2+
# The .NET Foundation licenses this file to you under the MIT license.
3+
4+
# Include directories
5+
include_directories(${CMAKE_CURRENT_LIST_DIR}/../fxr)
6+
include_directories(${CMAKE_CURRENT_LIST_DIR}/../json)
7+
8+
# CMake does not recommend using globbing since it messes with the freshness checks
9+
list(APPEND SOURCES
10+
${CMAKE_CURRENT_LIST_DIR}/../json_parser.cpp
11+
${CMAKE_CURRENT_LIST_DIR}/../deps_format.cpp
12+
${CMAKE_CURRENT_LIST_DIR}/../deps_entry.cpp
13+
${CMAKE_CURRENT_LIST_DIR}/../host_startup_info.cpp
14+
${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.cpp
15+
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.cpp
16+
${CMAKE_CURRENT_LIST_DIR}/../fx_reference.cpp
17+
${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.cpp
18+
${CMAKE_CURRENT_LIST_DIR}/../version.cpp
19+
${CMAKE_CURRENT_LIST_DIR}/../version_compatibility_range.cpp
20+
${CMAKE_CURRENT_LIST_DIR}/../runtime_config.cpp
21+
${CMAKE_CURRENT_LIST_DIR}/../bundle/info.cpp
22+
${CMAKE_CURRENT_LIST_DIR}/../bundle/reader.cpp
23+
${CMAKE_CURRENT_LIST_DIR}/../bundle/header.cpp
24+
)
25+
26+
list(APPEND HEADERS
27+
${CMAKE_CURRENT_LIST_DIR}/../json_parser.h
28+
${CMAKE_CURRENT_LIST_DIR}/../deps_format.h
29+
${CMAKE_CURRENT_LIST_DIR}/../deps_entry.h
30+
${CMAKE_CURRENT_LIST_DIR}/../host_startup_info.h
31+
${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.h
32+
${CMAKE_CURRENT_LIST_DIR}/../fx_definition.h
33+
${CMAKE_CURRENT_LIST_DIR}/../fx_reference.h
34+
${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.h
35+
${CMAKE_CURRENT_LIST_DIR}/../version.h
36+
${CMAKE_CURRENT_LIST_DIR}/../version_compatibility_range.h
37+
${CMAKE_CURRENT_LIST_DIR}/../runtime_config.h
38+
${CMAKE_CURRENT_LIST_DIR}/../bundle/info.h
39+
${CMAKE_CURRENT_LIST_DIR}/../bundle/reader.h
40+
${CMAKE_CURRENT_LIST_DIR}/../bundle/header.h
41+
)
42+
43+

0 commit comments

Comments
 (0)