-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Build an apphost with hostfxr and hostpolicy linked in #35368
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4841c9a
hostfxr: Build most of hostfxr as a static library
lpereira 4c89d2c
hostpolicy: Build as a static library
lpereira d942cf2
corehost: Allow linking of hostfxr and hostpolicy with apphost
lpereira ea2b6d7
dotnet: Teach the muxer binary about hostfxr_iface
lpereira 0f8daea
apphost: Teach apphost about hostfxr_iface
lpereira 23f1bf9
Add exports for hostfxr and policy
VSadov 54506ae
Exports for unix
VSadov 87a4e1f
EXPORTS_LINKER_OPTION
VSadov a8b90ae
use generateversionscript.awk from ENG
VSadov b231629
Move fxr files out of static
VSadov 1efc302
Fixes for Linux
VSadov d381ab4
Fix for win-x86
VSadov 50d6cd6
move HEADERS next to SOURCES similarly to other files.
VSadov b9cd86a
PR feedback (simplifying hostpolicy_resolver::try_get_dir for static …
VSadov 433db23
Publish static_apphost to Microsoft.NETCore.App.Host
VSadov 8e91d89
bind to entry points without probing, when in a static host.
VSadov 444cd0a
Add a test case
swaroop-sridhar 8f3de42
Merge pull request #2 from swaroop-sridhar/staticHostTest
VSadov 818f5c6
renamed hostfxr_iface --> hostfxr_resolver_t
VSadov d95d0ca
renamed shared --> standalone
VSadov 67cf394
rename static_apphost --> singlefilehost
VSadov eb30f92
Signing exclusions for singlefilehost
VSadov 8669c80
switched StaticHost tst to a different asset (mostly a copy of Standa…
VSadov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/installer/corehost/cli/apphost/standalone/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Licensed to the .NET Foundation under one or more agreements. | ||
# The .NET Foundation licenses this file to you under the MIT license. | ||
# See the LICENSE file in the project root for more information. | ||
|
||
project(apphost) | ||
set(DOTNET_PROJECT_NAME "apphost") | ||
|
||
# Add RPATH to the apphost binary that allows using local copies of shared libraries | ||
# dotnet core depends on for special scenarios when system wide installation of such | ||
# dependencies is not possible for some reason. | ||
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way, | ||
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive. | ||
if (NOT CLR_CMAKE_TARGET_OSX) | ||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) | ||
set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") | ||
endif() | ||
|
||
set(SKIP_VERSIONING 1) | ||
|
||
include_directories(..) | ||
|
||
set(SOURCES | ||
../bundle_marker.cpp | ||
./hostfxr_resolver_t.cpp | ||
) | ||
|
||
set(HEADERS | ||
../bundle_marker.h | ||
../../../hostfxr_resolver_t.h | ||
) | ||
|
||
if(CLR_CMAKE_TARGET_WIN32) | ||
list(APPEND SOURCES | ||
../apphost.windows.cpp) | ||
|
||
list(APPEND HEADERS | ||
../apphost.windows.h) | ||
endif() | ||
|
||
include(../../exe.cmake) | ||
|
||
add_definitions(-DFEATURE_APPHOST=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" | ||
) | ||
endif() | ||
|
||
# Specify non-default Windows libs to be used for Arm/Arm64 builds | ||
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)) | ||
target_link_libraries(apphost Advapi32.lib shell32.lib) | ||
endif() |
61 changes: 61 additions & 0 deletions
61
src/installer/corehost/cli/apphost/standalone/hostfxr_resolver_t.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#include <assert.h> | ||
|
||
#include "pal.h" | ||
#include "fxr_resolver.h" | ||
#include "trace.h" | ||
#include "hostfxr_resolver_t.h" | ||
|
||
hostfxr_main_bundle_startupinfo_fn hostfxr_resolver_t::resolve_main_bundle_startupinfo() | ||
{ | ||
assert(m_hostfxr_dll != nullptr); | ||
return reinterpret_cast<hostfxr_main_bundle_startupinfo_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_bundle_startupinfo")); | ||
} | ||
|
||
hostfxr_set_error_writer_fn hostfxr_resolver_t::resolve_set_error_writer() | ||
{ | ||
assert(m_hostfxr_dll != nullptr); | ||
return reinterpret_cast<hostfxr_set_error_writer_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_set_error_writer")); | ||
} | ||
|
||
hostfxr_main_startupinfo_fn hostfxr_resolver_t::resolve_main_startupinfo() | ||
{ | ||
assert(m_hostfxr_dll != nullptr); | ||
return reinterpret_cast<hostfxr_main_startupinfo_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_startupinfo")); | ||
} | ||
|
||
hostfxr_main_fn hostfxr_resolver_t::resolve_main_v1() | ||
{ | ||
assert(m_hostfxr_dll != nullptr); | ||
return reinterpret_cast<hostfxr_main_fn>(pal::get_symbol(m_hostfxr_dll, "hostfxr_main")); | ||
} | ||
|
||
hostfxr_resolver_t::hostfxr_resolver_t(const pal::string_t& app_root) | ||
{ | ||
if (!fxr_resolver::try_get_path(app_root, &m_dotnet_root, &m_fxr_path)) | ||
{ | ||
m_status_code = StatusCode::CoreHostLibMissingFailure; | ||
} | ||
else if (pal::load_library(&m_fxr_path, &m_hostfxr_dll)) | ||
{ | ||
m_status_code = StatusCode::Success; | ||
} | ||
else | ||
{ | ||
trace::error(_X("The library %s was found, but loading it from %s failed"), LIBFXR_NAME, m_fxr_path.c_str()); | ||
trace::error(_X(" - Installing .NET prerequisites might help resolve this problem.")); | ||
trace::error(_X(" %s"), DOTNET_CORE_INSTALL_PREREQUISITES_URL); | ||
m_status_code = StatusCode::CoreHostLibLoadFailure; | ||
} | ||
} | ||
|
||
hostfxr_resolver_t::~hostfxr_resolver_t() | ||
{ | ||
if (m_hostfxr_dll != nullptr) | ||
{ | ||
pal::unload_library(m_hostfxr_dll); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Licensed to the .NET Foundation under one or more agreements. | ||
# The .NET Foundation licenses this file to you under the MIT license. | ||
# See the LICENSE file in the project root for more information. | ||
|
||
project(singlefilehost) | ||
set(DOTNET_PROJECT_NAME "singlefilehost") | ||
|
||
# Add RPATH to the apphost binary that allows using local copies of shared libraries | ||
# dotnet core depends on for special scenarios when system wide installation of such | ||
# dependencies is not possible for some reason. | ||
# This cannot be enabled for MacOS (Darwin) since its RPATH works in a different way, | ||
# doesn't apply to libraries loaded via dlopen and most importantly, it is not transitive. | ||
if (NOT CLR_CMAKE_TARGET_OSX) | ||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) | ||
set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") | ||
endif() | ||
|
||
set(SKIP_VERSIONING 1) | ||
|
||
include_directories(..) | ||
include_directories(../../json) | ||
|
||
set(SOURCES | ||
../bundle_marker.cpp | ||
./hostfxr_resolver_t.cpp | ||
./hostpolicy_resolver.cpp | ||
) | ||
|
||
set(HEADERS | ||
../bundle_marker.h | ||
../../../hostfxr_resolver_t.h | ||
) | ||
|
||
if(CLR_CMAKE_TARGET_WIN32) | ||
list(APPEND SOURCES | ||
../apphost.windows.cpp) | ||
|
||
list(APPEND HEADERS | ||
../apphost.windows.h) | ||
endif() | ||
|
||
include(../../exe.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" | ||
) | ||
endif() | ||
|
||
# Specify non-default Windows libs to be used for Arm/Arm64 builds | ||
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)) | ||
target_link_libraries(singlefilehost Advapi32.lib shell32.lib) | ||
endif() | ||
|
||
target_link_libraries(singlefilehost | ||
libhostfxr_static | ||
libhostpolicy_static | ||
libhostcommon | ||
) |
63 changes: 63 additions & 0 deletions
63
src/installer/corehost/cli/apphost/static/hostfxr_resolver_t.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#include <assert.h> | ||
#include "trace.h" | ||
#include "hostfxr.h" | ||
#include "hostfxr_resolver_t.h" | ||
|
||
extern "C" | ||
{ | ||
int HOSTFXR_CALLTYPE hostfxr_main_bundle_startupinfo(const int argc, const pal::char_t* argv[], const pal::char_t* host_path, const pal::char_t* dotnet_root, const pal::char_t* app_path, int64_t bundle_header_offset); | ||
int HOSTFXR_CALLTYPE hostfxr_main_startupinfo(const int argc, const pal::char_t* argv[], const pal::char_t* host_path, const pal::char_t* dotnet_root, const pal::char_t* app_path); | ||
int HOSTFXR_CALLTYPE hostfxr_main(const int argc, const pal::char_t* argv[]); | ||
hostfxr_error_writer_fn HOSTFXR_CALLTYPE hostfxr_set_error_writer(hostfxr_error_writer_fn error_writer); | ||
} | ||
|
||
hostfxr_main_bundle_startupinfo_fn hostfxr_resolver_t::resolve_main_bundle_startupinfo() | ||
{ | ||
assert(m_hostfxr_dll == nullptr); | ||
return hostfxr_main_bundle_startupinfo; | ||
} | ||
|
||
hostfxr_set_error_writer_fn hostfxr_resolver_t::resolve_set_error_writer() | ||
{ | ||
assert(m_hostfxr_dll == nullptr); | ||
return hostfxr_set_error_writer; | ||
} | ||
|
||
hostfxr_main_startupinfo_fn hostfxr_resolver_t::resolve_main_startupinfo() | ||
{ | ||
assert(m_hostfxr_dll == nullptr); | ||
return hostfxr_main_startupinfo; | ||
} | ||
|
||
hostfxr_main_fn hostfxr_resolver_t::resolve_main_v1() | ||
{ | ||
assert(m_hostfxr_dll == nullptr); | ||
assert(!"This function should not be called in a static host"); | ||
return nullptr; | ||
} | ||
|
||
hostfxr_resolver_t::hostfxr_resolver_t(const pal::string_t& app_root) | ||
{ | ||
if (app_root.length() == 0) | ||
{ | ||
trace::info(_X("Application root path is empty. This shouldn't happen")); | ||
m_status_code = StatusCode::CoreHostLibMissingFailure; | ||
} | ||
else | ||
{ | ||
trace::info(_X("Using internal fxr")); | ||
|
||
m_dotnet_root.assign(app_root); | ||
m_fxr_path.assign(app_root); | ||
|
||
m_status_code = StatusCode::Success; | ||
} | ||
} | ||
|
||
hostfxr_resolver_t::~hostfxr_resolver_t() | ||
{ | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure "static" and "shared" are the best names here.
I think Leandro chose these because of static and shared libraries.
But "shared" is a bit confusing because (a) it seems to represent code shared between different kinds of builds, and (b) apphost is not a shared library.
Please consider renaming them to more representative names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like 'shared', but did not have a lot of good alternatives. It is an opposite of "static" and "super" - could it be "standalone"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I think "standalone" is a good option. "linked vs standalone" or "static vs standalone" are good I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make it static vs. standalone. (static seems good enough)