-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Statically linking coreclr and clrjit in single file host #43556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7872a2b
4fac39a
038d2af
c34ca9b
7a4dc8f
250d3fc
c4f8e6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -46,11 +55,50 @@ 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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I keep wondering if we should unify the configuration of runtime and installer instead (so that we can never build different flavors of those two). I am not happy about hacking around defines and options to make things build and also about the fact that we now compile the host sources twice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think we need a general solution here. This will not be needed after we move hosts to clr partition (tracked by #43700). We just need to finish superhost - i.e. enable it not only on Linux. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As for mixed configurations - I think at least combinations with Checked runtime are useful, for the same reason they are useful with libs - running installer tests with Debug runtime is very slow. |
||
|
||
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") | ||
endif() | ||
|
||
# Specify non-default Windows libs to be used for Arm/Arm64 builds | ||
|
@@ -66,10 +114,8 @@ message ("Looking for coreclr_static lib at location: '${CORECLR_STATIC_LIB_LOCA | |
|
||
if(CLR_CMAKE_TARGET_WIN32) | ||
set(CORECLR_LIBRARIES | ||
# Disable superhost on Win32 for now. | ||
# ${CORECLR_STATIC_LIB_LOCATION}/coreclr_static.lib | ||
${STATIC_MT_CRT_LIB} | ||
${STATIC_MT_VCRT_LIB} | ||
${CORECLR_STATIC_LIB_LOCATION}/coreclr_static.lib | ||
${CORECLR_STATIC_LIB_LOCATION}/System.Globalization.Native.lib | ||
kernel32.lib | ||
advapi32.lib | ||
ole32.lib | ||
|
@@ -81,46 +127,44 @@ if(CLR_CMAKE_TARGET_WIN32) | |
bcrypt.lib | ||
RuntimeObject.lib | ||
) | ||
elseif(CLR_CMAKE_TARGET_LINUX) | ||
else() | ||
set(CORECLR_LIBRARIES | ||
${CORECLR_STATIC_LIB_LOCATION}/libcoreclr_static.a | ||
${CORECLR_STATIC_LIB_LOCATION}/libSystem.Globalization.Native.a | ||
${CORECLR_STATIC_LIB_LOCATION}/libcoreclrpal.a | ||
${CORECLR_STATIC_LIB_LOCATION}/libpalrt.a | ||
${CORECLR_STATIC_LIB_LOCATION}/libeventprovider.a | ||
${CORECLR_STATIC_LIB_LOCATION}/libnativeresourcestring.a | ||
) | ||
endif() | ||
|
||
# currently linking coreclr into the singlefilehost is only supported on linux | ||
# the following code here would be needed if/when BSD and OSX are supported too | ||
# | ||
# if(CLR_CMAKE_TARGET_OSX) | ||
# find_library(COREFOUNDATION CoreFoundation) | ||
# find_library(CORESERVICES CoreServices) | ||
# find_library(SECURITY Security) | ||
# find_library(SYSTEM System) | ||
# | ||
# LIST(APPEND CORECLR_LIBRARIES | ||
# ${COREFOUNDATION} | ||
# ${CORESERVICES} | ||
# ${SECURITY} | ||
# ${SYSTEM} | ||
# ) | ||
# endif(CLR_CMAKE_TARGET_OSX) | ||
# | ||
# if(CLR_CMAKE_TARGET_NETBSD) | ||
# find_library(KVM kvm) | ||
# | ||
# LIST(APPEND CORECLR_LIBRARIES | ||
# ${KVM} | ||
# ) | ||
# endif(CLR_CMAKE_TARGET_NETBSD) | ||
endif(CLR_CMAKE_TARGET_WIN32) | ||
if(CLR_CMAKE_TARGET_OSX) | ||
find_library(COREFOUNDATION CoreFoundation) | ||
find_library(CORESERVICES CoreServices) | ||
find_library(SECURITY Security) | ||
find_library(SYSTEM System) | ||
|
||
LIST(APPEND CORECLR_LIBRARIES | ||
${COREFOUNDATION} | ||
${CORESERVICES} | ||
${SECURITY} | ||
${SYSTEM} | ||
) | ||
endif(CLR_CMAKE_TARGET_OSX) | ||
|
||
if(CLR_CMAKE_TARGET_NETBSD) | ||
find_library(KVM kvm) | ||
|
||
LIST(APPEND CORECLR_LIBRARIES | ||
${KVM} | ||
) | ||
endif(CLR_CMAKE_TARGET_NETBSD) | ||
|
||
# Path like: artifacts/bin/native/net5.0-Linux-Release-arm/ | ||
set(NATIVE_LIBS_LOCATION "${NATIVE_LIBS_ARTIFACTS}") | ||
message ("Looking for native libs at location: '${NATIVE_LIBS_LOCATION}'.") | ||
# On *BSD, we always use the libunwind that's part of the OS | ||
if(CLR_CMAKE_TARGET_FREEBSD) | ||
set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) | ||
endif() | ||
|
||
# If/when OSX and *BSD are supported, they should also use the libunwind that's part of the OS | ||
if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) | ||
find_unwind_libs(UNWIND_LIBS) | ||
|
||
|
@@ -129,14 +173,17 @@ if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) | |
) | ||
endif() | ||
|
||
# Path like: artifacts/bin/native/net5.0-Linux-Release-arm/ | ||
set(NATIVE_LIBS_LOCATION "${NATIVE_LIBS_ARTIFACTS}") | ||
message ("Looking for native libs at location: '${NATIVE_LIBS_LOCATION}'.") | ||
|
||
if(NOT CLR_CMAKE_TARGET_LINUX) | ||
set(NATIVE_LIBS | ||
# Native libs linked into singlefilehost is supported only on Linux for now. | ||
# if/when BSD and OSX are supported too, consider the commented code sections below. | ||
) | ||
else() | ||
set(NATIVE_LIBS | ||
${NATIVE_LIBS_LOCATION}/libSystem.Globalization.Native.a | ||
${NATIVE_LIBS_LOCATION}/libSystem.IO.Compression.Native.a | ||
${NATIVE_LIBS_LOCATION}/libSystem.Native.a | ||
${NATIVE_LIBS_LOCATION}/libSystem.Net.Security.Native.a | ||
|
@@ -207,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} | ||
|
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) |
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 | ||
) | ||
|
Uh oh!
There was an error while loading. Please reload this page.