Skip to content
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 #36230

Merged
merged 23 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3c1ca07
hostfxr: Build most of hostfxr as a static library
lpereira Apr 16, 2020
3ec490b
hostpolicy: Build as a static library
lpereira Apr 16, 2020
4af5894
corehost: Allow linking of hostfxr and hostpolicy with apphost
lpereira Apr 16, 2020
08d768d
dotnet: Teach the muxer binary about hostfxr_iface
lpereira Apr 16, 2020
d83c650
apphost: Teach apphost about hostfxr_iface
lpereira Apr 16, 2020
9b4c222
Add exports for hostfxr and policy
VSadov Apr 23, 2020
495c67c
Exports for unix
VSadov Apr 24, 2020
015794b
EXPORTS_LINKER_OPTION
VSadov Apr 24, 2020
4ad7fca
use generateversionscript.awk from ENG
VSadov Apr 24, 2020
44c9231
Move fxr files out of static
VSadov Apr 24, 2020
7afcf52
Fixes for Linux
VSadov Apr 27, 2020
b38f6a7
Fix for win-x86
VSadov Apr 27, 2020
7be0385
move HEADERS next to SOURCES similarly to other files.
VSadov Apr 27, 2020
9e8dd3c
PR feedback (simplifying hostpolicy_resolver::try_get_dir for static …
VSadov Apr 27, 2020
2b72e45
Publish static_apphost to Microsoft.NETCore.App.Host
VSadov Apr 27, 2020
09b7e47
bind to entry points without probing, when in a static host.
VSadov May 1, 2020
0b488e6
Add a test case
swaroop-sridhar May 4, 2020
0f1c4c3
renamed hostfxr_iface --> hostfxr_resolver_t
VSadov May 5, 2020
efe135d
renamed shared --> standalone
VSadov May 5, 2020
1478501
rename static_apphost --> singlefilehost
VSadov May 5, 2020
03a63ba
Signing exclusions for singlefilehost
VSadov May 5, 2020
ba0e584
switched StaticHost tst to a different asset (mostly a copy of Standa…
VSadov May 5, 2020
f71f944
get_method_module_path
VSadov May 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/SignCheckExclusionsFile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
;; and SCD apps. If they are signed, the file that the SDK produces has an invalid signature and
;; can't be signed again. More info at https://github.com/dotnet/core-setup/pull/7549.
*apphost.exe;;Template, https://github.com/dotnet/core-setup/pull/7549
*singlefilehost.exe;;Template, https://github.com/dotnet/core-setup/pull/7549
*comhost.dll;;Template, https://github.com/dotnet/core-setup/pull/7549
*apphosttemplateapphostexe.exe;;Template, https://github.com/dotnet/core-setup/pull/7549
*comhosttemplatecomhostdll.dll;;Template, https://github.com/dotnet/core-setup/pull/7549
Expand Down
2 changes: 1 addition & 1 deletion eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<BundleInstallerExeArtifact Include="$(ArtifactsPackagesDir)**/*.exe" />

<!-- apphost and comhost template files are not signed, by design. -->
<FileSignInfo Include="apphost.exe;comhost.dll" CertificateName="None" />
<FileSignInfo Include="apphost.exe;singlefilehost.exe;comhost.dll" CertificateName="None" />
</ItemGroup>

<ItemGroup Condition="'$(CrossTargetComponentFolder)' != ''">
Expand Down
8 changes: 4 additions & 4 deletions eng/native/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ function(generate_exports_file)

add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${AWK} -f ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} ${INPUT_LIST} >${outputFilename}
DEPENDS ${INPUT_LIST} ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT}
COMMAND ${AWK} -f ${CLR_ENG_NATIVE_DIR}/${AWK_SCRIPT} ${INPUT_LIST} >${outputFilename}
DEPENDS ${INPUT_LIST} ${CLR_ENG_NATIVE_DIR}/${AWK_SCRIPT}
COMMENT "Generating exports file ${outputFilename}"
)
set_source_files_properties(${outputFilename}
Expand All @@ -196,8 +196,8 @@ function(generate_exports_file_prefix inputFilename outputFilename prefix)

add_custom_command(
OUTPUT ${outputFilename}
COMMAND ${AWK} -f ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} ${AWK_VARS} ${inputFilename} >${outputFilename}
DEPENDS ${inputFilename} ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT}
COMMAND ${AWK} -f ${CLR_ENG_NATIVE_DIR}/${AWK_SCRIPT} ${AWK_VARS} ${inputFilename} >${outputFilename}
DEPENDS ${inputFilename} ${CLR_ENG_NATIVE_DIR}/${AWK_SCRIPT}
COMMENT "Generating exports file ${outputFilename}"
)
set_source_files_properties(${outputFilename}
Expand Down
4 changes: 2 additions & 2 deletions src/installer/corehost/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
add_subdirectory(hostcommon)
add_subdirectory(apphost)
add_subdirectory(dotnet)
add_subdirectory(fxr)
add_subdirectory(hostpolicy)
add_subdirectory(nethost)
add_subdirectory(test_fx_ver)
add_subdirectory(fxr)
add_subdirectory(hostpolicy)

add_subdirectory(test)

Expand Down
48 changes: 2 additions & 46 deletions src/installer/corehost/cli/apphost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,5 @@
# 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)

set(SOURCES
./bundle_marker.cpp
)

set(HEADERS
./bundle_marker.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()
add_subdirectory(static)
add_subdirectory(standalone)
54 changes: 54 additions & 0 deletions src/installer/corehost/cli/apphost/standalone/CMakeLists.txt
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()
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);
}
}
63 changes: 63 additions & 0 deletions src/installer/corehost/cli/apphost/static/CMakeLists.txt
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 src/installer/corehost/cli/apphost/static/hostfxr_resolver_t.cpp
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()
{
}
Loading