From 4841c9a7d87b604ca1ce8224b7476bb624fdab01 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 16 Apr 2020 01:08:50 +0000 Subject: [PATCH 01/22] hostfxr: Build most of hostfxr as a static library This is part of the work to create an apphost that bundles both hostfxr and hostpolicy. The main distinction between the static and shared versions of hostfxr is that the static version contains a hostpolicy resolver that references the hostpolicy symbols directly rather than loading them from a DLL. --- src/installer/corehost/cli/CMakeLists.txt | 4 +- .../corehost/cli/comhost/CMakeLists.txt | 1 + src/installer/corehost/cli/exe.cmake | 1 + src/installer/corehost/cli/fxr/CMakeLists.txt | 45 +---------- .../corehost/cli/fxr/shared/CMakeLists.txt | 33 ++++++++ .../fxr/{ => shared}/hostpolicy_resolver.cpp | 0 .../corehost/cli/fxr/static/CMakeLists.txt | 44 ++++++++++ .../cli/fxr/{ => static}/command_line.cpp | 0 .../cli/fxr/{ => static}/command_line.h | 0 .../cli/fxr/{ => static}/corehost_init.cpp | 0 .../cli/fxr/{ => static}/corehost_init.h | 0 .../cli/fxr/{ => static}/framework_info.cpp | 0 .../cli/fxr/{ => static}/framework_info.h | 0 .../cli/fxr/{ => static}/fx_muxer.cpp | 2 +- .../corehost/cli/fxr/{ => static}/fx_muxer.h | 0 .../cli/fxr/{ => static}/fx_resolver.cpp | 0 .../cli/fxr/{ => static}/fx_resolver.h | 0 .../fxr/{ => static}/fx_resolver.messages.cpp | 0 .../corehost/cli/fxr/{ => static}/fx_ver.cpp | 0 .../corehost/cli/fxr/{ => static}/fx_ver.h | 0 .../cli/fxr/{ => static}/host_context.cpp | 0 .../cli/fxr/{ => static}/host_context.h | 0 .../corehost/cli/fxr/{ => static}/hostfxr.cpp | 0 .../cli/fxr/static/hostpolicy_resolver.cpp | 80 +++++++++++++++++++ .../fxr/{ => static}/hostpolicy_resolver.h | 0 .../cli/fxr/{ => static}/sdk_info.cpp | 0 .../corehost/cli/fxr/{ => static}/sdk_info.h | 0 .../cli/fxr/{ => static}/sdk_resolver.cpp | 0 .../cli/fxr/{ => static}/sdk_resolver.h | 0 .../corehost/cli/hostcommon/CMakeLists.txt | 5 +- .../corehost/cli/hostpolicy/CMakeLists.txt | 1 + .../corehost/cli/ijwhost/CMakeLists.txt | 1 + .../corehost/cli/nethost/CMakeLists.txt | 1 + .../corehost/cli/test_fx_ver/CMakeLists.txt | 1 + .../corehost/cli/winrthost/CMakeLists.txt | 1 + 35 files changed, 172 insertions(+), 48 deletions(-) create mode 100644 src/installer/corehost/cli/fxr/shared/CMakeLists.txt rename src/installer/corehost/cli/fxr/{ => shared}/hostpolicy_resolver.cpp (100%) create mode 100644 src/installer/corehost/cli/fxr/static/CMakeLists.txt rename src/installer/corehost/cli/fxr/{ => static}/command_line.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/command_line.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/corehost_init.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/corehost_init.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/framework_info.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/framework_info.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/fx_muxer.cpp (99%) rename src/installer/corehost/cli/fxr/{ => static}/fx_muxer.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/fx_resolver.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/fx_resolver.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/fx_resolver.messages.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/fx_ver.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/fx_ver.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/host_context.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/host_context.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/hostfxr.cpp (100%) create mode 100644 src/installer/corehost/cli/fxr/static/hostpolicy_resolver.cpp rename src/installer/corehost/cli/fxr/{ => static}/hostpolicy_resolver.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/sdk_info.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/sdk_info.h (100%) rename src/installer/corehost/cli/fxr/{ => static}/sdk_resolver.cpp (100%) rename src/installer/corehost/cli/fxr/{ => static}/sdk_resolver.h (100%) diff --git a/src/installer/corehost/cli/CMakeLists.txt b/src/installer/corehost/cli/CMakeLists.txt index 15ce0fa117721..3c1bdb1f2f0ec 100644 --- a/src/installer/corehost/cli/CMakeLists.txt +++ b/src/installer/corehost/cli/CMakeLists.txt @@ -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) diff --git a/src/installer/corehost/cli/comhost/CMakeLists.txt b/src/installer/corehost/cli/comhost/CMakeLists.txt index b0f4759ffc682..de8094a194f93 100644 --- a/src/installer/corehost/cli/comhost/CMakeLists.txt +++ b/src/installer/corehost/cli/comhost/CMakeLists.txt @@ -8,6 +8,7 @@ set(DOTNET_PROJECT_NAME "comhost") # Include directories include_directories(../fxr) +include_directories(../fxr/static) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake index c9295d5c65f77..481d0fdb040af 100644 --- a/src/installer/corehost/cli/exe.cmake +++ b/src/installer/corehost/cli/exe.cmake @@ -12,6 +12,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) # Include directories include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr) +include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr/static) # CMake does not recommend using globbing since it messes with the freshness checks list(APPEND SOURCES diff --git a/src/installer/corehost/cli/fxr/CMakeLists.txt b/src/installer/corehost/cli/fxr/CMakeLists.txt index 216ecbf076bb7..886c9c33d996b 100644 --- a/src/installer/corehost/cli/fxr/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/CMakeLists.txt @@ -2,46 +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(hostfxr) - -set(DOTNET_PROJECT_NAME "hostfxr") - -# Include directories -include_directories(../json) - -# CMake does not recommend using globbing since it messes with the freshness checks -set(SOURCES - ./command_line.cpp - ./corehost_init.cpp - ./hostfxr.cpp - ./fx_muxer.cpp - ./fx_resolver.cpp - ./fx_resolver.messages.cpp - ./framework_info.cpp - ./host_context.cpp - ./hostpolicy_resolver.cpp - ./sdk_info.cpp - ./sdk_resolver.cpp -) - -set(HEADERS - ../corehost_context_contract.h - ../hostpolicy.h - ../fx_definition.h - ../fx_reference.h - ../roll_fwd_on_no_candidate_fx_option.h - ./command_line.h - ./corehost_init.h - ./fx_muxer.h - ./fx_resolver.h - ./framework_info.h - ./host_context.h - ./hostpolicy_resolver.h - ./sdk_info.h - ./sdk_resolver.h -) - -include(../lib.cmake) - -install_with_stripped_symbols(hostfxr TARGETS corehost) -target_link_libraries(hostfxr libhostcommon) +add_subdirectory(static) +add_subdirectory(shared) diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt new file mode 100644 index 0000000000000..d8d2bce4fe8c9 --- /dev/null +++ b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt @@ -0,0 +1,33 @@ +# 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(hostfxr) + +set(DOTNET_PROJECT_NAME "hostfxr") + +# Include directories +include_directories(../../json) +include_directories(../static) + +# CMake does not recommend using globbing since it messes with the freshness checks +set(SOURCES + ./hostpolicy_resolver.cpp +) + +set(HEADERS + ../static/command_line.h + ../static/corehost_init.h + ../static/fx_muxer.h + ../static/fx_resolver.h + ../static/framework_info.h + ../static/host_context.h + ../static/hostpolicy_resolver.h + ../static/sdk_info.h + ../static/sdk_resolver.h +) + +include(../../lib.cmake) + +install_with_stripped_symbols(hostfxr TARGETS corehost) +target_link_libraries(hostfxr libhostcommon libhostfxr_static) diff --git a/src/installer/corehost/cli/fxr/hostpolicy_resolver.cpp b/src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/hostpolicy_resolver.cpp rename to src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp diff --git a/src/installer/corehost/cli/fxr/static/CMakeLists.txt b/src/installer/corehost/cli/fxr/static/CMakeLists.txt new file mode 100644 index 0000000000000..39f7d1a5a2de9 --- /dev/null +++ b/src/installer/corehost/cli/fxr/static/CMakeLists.txt @@ -0,0 +1,44 @@ +# 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(hostfxr_static) + +set(DOTNET_PROJECT_NAME "hostfxr_static") + +# Include directories +include_directories(../../json) + +# CMake does not recommend using globbing since it messes with the freshness checks +set(SOURCES + ./command_line.cpp + ./corehost_init.cpp + ./hostfxr.cpp + ./fx_muxer.cpp + ./fx_resolver.cpp + ./fx_resolver.messages.cpp + ./framework_info.cpp + ./host_context.cpp + ./sdk_info.cpp + ./sdk_resolver.cpp + ./hostpolicy_resolver.cpp +) + +set(HEADERS + ../../corehost_context_contract.h + ../../hostpolicy.h + ../../fx_definition.h + ../../fx_reference.h + ../../roll_fwd_on_no_candidate_fx_option.h + ./command_line.h + ./corehost_init.h + ./fx_muxer.h + ./fx_resolver.h + ./framework_info.h + ./host_context.h + ./sdk_info.h + ./sdk_resolver.h +) + +set(SKIP_VERSIONING 1) +include(../../lib_static.cmake) diff --git a/src/installer/corehost/cli/fxr/command_line.cpp b/src/installer/corehost/cli/fxr/static/command_line.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/command_line.cpp rename to src/installer/corehost/cli/fxr/static/command_line.cpp diff --git a/src/installer/corehost/cli/fxr/command_line.h b/src/installer/corehost/cli/fxr/static/command_line.h similarity index 100% rename from src/installer/corehost/cli/fxr/command_line.h rename to src/installer/corehost/cli/fxr/static/command_line.h diff --git a/src/installer/corehost/cli/fxr/corehost_init.cpp b/src/installer/corehost/cli/fxr/static/corehost_init.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/corehost_init.cpp rename to src/installer/corehost/cli/fxr/static/corehost_init.cpp diff --git a/src/installer/corehost/cli/fxr/corehost_init.h b/src/installer/corehost/cli/fxr/static/corehost_init.h similarity index 100% rename from src/installer/corehost/cli/fxr/corehost_init.h rename to src/installer/corehost/cli/fxr/static/corehost_init.h diff --git a/src/installer/corehost/cli/fxr/framework_info.cpp b/src/installer/corehost/cli/fxr/static/framework_info.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/framework_info.cpp rename to src/installer/corehost/cli/fxr/static/framework_info.cpp diff --git a/src/installer/corehost/cli/fxr/framework_info.h b/src/installer/corehost/cli/fxr/static/framework_info.h similarity index 100% rename from src/installer/corehost/cli/fxr/framework_info.h rename to src/installer/corehost/cli/fxr/static/framework_info.h diff --git a/src/installer/corehost/cli/fxr/fx_muxer.cpp b/src/installer/corehost/cli/fxr/static/fx_muxer.cpp similarity index 99% rename from src/installer/corehost/cli/fxr/fx_muxer.cpp rename to src/installer/corehost/cli/fxr/static/fx_muxer.cpp index 31c8c17797807..0357513f11407 100644 --- a/src/installer/corehost/cli/fxr/fx_muxer.cpp +++ b/src/installer/corehost/cli/fxr/static/fx_muxer.cpp @@ -471,7 +471,7 @@ namespace if (!hostpolicy_resolver::try_get_dir(mode, host_info.dotnet_root, fx_definitions, app_candidate, deps_file, probe_realpaths, &hostpolicy_dir)) { - return CoreHostLibMissingFailure; + return StatusCode::CoreHostLibMissingFailure; } init.reset(new corehost_init_t(host_command, host_info, deps_file, additional_deps_serialized, probe_realpaths, mode, fx_definitions)); diff --git a/src/installer/corehost/cli/fxr/fx_muxer.h b/src/installer/corehost/cli/fxr/static/fx_muxer.h similarity index 100% rename from src/installer/corehost/cli/fxr/fx_muxer.h rename to src/installer/corehost/cli/fxr/static/fx_muxer.h diff --git a/src/installer/corehost/cli/fxr/fx_resolver.cpp b/src/installer/corehost/cli/fxr/static/fx_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/fx_resolver.cpp rename to src/installer/corehost/cli/fxr/static/fx_resolver.cpp diff --git a/src/installer/corehost/cli/fxr/fx_resolver.h b/src/installer/corehost/cli/fxr/static/fx_resolver.h similarity index 100% rename from src/installer/corehost/cli/fxr/fx_resolver.h rename to src/installer/corehost/cli/fxr/static/fx_resolver.h diff --git a/src/installer/corehost/cli/fxr/fx_resolver.messages.cpp b/src/installer/corehost/cli/fxr/static/fx_resolver.messages.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/fx_resolver.messages.cpp rename to src/installer/corehost/cli/fxr/static/fx_resolver.messages.cpp diff --git a/src/installer/corehost/cli/fxr/fx_ver.cpp b/src/installer/corehost/cli/fxr/static/fx_ver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/fx_ver.cpp rename to src/installer/corehost/cli/fxr/static/fx_ver.cpp diff --git a/src/installer/corehost/cli/fxr/fx_ver.h b/src/installer/corehost/cli/fxr/static/fx_ver.h similarity index 100% rename from src/installer/corehost/cli/fxr/fx_ver.h rename to src/installer/corehost/cli/fxr/static/fx_ver.h diff --git a/src/installer/corehost/cli/fxr/host_context.cpp b/src/installer/corehost/cli/fxr/static/host_context.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/host_context.cpp rename to src/installer/corehost/cli/fxr/static/host_context.cpp diff --git a/src/installer/corehost/cli/fxr/host_context.h b/src/installer/corehost/cli/fxr/static/host_context.h similarity index 100% rename from src/installer/corehost/cli/fxr/host_context.h rename to src/installer/corehost/cli/fxr/static/host_context.h diff --git a/src/installer/corehost/cli/fxr/hostfxr.cpp b/src/installer/corehost/cli/fxr/static/hostfxr.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/hostfxr.cpp rename to src/installer/corehost/cli/fxr/static/hostfxr.cpp diff --git a/src/installer/corehost/cli/fxr/static/hostpolicy_resolver.cpp b/src/installer/corehost/cli/fxr/static/hostpolicy_resolver.cpp new file mode 100644 index 0000000000000..8bf2371988ba1 --- /dev/null +++ b/src/installer/corehost/cli/fxr/static/hostpolicy_resolver.cpp @@ -0,0 +1,80 @@ +// 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 +#include +#include +#include "hostpolicy_resolver.h" +#include +#include + +extern "C" +{ + int corehost_load(const host_interface_t* init); + int corehost_unload(); + corehost_error_writer_fn corehost_set_error_writer(corehost_error_writer_fn error_writer); + int corehost_initialize(const corehost_initialize_request_t *init_request, int32_t options, /*out*/ corehost_context_contract *context_contract); +} + +int hostpolicy_resolver::load( + const pal::string_t& lib_dir, + pal::dll_t* dll, + hostpolicy_contract_t &hostpolicy_contract) +{ + static hostpolicy_contract_t contract; + + trace::info(_X("Using internal hostpolicy")); + + contract.load = corehost_load; + contract.unload = corehost_unload; + contract.set_error_writer = corehost_set_error_writer; + contract.initialize = corehost_initialize; + + hostpolicy_contract = contract; + *dll = nullptr; + + return StatusCode::Success; +} + +bool hostpolicy_resolver::try_get_dir( + host_mode_t mode, + const pal::string_t& dotnet_root, + const fx_definition_vector_t& fx_definitions, + const pal::string_t& app_candidate, + const pal::string_t& specified_deps_file, + const std::vector& probe_realpaths, + pal::string_t* impl_dir) +{ + // Get the expected directory that would contain hostpolicy. + pal::string_t expected; + if (get_app(fx_definitions).get_runtime_config().get_is_framework_dependent()) + { + // The hostpolicy is required to be in the root framework's location + expected.assign(get_root_framework(fx_definitions).get_dir()); + assert(pal::directory_exists(expected)); + } + else + { + // Native apps can be activated by muxer, native exe host or "corehost" + // 1. When activated with dotnet.exe or corehost.exe, check for hostpolicy in the deps dir or + // app dir. + // 2. When activated with native exe, the standalone host, check own directory. + assert(mode != host_mode_t::invalid); + switch (mode) + { + case host_mode_t::apphost: + case host_mode_t::libhost: + expected = dotnet_root; + break; + + default: + expected = get_directory(specified_deps_file.empty() ? app_candidate : specified_deps_file); + break; + } + } + + // Assume the internal hostpolicy is in the expected location. + impl_dir->assign(expected); + return true; +} diff --git a/src/installer/corehost/cli/fxr/hostpolicy_resolver.h b/src/installer/corehost/cli/fxr/static/hostpolicy_resolver.h similarity index 100% rename from src/installer/corehost/cli/fxr/hostpolicy_resolver.h rename to src/installer/corehost/cli/fxr/static/hostpolicy_resolver.h diff --git a/src/installer/corehost/cli/fxr/sdk_info.cpp b/src/installer/corehost/cli/fxr/static/sdk_info.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/sdk_info.cpp rename to src/installer/corehost/cli/fxr/static/sdk_info.cpp diff --git a/src/installer/corehost/cli/fxr/sdk_info.h b/src/installer/corehost/cli/fxr/static/sdk_info.h similarity index 100% rename from src/installer/corehost/cli/fxr/sdk_info.h rename to src/installer/corehost/cli/fxr/static/sdk_info.h diff --git a/src/installer/corehost/cli/fxr/sdk_resolver.cpp b/src/installer/corehost/cli/fxr/static/sdk_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/sdk_resolver.cpp rename to src/installer/corehost/cli/fxr/static/sdk_resolver.cpp diff --git a/src/installer/corehost/cli/fxr/sdk_resolver.h b/src/installer/corehost/cli/fxr/static/sdk_resolver.h similarity index 100% rename from src/installer/corehost/cli/fxr/sdk_resolver.h rename to src/installer/corehost/cli/fxr/static/sdk_resolver.h diff --git a/src/installer/corehost/cli/hostcommon/CMakeLists.txt b/src/installer/corehost/cli/hostcommon/CMakeLists.txt index 8ad0c8d09f47c..2bac08df03e7c 100644 --- a/src/installer/corehost/cli/hostcommon/CMakeLists.txt +++ b/src/installer/corehost/cli/hostcommon/CMakeLists.txt @@ -8,6 +8,7 @@ set(DOTNET_PROJECT_NAME "hostcommon") # Include directories include_directories(../fxr) +include_directories(../fxr/static) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks @@ -19,7 +20,7 @@ set(SOURCES ../roll_forward_option.cpp ../fx_definition.cpp ../fx_reference.cpp - ../fxr/fx_ver.cpp + ../fxr/static/fx_ver.cpp ../version.cpp ../version_compatibility_range.cpp ../runtime_config.cpp @@ -36,7 +37,7 @@ set(HEADERS ../roll_forward_option.h ../fx_definition.h ../fx_reference.h - ../fxr/fx_ver.h + ../fxr/static/fx_ver.h ../version.h ../version_compatibility_range.h ../runtime_config.h diff --git a/src/installer/corehost/cli/hostpolicy/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/CMakeLists.txt index ca2c78fa27951..bc22953a2de11 100644 --- a/src/installer/corehost/cli/hostpolicy/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/CMakeLists.txt @@ -8,6 +8,7 @@ set(DOTNET_PROJECT_NAME "hostpolicy") # Include directories include_directories(../fxr) +include_directories(../fxr_base) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks diff --git a/src/installer/corehost/cli/ijwhost/CMakeLists.txt b/src/installer/corehost/cli/ijwhost/CMakeLists.txt index 46387c0f29299..d19b479785248 100644 --- a/src/installer/corehost/cli/ijwhost/CMakeLists.txt +++ b/src/installer/corehost/cli/ijwhost/CMakeLists.txt @@ -8,6 +8,7 @@ set(DOTNET_PROJECT_NAME "ijwhost") # Include directories include_directories(../fxr) +include_directories(../fxr/static) include_directories(${ARCH_SOURCES_DIR}) # CMake does not recommend using globbing since it messes with the freshness checks diff --git a/src/installer/corehost/cli/nethost/CMakeLists.txt b/src/installer/corehost/cli/nethost/CMakeLists.txt index 864129970512c..1e2688ea2aec0 100644 --- a/src/installer/corehost/cli/nethost/CMakeLists.txt +++ b/src/installer/corehost/cli/nethost/CMakeLists.txt @@ -8,6 +8,7 @@ set(DOTNET_PROJECT_NAME "nethost") # Include directories include_directories(../fxr) +include_directories(../fxr/static) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES diff --git a/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt b/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt index d68eea66656fe..5a78901dde848 100644 --- a/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt +++ b/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt @@ -8,6 +8,7 @@ set(EXE_NAME "test_fx_ver") include_directories(../../) include_directories(../) include_directories(../fxr) +include_directories(../fxr/static) include_directories(../hostmisc) set(SOURCES diff --git a/src/installer/corehost/cli/winrthost/CMakeLists.txt b/src/installer/corehost/cli/winrthost/CMakeLists.txt index 22b32e998771a..39f1ccd9633ca 100644 --- a/src/installer/corehost/cli/winrthost/CMakeLists.txt +++ b/src/installer/corehost/cli/winrthost/CMakeLists.txt @@ -7,6 +7,7 @@ set(DOTNET_PROJECT_NAME "winrthost") # Include directories include_directories(../fxr) +include_directories(../fxr/static) # CMake does not recommend using globbing since it messes with the freshness checks From 4c89d2c45c6aa30dd0b394df8b9a5b37e19353b3 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 16 Apr 2020 01:09:41 +0000 Subject: [PATCH 02/22] hostpolicy: Build as a static library This change is part of the work to enable an apphost that bundles both hostfxr and hostpolicy. There's no distinction between hostpolicy that's built as a shared library and as a static library: the shared library is built by linking an empty object file with the static library. --- .../corehost/cli/hostpolicy/CMakeLists.txt | 47 +----------------- .../cli/hostpolicy/shared/CMakeLists.txt | 27 +++++++++++ .../cli/hostpolicy/static/CMakeLists.txt | 48 +++++++++++++++++++ .../cli/hostpolicy/{ => static}/args.cpp | 0 .../cli/hostpolicy/{ => static}/args.h | 0 .../hostpolicy/{ => static}/breadcrumbs.cpp | 0 .../cli/hostpolicy/{ => static}/breadcrumbs.h | 0 .../cli/hostpolicy/{ => static}/coreclr.cpp | 0 .../cli/hostpolicy/{ => static}/coreclr.h | 0 .../hostpolicy/{ => static}/deps_resolver.cpp | 0 .../hostpolicy/{ => static}/deps_resolver.h | 0 .../hostpolicy/{ => static}/hostpolicy.cpp | 0 .../{ => static}/hostpolicy_context.cpp | 0 .../{ => static}/hostpolicy_context.h | 0 .../{ => static}/hostpolicy_init.cpp | 0 .../hostpolicy/{ => static}/hostpolicy_init.h | 0 src/installer/corehost/cli/lib_static.cmake | 6 ++- 17 files changed, 82 insertions(+), 46 deletions(-) create mode 100644 src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt create mode 100644 src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt rename src/installer/corehost/cli/hostpolicy/{ => static}/args.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/args.h (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/breadcrumbs.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/breadcrumbs.h (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/coreclr.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/coreclr.h (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/deps_resolver.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/deps_resolver.h (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/hostpolicy.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/hostpolicy_context.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/hostpolicy_context.h (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/hostpolicy_init.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{ => static}/hostpolicy_init.h (100%) diff --git a/src/installer/corehost/cli/hostpolicy/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/CMakeLists.txt index bc22953a2de11..2070410114828 100644 --- a/src/installer/corehost/cli/hostpolicy/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/CMakeLists.txt @@ -2,48 +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(hostpolicy) - -set(DOTNET_PROJECT_NAME "hostpolicy") - -# Include directories -include_directories(../fxr) -include_directories(../fxr_base) -include_directories(../json) - -# CMake does not recommend using globbing since it messes with the freshness checks -set(SOURCES - ./args.cpp - ./breadcrumbs.cpp - ./coreclr.cpp - ./deps_resolver.cpp - ./hostpolicy_context.cpp - ./hostpolicy.cpp - ./hostpolicy_init.cpp - ../bundle/dir_utils.cpp - ../bundle/extractor.cpp - ../bundle/file_entry.cpp - ../bundle/manifest.cpp - ../bundle/runner.cpp -) - -set(HEADERS - ./args.h - ./breadcrumbs.h - ./coreclr.h - ../corehost_context_contract.h - ./deps_resolver.h - ./hostpolicy_context.h - ../hostpolicy.h - ./hostpolicy_init.h - ../bundle/dir_utils.h - ../bundle/extractor.h - ../bundle/file_entry.h - ../bundle/manifest.h - ../bundle/runner.h -) - -include(../lib.cmake) - -install_with_stripped_symbols(hostpolicy TARGETS corehost) -target_link_libraries(hostpolicy libhostcommon) +add_subdirectory(static) +add_subdirectory(shared) \ No newline at end of file diff --git a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt new file mode 100644 index 0000000000000..a2ae28e7a1703 --- /dev/null +++ b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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(hostpolicy) + +set(DOTNET_PROJECT_NAME "hostpolicy") + +# CMake does not recommend using globbing since it messes with the freshness checks + +# Can't call add_library() without source files. Create an empty .c file, +# then link with the static library just recently built. +if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/empty.cpp") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/empty.cpp" "") +endif () + +set(SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp +) + +set(HEADERS +) + +include(../../lib.cmake) + +install_with_stripped_symbols(hostpolicy TARGETS corehost) +target_link_libraries(hostpolicy libhostcommon libhostpolicy_static) diff --git a/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt new file mode 100644 index 0000000000000..f683ce7319d6b --- /dev/null +++ b/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt @@ -0,0 +1,48 @@ +# 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(hostpolicy_static) + +set(DOTNET_PROJECT_NAME "hostpolicy_static") + +# Include directories +include_directories(../../fxr/shared) +include_directories(../../fxr/static) +include_directories(../../json) + +# CMake does not recommend using globbing since it messes with the freshness checks +set(SOURCES + ./args.cpp + ./breadcrumbs.cpp + ./coreclr.cpp + ./deps_resolver.cpp + ./hostpolicy_context.cpp + ./hostpolicy.cpp + ./hostpolicy_init.cpp + ../../bundle/dir_utils.cpp + ../../bundle/extractor.cpp + ../../bundle/file_entry.cpp + ../../bundle/manifest.cpp + ../../bundle/runner.cpp +) + +set(HEADERS + ./args.h + ./breadcrumbs.h + ./coreclr.h + ../../corehost_context_contract.h + ./deps_resolver.h + ./hostpolicy_context.h + ../../hostpolicy.h + ./hostpolicy_init.h + ../../bundle/dir_utils.h + ../../bundle/extractor.h + ../../bundle/file_entry.h + ../../bundle/manifest.h + ../../bundle/runner.h +) + +set(SKIP_VERSIONING 1) +set(BUILD_OBJECT_LIBRARY 1) +include(../../lib_static.cmake) diff --git a/src/installer/corehost/cli/hostpolicy/args.cpp b/src/installer/corehost/cli/hostpolicy/static/args.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/args.cpp rename to src/installer/corehost/cli/hostpolicy/static/args.cpp diff --git a/src/installer/corehost/cli/hostpolicy/args.h b/src/installer/corehost/cli/hostpolicy/static/args.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/args.h rename to src/installer/corehost/cli/hostpolicy/static/args.h diff --git a/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp b/src/installer/corehost/cli/hostpolicy/static/breadcrumbs.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp rename to src/installer/corehost/cli/hostpolicy/static/breadcrumbs.cpp diff --git a/src/installer/corehost/cli/hostpolicy/breadcrumbs.h b/src/installer/corehost/cli/hostpolicy/static/breadcrumbs.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/breadcrumbs.h rename to src/installer/corehost/cli/hostpolicy/static/breadcrumbs.h diff --git a/src/installer/corehost/cli/hostpolicy/coreclr.cpp b/src/installer/corehost/cli/hostpolicy/static/coreclr.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/coreclr.cpp rename to src/installer/corehost/cli/hostpolicy/static/coreclr.cpp diff --git a/src/installer/corehost/cli/hostpolicy/coreclr.h b/src/installer/corehost/cli/hostpolicy/static/coreclr.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/coreclr.h rename to src/installer/corehost/cli/hostpolicy/static/coreclr.h diff --git a/src/installer/corehost/cli/hostpolicy/deps_resolver.cpp b/src/installer/corehost/cli/hostpolicy/static/deps_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/deps_resolver.cpp rename to src/installer/corehost/cli/hostpolicy/static/deps_resolver.cpp diff --git a/src/installer/corehost/cli/hostpolicy/deps_resolver.h b/src/installer/corehost/cli/hostpolicy/static/deps_resolver.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/deps_resolver.h rename to src/installer/corehost/cli/hostpolicy/static/deps_resolver.h diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy.cpp b/src/installer/corehost/cli/hostpolicy/static/hostpolicy.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/hostpolicy.cpp rename to src/installer/corehost/cli/hostpolicy/static/hostpolicy.cpp diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp b/src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp rename to src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.cpp diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.h b/src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/hostpolicy_context.h rename to src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.h diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_init.cpp b/src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/hostpolicy_init.cpp rename to src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.cpp diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_init.h b/src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/hostpolicy_init.h rename to src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.h diff --git a/src/installer/corehost/cli/lib_static.cmake b/src/installer/corehost/cli/lib_static.cmake index 8135e9c19e0e0..00204df3ce9f4 100644 --- a/src/installer/corehost/cli/lib_static.cmake +++ b/src/installer/corehost/cli/lib_static.cmake @@ -10,7 +10,11 @@ add_definitions(-D_NO_ASYNCRTIMP) add_definitions(-D_NO_PPLXIMP) add_definitions(-DEXPORT_SHARED_API=1) -add_library(lib${DOTNET_PROJECT_NAME} STATIC ${SOURCES} ${RESOURCES}) +if (BUILD_OBJECT_LIBRARY) + add_library(lib${DOTNET_PROJECT_NAME} OBJECT ${SOURCES} ${RESOURCES}) +else () + add_library(lib${DOTNET_PROJECT_NAME} STATIC ${SOURCES} ${RESOURCES}) +endif () set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE) set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES PREFIX "") From d942cf2679d20eaeed5f4e449b9c00553bd20de4 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 16 Apr 2020 20:48:08 +0000 Subject: [PATCH 03/22] corehost: Allow linking of hostfxr and hostpolicy with apphost Provide a hostfxr_iface class, that abstracts how the hostfxr functions called by the early stage in the hosting layer is resolved. --- src/installer/corehost/cli/exe.cmake | 3 ++ src/installer/corehost/corehost.cpp | 60 +++++++++++--------------- src/installer/corehost/hostfxr_iface.h | 40 +++++++++++++++++ 3 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 src/installer/corehost/hostfxr_iface.h diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake index 481d0fdb040af..d7b69e4fec9e0 100644 --- a/src/installer/corehost/cli/exe.cmake +++ b/src/installer/corehost/cli/exe.cmake @@ -19,6 +19,9 @@ list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/fxr_resolver.cpp ${CMAKE_CURRENT_LIST_DIR}/../corehost.cpp ) +list(APPEND HEADERS + ${CMAKE_CURRENT_LIST_DIR}/../hostfxr_iface.h +) add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES}) diff --git a/src/installer/corehost/corehost.cpp b/src/installer/corehost/corehost.cpp index 55b8ed629827c..bd73110e837f2 100644 --- a/src/installer/corehost/corehost.cpp +++ b/src/installer/corehost/corehost.cpp @@ -9,6 +9,7 @@ #include "fx_ver.h" #include "trace.h" #include "utils.h" +#include "hostfxr_iface.h" #if defined(FEATURE_APPHOST) #include "bundle_marker.h" @@ -176,51 +177,41 @@ int exe_start(const int argc, const pal::char_t* argv[]) app_path.append(_X(".dll")); #endif - pal::string_t dotnet_root; - pal::string_t fxr_path; - if (!fxr_resolver::try_get_path(app_root, &dotnet_root, &fxr_path)) - { - return StatusCode::CoreHostLibMissingFailure; - } + hostfxr fxr{app_root}; - // Load library - pal::dll_t fxr; - if (!pal::load_library(&fxr_path, &fxr)) + // Obtain the entrypoints. + int rc = fxr.status_code(); + if (rc != StatusCode::Success) { - trace::error(_X("The library %s was found, but loading it from %s failed"), LIBFXR_NAME, fxr_path.c_str()); - trace::error(_X(" - Installing .NET prerequisites might help resolve this problem.")); - trace::error(_X(" %s"), DOTNET_CORE_INSTALL_PREREQUISITES_URL); - return StatusCode::CoreHostLibLoadFailure; + return rc; } - // Obtain the entrypoints. - int rc; #if defined(FEATURE_APPHOST) if (bundle_marker_t::is_bundle()) { - hostfxr_main_bundle_startupinfo_fn hostfxr_main_bundle_startupinfo = reinterpret_cast(pal::get_symbol(fxr, "hostfxr_main_bundle_startupinfo")); + auto hostfxr_main_bundle_startupinfo = fxr.resolve_main_bundle_startupinfo(); if (hostfxr_main_bundle_startupinfo != nullptr) { const pal::char_t* host_path_cstr = host_path.c_str(); - const pal::char_t* dotnet_root_cstr = dotnet_root.empty() ? nullptr : dotnet_root.c_str(); + const pal::char_t* dotnet_root_cstr = fxr.dotnet_root().empty() ? nullptr : fxr.dotnet_root().c_str(); const pal::char_t* app_path_cstr = app_path.empty() ? nullptr : app_path.c_str(); int64_t bundle_header_offset = bundle_marker_t::header_offset(); - trace::info(_X("Invoking fx resolver [%s] hostfxr_main_bundle_startupinfo"), fxr_path.c_str()); + trace::info(_X("Invoking fx resolver [%s] hostfxr_main_bundle_startupinfo"), fxr.fxr_path().c_str()); trace::info(_X("Host path: [%s]"), host_path.c_str()); - trace::info(_X("Dotnet path: [%s]"), dotnet_root.c_str()); + trace::info(_X("Dotnet path: [%s]"), fxr.dotnet_root().c_str()); trace::info(_X("App path: [%s]"), app_path.c_str()); trace::info(_X("Bundle Header Offset: [%lx]"), bundle_header_offset); - hostfxr_set_error_writer_fn set_error_writer_fn = reinterpret_cast(pal::get_symbol(fxr, "hostfxr_set_error_writer")); - propagate_error_writer_t propagate_error_writer_to_hostfxr(set_error_writer_fn); + auto set_error_writer = fxr.resolve_set_error_writer(); + propagate_error_writer_t propagate_error_writer_to_hostfxr(set_error_writer); rc = hostfxr_main_bundle_startupinfo(argc, argv, host_path_cstr, dotnet_root_cstr, app_path_cstr, bundle_header_offset); } else { // The host components will be statically linked with the app-host: https://github.com/dotnet/runtime/issues/32823 // Once this work is completed, an outdated hostfxr can only be found for framework-related apps. - trace::error(_X("The required library %s does not support single-file apps."), fxr_path.c_str()); + trace::error(_X("The required library %s does not support single-file apps."), fxr.fxr_path().c_str()); need_newer_framework_error(); rc = StatusCode::FrameworkMissingFailure; } @@ -228,60 +219,61 @@ int exe_start(const int argc, const pal::char_t* argv[]) else #endif // defined(FEATURE_APPHOST) { - hostfxr_main_startupinfo_fn hostfxr_main_startupinfo = reinterpret_cast(pal::get_symbol(fxr, "hostfxr_main_startupinfo")); + auto hostfxr_main_startupinfo = fxr.resolve_main_startupinfo(); if (hostfxr_main_startupinfo != nullptr) { const pal::char_t* host_path_cstr = host_path.c_str(); - const pal::char_t* dotnet_root_cstr = dotnet_root.empty() ? nullptr : dotnet_root.c_str(); + const pal::char_t* dotnet_root_cstr = fxr.dotnet_root().empty() ? nullptr : fxr.dotnet_root().c_str(); const pal::char_t* app_path_cstr = app_path.empty() ? nullptr : app_path.c_str(); - trace::info(_X("Invoking fx resolver [%s] hostfxr_main_startupinfo"), fxr_path.c_str()); + trace::info(_X("Invoking fx resolver [%s] hostfxr_main_startupinfo"), fxr.fxr_path().c_str()); trace::info(_X("Host path: [%s]"), host_path.c_str()); - trace::info(_X("Dotnet path: [%s]"), dotnet_root.c_str()); + trace::info(_X("Dotnet path: [%s]"), fxr.dotnet_root().c_str()); trace::info(_X("App path: [%s]"), app_path.c_str()); - hostfxr_set_error_writer_fn set_error_writer_fn = reinterpret_cast(pal::get_symbol(fxr, "hostfxr_set_error_writer")); - propagate_error_writer_t propagate_error_writer_to_hostfxr(set_error_writer_fn); + auto set_error_writer = fxr.resolve_set_error_writer(); + propagate_error_writer_t propagate_error_writer_to_hostfxr(set_error_writer); rc = hostfxr_main_startupinfo(argc, argv, host_path_cstr, dotnet_root_cstr, app_path_cstr); // This check exists to provide an error message for UI apps when running 3.0 apps on 2.0 only hostfxr, which doesn't support error writer redirection. - if (trace::get_error_writer() != nullptr && rc == static_cast(StatusCode::FrameworkMissingFailure) && !set_error_writer_fn) + if (trace::get_error_writer() != nullptr && rc == static_cast(StatusCode::FrameworkMissingFailure) && set_error_writer == nullptr) { need_newer_framework_error(); } } +#if !defined(FEATURE_STATIC_HOST) else { if (requires_hostfxr_startupinfo_interface) { - trace::error(_X("The required library %s does not support relative app dll paths."), fxr_path.c_str()); + trace::error(_X("The required library %s does not support relative app dll paths."), fxr.fxr_path().c_str()); rc = StatusCode::CoreHostEntryPointFailure; } else { - trace::info(_X("Invoking fx resolver [%s] v1"), fxr_path.c_str()); + trace::info(_X("Invoking fx resolver [%s] v1"), fxr.fxr_path().c_str()); // Previous corehost trace messages must be printed before calling trace::setup in hostfxr trace::flush(); // For compat, use the v1 interface. This requires additional file I\O to re-parse parameters and // for apphost, does not support DOTNET_ROOT or dll with different name for exe. - hostfxr_main_fn main_fn_v1 = reinterpret_cast(pal::get_symbol(fxr, "hostfxr_main")); + auto main_fn_v1 = fxr.resolve_main_v1(); if (main_fn_v1 != nullptr) { rc = main_fn_v1(argc, argv); } else { - trace::error(_X("The required library %s does not contain the expected entry point."), fxr_path.c_str()); + trace::error(_X("The required library %s does not contain the expected entry point."), fxr.fxr_path().c_str()); rc = StatusCode::CoreHostEntryPointFailure; } } } +#endif // defined(FEATURE_STATIC_HOST) } - pal::unload_library(fxr); return rc; } diff --git a/src/installer/corehost/hostfxr_iface.h b/src/installer/corehost/hostfxr_iface.h new file mode 100644 index 0000000000000..93acb8fef201c --- /dev/null +++ b/src/installer/corehost/hostfxr_iface.h @@ -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. +// See the LICENSE file in the project root for more information. + +#ifndef __HOSTFXR_IFACE_H__ +#define __HOSTFXR_IFACE_H__ + +#include "hostfxr.h" +#include "pal.h" +#include "error_codes.h" + +class hostfxr +{ + public: + hostfxr(const pal::string_t& app_root); + ~hostfxr(); + + StatusCode status_code() const { return m_status_code; } + + const pal::string_t& host_path() const { return m_host_path; } + const pal::string_t& dotnet_root() const { return m_dotnet_root; } + const pal::string_t& fxr_path() const { return m_fxr_path; } + + hostfxr_main_bundle_startupinfo_fn resolve_main_bundle_startupinfo(); + hostfxr_set_error_writer_fn resolve_set_error_writer(); + hostfxr_main_startupinfo_fn resolve_main_startupinfo(); + hostfxr_main_fn resolve_main_v1(); + + private: + pal::dll_t m_hostfxr_dll{nullptr}; + + pal::string_t m_host_path; + pal::string_t m_dotnet_root; + pal::string_t m_fxr_path; + + bool m_requires_startupinfo_iface{false}; + StatusCode m_status_code; +}; + +#endif // __HOSTFXR_IFACE_H__ From ea2b6d799fcd5f6c34dd01f20315e3419122724a Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 16 Apr 2020 22:21:18 +0000 Subject: [PATCH 04/22] dotnet: Teach the muxer binary about hostfxr_iface --- src/installer/corehost/cli/dotnet/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/installer/corehost/cli/dotnet/CMakeLists.txt b/src/installer/corehost/cli/dotnet/CMakeLists.txt index 4527986acfe3c..8bf75e8cff873 100644 --- a/src/installer/corehost/cli/dotnet/CMakeLists.txt +++ b/src/installer/corehost/cli/dotnet/CMakeLists.txt @@ -10,4 +10,8 @@ if(CLR_CMAKE_TARGET_WIN32) dotnet.manifest) endif() +list(APPEND SOURCES + ../apphost/shared/hostfxr_iface.cpp +) + include(../exe.cmake) From 0f8daea7e077c3f35045a62f8cb89f53fab2195a Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 16 Apr 2020 20:47:35 +0000 Subject: [PATCH 05/22] apphost: Teach apphost about hostfxr_iface This provides two implementations of hostfxr_iface: one for the static apphost, which bundles hostfxr and hostpolicy, and another for the conventional apphost, which loads them dynamically on startup. --- .../corehost/cli/apphost/CMakeLists.txt | 48 +------------- .../cli/apphost/shared/CMakeLists.txt | 54 ++++++++++++++++ .../cli/apphost/shared/hostfxr_iface.cpp | 61 ++++++++++++++++++ .../cli/apphost/static/CMakeLists.txt | 61 ++++++++++++++++++ .../cli/apphost/static/hostfxr_iface.cpp | 63 +++++++++++++++++++ 5 files changed, 241 insertions(+), 46 deletions(-) create mode 100644 src/installer/corehost/cli/apphost/shared/CMakeLists.txt create mode 100644 src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp create mode 100644 src/installer/corehost/cli/apphost/static/CMakeLists.txt create mode 100644 src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp diff --git a/src/installer/corehost/cli/apphost/CMakeLists.txt b/src/installer/corehost/cli/apphost/CMakeLists.txt index ba01e32ec47c7..886c9c33d996b 100644 --- a/src/installer/corehost/cli/apphost/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/CMakeLists.txt @@ -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(shared) diff --git a/src/installer/corehost/cli/apphost/shared/CMakeLists.txt b/src/installer/corehost/cli/apphost/shared/CMakeLists.txt new file mode 100644 index 0000000000000..e760a857b0eeb --- /dev/null +++ b/src/installer/corehost/cli/apphost/shared/CMakeLists.txt @@ -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_iface.cpp +) + +set(HEADERS + ../bundle_marker.h + ../../../hostfxr_iface.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() diff --git a/src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp b/src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp new file mode 100644 index 0000000000000..044d3bf831a1d --- /dev/null +++ b/src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp @@ -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 + +#include "pal.h" +#include "fxr_resolver.h" +#include "trace.h" +#include "hostfxr_iface.h" + +hostfxr_main_bundle_startupinfo_fn hostfxr::resolve_main_bundle_startupinfo() +{ + assert(m_hostfxr_dll != nullptr); + return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_bundle_startupinfo")); +} + +hostfxr_set_error_writer_fn hostfxr::resolve_set_error_writer() +{ + assert(m_hostfxr_dll != nullptr); + return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_set_error_writer")); +} + +hostfxr_main_startupinfo_fn hostfxr::resolve_main_startupinfo() +{ + assert(m_hostfxr_dll != nullptr); + return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_startupinfo")); +} + +hostfxr_main_fn hostfxr::resolve_main_v1() +{ + assert(m_hostfxr_dll != nullptr); + return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_main")); +} + +hostfxr::hostfxr(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::~hostfxr() +{ + if (m_hostfxr_dll != nullptr) + { + pal::unload_library(m_hostfxr_dll); + } +} diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt new file mode 100644 index 0000000000000..8e0119720a682 --- /dev/null +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -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. + +project(static_apphost) +set(DOTNET_PROJECT_NAME "static_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_iface.cpp +) + +set(HEADERS + ../bundle_marker.h + ../../../hostfxr_iface.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(static_apphost Advapi32.lib shell32.lib) +endif() + +target_link_libraries(static_apphost + libhostfxr_static + libhostpolicy_static + libhostcommon +) diff --git a/src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp b/src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp new file mode 100644 index 0000000000000..83dfa626aa98f --- /dev/null +++ b/src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp @@ -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 +#include "trace.h" +#include "hostfxr.h" +#include "hostfxr_iface.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::resolve_main_bundle_startupinfo() +{ + assert(m_hostfxr_dll == nullptr); + return hostfxr_main_bundle_startupinfo; +} + +hostfxr_set_error_writer_fn hostfxr::resolve_set_error_writer() +{ + assert(m_hostfxr_dll == nullptr); + return hostfxr_set_error_writer; +} + +hostfxr_main_startupinfo_fn hostfxr::resolve_main_startupinfo() +{ + assert(m_hostfxr_dll == nullptr); + return hostfxr_main_startupinfo; +} + +hostfxr_main_fn hostfxr::resolve_main_v1() +{ + assert(m_hostfxr_dll == nullptr); + assert(!"This function should not be called in a static host"); + return nullptr; +} + +hostfxr::hostfxr(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::~hostfxr() +{ +} From 23f1bf992aec000a417d6b2ebbddc7d9c015fa6d Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 23 Apr 2020 14:59:48 -0700 Subject: [PATCH 06/22] Add exports for hostfxr and policy --- .../corehost/cli/fxr/shared/CMakeLists.txt | 5 +++++ .../corehost/cli/fxr/shared/Exports.def | 17 +++++++++++++++++ .../cli/hostpolicy/shared/CMakeLists.txt | 5 +++++ .../corehost/cli/hostpolicy/shared/Exports.def | 8 ++++++++ 4 files changed, 35 insertions(+) create mode 100644 src/installer/corehost/cli/fxr/shared/Exports.def create mode 100644 src/installer/corehost/cli/hostpolicy/shared/Exports.def diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt index d8d2bce4fe8c9..2f90d81a5d1b1 100644 --- a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt @@ -15,6 +15,11 @@ set(SOURCES ./hostpolicy_resolver.cpp ) +if(CLR_CMAKE_TARGET_WIN32) + list(APPEND SOURCES + Exports.def) +endif() + set(HEADERS ../static/command_line.h ../static/corehost_init.h diff --git a/src/installer/corehost/cli/fxr/shared/Exports.def b/src/installer/corehost/cli/fxr/shared/Exports.def new file mode 100644 index 0000000000000..8ffdccb0b20dd --- /dev/null +++ b/src/installer/corehost/cli/fxr/shared/Exports.def @@ -0,0 +1,17 @@ +EXPORTS + hostfxr_main_bundle_startupinfo + hostfxr_main_startupinfo + hostfxr_main + hostfxr_resolve_sdk + hostfxr_resolve_sdk2 + hostfxr_get_available_sdks + hostfxr_get_native_search_directories + hostfxr_set_error_writer + hostfxr_initialize_for_dotnet_command_line + hostfxr_initialize_for_runtime_config + hostfxr_run_app + hostfxr_get_runtime_delegate + hostfxr_get_runtime_property_value + hostfxr_set_runtime_property_value + hostfxr_get_runtime_properties + hostfxr_close \ No newline at end of file diff --git a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt index a2ae28e7a1703..398860eeac5cc 100644 --- a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt @@ -18,6 +18,11 @@ set(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp ) +if(CLR_CMAKE_TARGET_WIN32) + list(APPEND SOURCES + Exports.def) +endif() + set(HEADERS ) diff --git a/src/installer/corehost/cli/hostpolicy/shared/Exports.def b/src/installer/corehost/cli/hostpolicy/shared/Exports.def new file mode 100644 index 0000000000000..e132a61cee32f --- /dev/null +++ b/src/installer/corehost/cli/hostpolicy/shared/Exports.def @@ -0,0 +1,8 @@ +EXPORTS + corehost_initialize + corehost_load + corehost_main + corehost_main_with_output_buffer + corehost_resolve_component_dependencies + corehost_set_error_writer + corehost_unload From 54506ae59165e87e3b465fa7ca35a70b18c694ac Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 23 Apr 2020 18:06:00 -0700 Subject: [PATCH 07/22] Exports for unix --- .../corehost/cli/fxr/shared/CMakeLists.txt | 23 ++++++++++++++++-- .../fxr/shared/{Exports.def => hostfxr.def} | 6 ++++- .../cli/fxr/shared/hostfxr_unixexports.src | 20 ++++++++++++++++ .../cli/hostpolicy/shared/CMakeLists.txt | 24 +++++++++++++++++-- .../cli/hostpolicy/shared/Exports.def | 8 ------- .../cli/hostpolicy/shared/hostpolicy.def | 12 ++++++++++ .../shared/hostpolicy_unixexports.src | 11 +++++++++ 7 files changed, 91 insertions(+), 13 deletions(-) rename src/installer/corehost/cli/fxr/shared/{Exports.def => hostfxr.def} (69%) create mode 100644 src/installer/corehost/cli/fxr/shared/hostfxr_unixexports.src delete mode 100644 src/installer/corehost/cli/hostpolicy/shared/Exports.def create mode 100644 src/installer/corehost/cli/hostpolicy/shared/hostpolicy.def create mode 100644 src/installer/corehost/cli/hostpolicy/shared/hostpolicy_unixexports.src diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt index 2f90d81a5d1b1..66cef01bb31b1 100644 --- a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt @@ -17,8 +17,27 @@ set(SOURCES if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES - Exports.def) -endif() + hostfxr.def) +else(CLR_CMAKE_TARGET_WIN32) + set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hostfxr_unixexports.src) + set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/hostfxr.exports) + generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + + if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) + endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) + + if(CLR_CMAKE_HOST_OSX) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) + endif(CLR_CMAKE_HOST_OSX) + + if(CLR_CMAKE_HOST_SUNOS) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) + endif(CLR_CMAKE_HOST_SUNOS) +endif(CLR_CMAKE_TARGET_WIN32) set(HEADERS ../static/command_line.h diff --git a/src/installer/corehost/cli/fxr/shared/Exports.def b/src/installer/corehost/cli/fxr/shared/hostfxr.def similarity index 69% rename from src/installer/corehost/cli/fxr/shared/Exports.def rename to src/installer/corehost/cli/fxr/shared/hostfxr.def index 8ffdccb0b20dd..c86139a7fb58b 100644 --- a/src/installer/corehost/cli/fxr/shared/Exports.def +++ b/src/installer/corehost/cli/fxr/shared/hostfxr.def @@ -1,3 +1,7 @@ +; 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. + EXPORTS hostfxr_main_bundle_startupinfo hostfxr_main_startupinfo @@ -14,4 +18,4 @@ EXPORTS hostfxr_get_runtime_property_value hostfxr_set_runtime_property_value hostfxr_get_runtime_properties - hostfxr_close \ No newline at end of file + hostfxr_close diff --git a/src/installer/corehost/cli/fxr/shared/hostfxr_unixexports.src b/src/installer/corehost/cli/fxr/shared/hostfxr_unixexports.src new file mode 100644 index 0000000000000..fcf85d027fa64 --- /dev/null +++ b/src/installer/corehost/cli/fxr/shared/hostfxr_unixexports.src @@ -0,0 +1,20 @@ +; 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. + +hostfxr_main_bundle_startupinfo +hostfxr_main_startupinfo +hostfxr_main +hostfxr_resolve_sdk +hostfxr_resolve_sdk2 +hostfxr_get_available_sdks +hostfxr_get_native_search_directories +hostfxr_set_error_writer +hostfxr_initialize_for_dotnet_command_line +hostfxr_initialize_for_runtime_config +hostfxr_run_app +hostfxr_get_runtime_delegate +hostfxr_get_runtime_property_value +hostfxr_set_runtime_property_value +hostfxr_get_runtime_properties +hostfxr_close diff --git a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt index 398860eeac5cc..ea7e06cff3e61 100644 --- a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt @@ -20,8 +20,28 @@ set(SOURCES if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES - Exports.def) -endif() + hostpolicy.def) +else(CLR_CMAKE_TARGET_WIN32) + set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hostpolicy_unixexports.src) + set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/hostpolicy.exports) + generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + + if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) + endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) + + if(CLR_CMAKE_HOST_OSX) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) + endif(CLR_CMAKE_HOST_OSX) + + if(CLR_CMAKE_HOST_SUNOS) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) + endif(CLR_CMAKE_HOST_SUNOS) +endif(CLR_CMAKE_TARGET_WIN32) + set(HEADERS ) diff --git a/src/installer/corehost/cli/hostpolicy/shared/Exports.def b/src/installer/corehost/cli/hostpolicy/shared/Exports.def deleted file mode 100644 index e132a61cee32f..0000000000000 --- a/src/installer/corehost/cli/hostpolicy/shared/Exports.def +++ /dev/null @@ -1,8 +0,0 @@ -EXPORTS - corehost_initialize - corehost_load - corehost_main - corehost_main_with_output_buffer - corehost_resolve_component_dependencies - corehost_set_error_writer - corehost_unload diff --git a/src/installer/corehost/cli/hostpolicy/shared/hostpolicy.def b/src/installer/corehost/cli/hostpolicy/shared/hostpolicy.def new file mode 100644 index 0000000000000..af03ab9dca68d --- /dev/null +++ b/src/installer/corehost/cli/hostpolicy/shared/hostpolicy.def @@ -0,0 +1,12 @@ +; 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. + +EXPORTS + corehost_initialize + corehost_load + corehost_main + corehost_main_with_output_buffer + corehost_resolve_component_dependencies + corehost_set_error_writer + corehost_unload diff --git a/src/installer/corehost/cli/hostpolicy/shared/hostpolicy_unixexports.src b/src/installer/corehost/cli/hostpolicy/shared/hostpolicy_unixexports.src new file mode 100644 index 0000000000000..98f3e616e9499 --- /dev/null +++ b/src/installer/corehost/cli/hostpolicy/shared/hostpolicy_unixexports.src @@ -0,0 +1,11 @@ +; 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. + +corehost_initialize +corehost_load +corehost_main +corehost_main_with_output_buffer +corehost_resolve_component_dependencies +corehost_set_error_writer +corehost_unload From 87a4e1fde2d851f4c1abbc4944c17d71e5ac2ece Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 24 Apr 2020 06:47:58 -0700 Subject: [PATCH 08/22] EXPORTS_LINKER_OPTION --- src/installer/corehost/cli/fxr/shared/CMakeLists.txt | 8 ++++++++ .../corehost/cli/hostpolicy/shared/CMakeLists.txt | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt index 66cef01bb31b1..27a888b4bb381 100644 --- a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt @@ -53,5 +53,13 @@ set(HEADERS include(../../lib.cmake) +if(CLR_CMAKE_HOST_UNIX) + add_custom_target(hostfxr_exports DEPENDS ${EXPORTS_FILE}) + add_dependencies(hostfxr hostfxr_exports) + + set_property(TARGET hostfxr APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) + set_property(TARGET hostfxr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) +endif(CLR_CMAKE_HOST_UNIX) + install_with_stripped_symbols(hostfxr TARGETS corehost) target_link_libraries(hostfxr libhostcommon libhostfxr_static) diff --git a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt index ea7e06cff3e61..41cb9d96275c6 100644 --- a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt @@ -48,5 +48,13 @@ set(HEADERS include(../../lib.cmake) +if(CLR_CMAKE_HOST_UNIX) + add_custom_target(hostpolicy_exports DEPENDS ${EXPORTS_FILE}) + add_dependencies(hostpolicy hostpolicy_exports) + + set_property(TARGET hostpolicy APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) + set_property(TARGET hostpolicy APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) +endif(CLR_CMAKE_HOST_UNIX) + install_with_stripped_symbols(hostpolicy TARGETS corehost) target_link_libraries(hostpolicy libhostcommon libhostpolicy_static) From a8b90aee7b6460602d93568e30a02582e0775fb8 Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 24 Apr 2020 11:55:34 -0700 Subject: [PATCH 09/22] use generateversionscript.awk from ENG --- eng/native/functions.cmake | 8 ++++---- {src/coreclr => eng/native}/generateexportedsymbols.awk | 0 {src/coreclr => eng/native}/generateversionscript.awk | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename {src/coreclr => eng/native}/generateexportedsymbols.awk (100%) rename {src/coreclr => eng/native}/generateversionscript.awk (100%) diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 060cff8987e35..49b0064499eb4 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -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} @@ -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} diff --git a/src/coreclr/generateexportedsymbols.awk b/eng/native/generateexportedsymbols.awk similarity index 100% rename from src/coreclr/generateexportedsymbols.awk rename to eng/native/generateexportedsymbols.awk diff --git a/src/coreclr/generateversionscript.awk b/eng/native/generateversionscript.awk similarity index 100% rename from src/coreclr/generateversionscript.awk rename to eng/native/generateversionscript.awk From b231629dff00d2b8d39d989a0042bbb2001670c4 Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 24 Apr 2020 13:45:38 -0700 Subject: [PATCH 10/22] Move fxr files out of static --- .../corehost/cli/comhost/CMakeLists.txt | 1 - src/installer/corehost/cli/exe.cmake | 1 - .../cli/fxr/{static => }/command_line.cpp | 0 .../cli/fxr/{static => }/command_line.h | 0 .../cli/fxr/{static => }/corehost_init.cpp | 0 .../cli/fxr/{static => }/corehost_init.h | 0 .../cli/fxr/{static => }/framework_info.cpp | 0 .../cli/fxr/{static => }/framework_info.h | 0 .../cli/fxr/{static => }/fx_muxer.cpp | 0 .../corehost/cli/fxr/{static => }/fx_muxer.h | 0 .../cli/fxr/{static => }/fx_resolver.cpp | 0 .../cli/fxr/{static => }/fx_resolver.h | 0 .../fxr/{static => }/fx_resolver.messages.cpp | 0 .../corehost/cli/fxr/{static => }/fx_ver.cpp | 0 .../corehost/cli/fxr/{static => }/fx_ver.h | 0 .../cli/fxr/{static => }/host_context.cpp | 0 .../cli/fxr/{static => }/host_context.h | 0 .../corehost/cli/fxr/{static => }/hostfxr.cpp | 0 .../fxr/{static => }/hostpolicy_resolver.h | 0 .../cli/fxr/{static => }/sdk_info.cpp | 0 .../corehost/cli/fxr/{static => }/sdk_info.h | 0 .../cli/fxr/{static => }/sdk_resolver.cpp | 0 .../cli/fxr/{static => }/sdk_resolver.h | 0 .../corehost/cli/fxr/shared/CMakeLists.txt | 20 +++++----- .../corehost/cli/fxr/static/CMakeLists.txt | 37 ++++++++++--------- .../corehost/cli/hostcommon/CMakeLists.txt | 5 +-- .../cli/hostpolicy/{static => }/args.cpp | 0 .../cli/hostpolicy/{static => }/args.h | 0 .../hostpolicy/{static => }/breadcrumbs.cpp | 0 .../cli/hostpolicy/{static => }/breadcrumbs.h | 0 .../cli/hostpolicy/{static => }/coreclr.cpp | 0 .../cli/hostpolicy/{static => }/coreclr.h | 0 .../hostpolicy/{static => }/deps_resolver.cpp | 0 .../hostpolicy/{static => }/deps_resolver.h | 0 .../hostpolicy/{static => }/hostpolicy.cpp | 0 .../{static => }/hostpolicy_context.cpp | 0 .../{static => }/hostpolicy_context.h | 0 .../{static => }/hostpolicy_init.cpp | 0 .../hostpolicy/{static => }/hostpolicy_init.h | 0 .../cli/hostpolicy/static/CMakeLists.txt | 31 ++++++++-------- .../corehost/cli/ijwhost/CMakeLists.txt | 1 - .../corehost/cli/nethost/CMakeLists.txt | 1 - .../corehost/cli/test_fx_ver/CMakeLists.txt | 1 - .../corehost/cli/winrthost/CMakeLists.txt | 1 - 44 files changed, 46 insertions(+), 53 deletions(-) rename src/installer/corehost/cli/fxr/{static => }/command_line.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/command_line.h (100%) rename src/installer/corehost/cli/fxr/{static => }/corehost_init.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/corehost_init.h (100%) rename src/installer/corehost/cli/fxr/{static => }/framework_info.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/framework_info.h (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_muxer.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_muxer.h (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_resolver.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_resolver.h (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_resolver.messages.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_ver.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/fx_ver.h (100%) rename src/installer/corehost/cli/fxr/{static => }/host_context.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/host_context.h (100%) rename src/installer/corehost/cli/fxr/{static => }/hostfxr.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/hostpolicy_resolver.h (100%) rename src/installer/corehost/cli/fxr/{static => }/sdk_info.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/sdk_info.h (100%) rename src/installer/corehost/cli/fxr/{static => }/sdk_resolver.cpp (100%) rename src/installer/corehost/cli/fxr/{static => }/sdk_resolver.h (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/args.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/args.h (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/breadcrumbs.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/breadcrumbs.h (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/coreclr.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/coreclr.h (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/deps_resolver.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/deps_resolver.h (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/hostpolicy.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/hostpolicy_context.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/hostpolicy_context.h (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/hostpolicy_init.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{static => }/hostpolicy_init.h (100%) diff --git a/src/installer/corehost/cli/comhost/CMakeLists.txt b/src/installer/corehost/cli/comhost/CMakeLists.txt index de8094a194f93..b0f4759ffc682 100644 --- a/src/installer/corehost/cli/comhost/CMakeLists.txt +++ b/src/installer/corehost/cli/comhost/CMakeLists.txt @@ -8,7 +8,6 @@ set(DOTNET_PROJECT_NAME "comhost") # Include directories include_directories(../fxr) -include_directories(../fxr/static) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake index d7b69e4fec9e0..920f332a662a3 100644 --- a/src/installer/corehost/cli/exe.cmake +++ b/src/installer/corehost/cli/exe.cmake @@ -12,7 +12,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) # Include directories include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr) -include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr/static) # CMake does not recommend using globbing since it messes with the freshness checks list(APPEND SOURCES diff --git a/src/installer/corehost/cli/fxr/static/command_line.cpp b/src/installer/corehost/cli/fxr/command_line.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/command_line.cpp rename to src/installer/corehost/cli/fxr/command_line.cpp diff --git a/src/installer/corehost/cli/fxr/static/command_line.h b/src/installer/corehost/cli/fxr/command_line.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/command_line.h rename to src/installer/corehost/cli/fxr/command_line.h diff --git a/src/installer/corehost/cli/fxr/static/corehost_init.cpp b/src/installer/corehost/cli/fxr/corehost_init.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/corehost_init.cpp rename to src/installer/corehost/cli/fxr/corehost_init.cpp diff --git a/src/installer/corehost/cli/fxr/static/corehost_init.h b/src/installer/corehost/cli/fxr/corehost_init.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/corehost_init.h rename to src/installer/corehost/cli/fxr/corehost_init.h diff --git a/src/installer/corehost/cli/fxr/static/framework_info.cpp b/src/installer/corehost/cli/fxr/framework_info.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/framework_info.cpp rename to src/installer/corehost/cli/fxr/framework_info.cpp diff --git a/src/installer/corehost/cli/fxr/static/framework_info.h b/src/installer/corehost/cli/fxr/framework_info.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/framework_info.h rename to src/installer/corehost/cli/fxr/framework_info.h diff --git a/src/installer/corehost/cli/fxr/static/fx_muxer.cpp b/src/installer/corehost/cli/fxr/fx_muxer.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_muxer.cpp rename to src/installer/corehost/cli/fxr/fx_muxer.cpp diff --git a/src/installer/corehost/cli/fxr/static/fx_muxer.h b/src/installer/corehost/cli/fxr/fx_muxer.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_muxer.h rename to src/installer/corehost/cli/fxr/fx_muxer.h diff --git a/src/installer/corehost/cli/fxr/static/fx_resolver.cpp b/src/installer/corehost/cli/fxr/fx_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_resolver.cpp rename to src/installer/corehost/cli/fxr/fx_resolver.cpp diff --git a/src/installer/corehost/cli/fxr/static/fx_resolver.h b/src/installer/corehost/cli/fxr/fx_resolver.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_resolver.h rename to src/installer/corehost/cli/fxr/fx_resolver.h diff --git a/src/installer/corehost/cli/fxr/static/fx_resolver.messages.cpp b/src/installer/corehost/cli/fxr/fx_resolver.messages.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_resolver.messages.cpp rename to src/installer/corehost/cli/fxr/fx_resolver.messages.cpp diff --git a/src/installer/corehost/cli/fxr/static/fx_ver.cpp b/src/installer/corehost/cli/fxr/fx_ver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_ver.cpp rename to src/installer/corehost/cli/fxr/fx_ver.cpp diff --git a/src/installer/corehost/cli/fxr/static/fx_ver.h b/src/installer/corehost/cli/fxr/fx_ver.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/fx_ver.h rename to src/installer/corehost/cli/fxr/fx_ver.h diff --git a/src/installer/corehost/cli/fxr/static/host_context.cpp b/src/installer/corehost/cli/fxr/host_context.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/host_context.cpp rename to src/installer/corehost/cli/fxr/host_context.cpp diff --git a/src/installer/corehost/cli/fxr/static/host_context.h b/src/installer/corehost/cli/fxr/host_context.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/host_context.h rename to src/installer/corehost/cli/fxr/host_context.h diff --git a/src/installer/corehost/cli/fxr/static/hostfxr.cpp b/src/installer/corehost/cli/fxr/hostfxr.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/hostfxr.cpp rename to src/installer/corehost/cli/fxr/hostfxr.cpp diff --git a/src/installer/corehost/cli/fxr/static/hostpolicy_resolver.h b/src/installer/corehost/cli/fxr/hostpolicy_resolver.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/hostpolicy_resolver.h rename to src/installer/corehost/cli/fxr/hostpolicy_resolver.h diff --git a/src/installer/corehost/cli/fxr/static/sdk_info.cpp b/src/installer/corehost/cli/fxr/sdk_info.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/sdk_info.cpp rename to src/installer/corehost/cli/fxr/sdk_info.cpp diff --git a/src/installer/corehost/cli/fxr/static/sdk_info.h b/src/installer/corehost/cli/fxr/sdk_info.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/sdk_info.h rename to src/installer/corehost/cli/fxr/sdk_info.h diff --git a/src/installer/corehost/cli/fxr/static/sdk_resolver.cpp b/src/installer/corehost/cli/fxr/sdk_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/sdk_resolver.cpp rename to src/installer/corehost/cli/fxr/sdk_resolver.cpp diff --git a/src/installer/corehost/cli/fxr/static/sdk_resolver.h b/src/installer/corehost/cli/fxr/sdk_resolver.h similarity index 100% rename from src/installer/corehost/cli/fxr/static/sdk_resolver.h rename to src/installer/corehost/cli/fxr/sdk_resolver.h diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt index 27a888b4bb381..7b9305a482808 100644 --- a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt @@ -8,7 +8,7 @@ set(DOTNET_PROJECT_NAME "hostfxr") # Include directories include_directories(../../json) -include_directories(../static) +include_directories(../../fxr) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES @@ -40,15 +40,15 @@ else(CLR_CMAKE_TARGET_WIN32) endif(CLR_CMAKE_TARGET_WIN32) set(HEADERS - ../static/command_line.h - ../static/corehost_init.h - ../static/fx_muxer.h - ../static/fx_resolver.h - ../static/framework_info.h - ../static/host_context.h - ../static/hostpolicy_resolver.h - ../static/sdk_info.h - ../static/sdk_resolver.h + ../command_line.h + ../corehost_init.h + ../fx_muxer.h + ../fx_resolver.h + ../framework_info.h + ../host_context.h + ../hostpolicy_resolver.h + ../sdk_info.h + ../sdk_resolver.h ) include(../../lib.cmake) diff --git a/src/installer/corehost/cli/fxr/static/CMakeLists.txt b/src/installer/corehost/cli/fxr/static/CMakeLists.txt index 39f7d1a5a2de9..1f59bc0590504 100644 --- a/src/installer/corehost/cli/fxr/static/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/static/CMakeLists.txt @@ -8,19 +8,20 @@ set(DOTNET_PROJECT_NAME "hostfxr_static") # Include directories include_directories(../../json) +include_directories(../../fxr) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES - ./command_line.cpp - ./corehost_init.cpp - ./hostfxr.cpp - ./fx_muxer.cpp - ./fx_resolver.cpp - ./fx_resolver.messages.cpp - ./framework_info.cpp - ./host_context.cpp - ./sdk_info.cpp - ./sdk_resolver.cpp + ../command_line.cpp + ../corehost_init.cpp + ../hostfxr.cpp + ../fx_muxer.cpp + ../fx_resolver.cpp + ../fx_resolver.messages.cpp + ../framework_info.cpp + ../host_context.cpp + ../sdk_info.cpp + ../sdk_resolver.cpp ./hostpolicy_resolver.cpp ) @@ -30,14 +31,14 @@ set(HEADERS ../../fx_definition.h ../../fx_reference.h ../../roll_fwd_on_no_candidate_fx_option.h - ./command_line.h - ./corehost_init.h - ./fx_muxer.h - ./fx_resolver.h - ./framework_info.h - ./host_context.h - ./sdk_info.h - ./sdk_resolver.h + ../command_line.h + ../corehost_init.h + ../fx_muxer.h + ../fx_resolver.h + ../framework_info.h + ../host_context.h + ../sdk_info.h + ../sdk_resolver.h ) set(SKIP_VERSIONING 1) diff --git a/src/installer/corehost/cli/hostcommon/CMakeLists.txt b/src/installer/corehost/cli/hostcommon/CMakeLists.txt index 2bac08df03e7c..8ad0c8d09f47c 100644 --- a/src/installer/corehost/cli/hostcommon/CMakeLists.txt +++ b/src/installer/corehost/cli/hostcommon/CMakeLists.txt @@ -8,7 +8,6 @@ set(DOTNET_PROJECT_NAME "hostcommon") # Include directories include_directories(../fxr) -include_directories(../fxr/static) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks @@ -20,7 +19,7 @@ set(SOURCES ../roll_forward_option.cpp ../fx_definition.cpp ../fx_reference.cpp - ../fxr/static/fx_ver.cpp + ../fxr/fx_ver.cpp ../version.cpp ../version_compatibility_range.cpp ../runtime_config.cpp @@ -37,7 +36,7 @@ set(HEADERS ../roll_forward_option.h ../fx_definition.h ../fx_reference.h - ../fxr/static/fx_ver.h + ../fxr/fx_ver.h ../version.h ../version_compatibility_range.h ../runtime_config.h diff --git a/src/installer/corehost/cli/hostpolicy/static/args.cpp b/src/installer/corehost/cli/hostpolicy/args.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/args.cpp rename to src/installer/corehost/cli/hostpolicy/args.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/args.h b/src/installer/corehost/cli/hostpolicy/args.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/args.h rename to src/installer/corehost/cli/hostpolicy/args.h diff --git a/src/installer/corehost/cli/hostpolicy/static/breadcrumbs.cpp b/src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/breadcrumbs.cpp rename to src/installer/corehost/cli/hostpolicy/breadcrumbs.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/breadcrumbs.h b/src/installer/corehost/cli/hostpolicy/breadcrumbs.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/breadcrumbs.h rename to src/installer/corehost/cli/hostpolicy/breadcrumbs.h diff --git a/src/installer/corehost/cli/hostpolicy/static/coreclr.cpp b/src/installer/corehost/cli/hostpolicy/coreclr.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/coreclr.cpp rename to src/installer/corehost/cli/hostpolicy/coreclr.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/coreclr.h b/src/installer/corehost/cli/hostpolicy/coreclr.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/coreclr.h rename to src/installer/corehost/cli/hostpolicy/coreclr.h diff --git a/src/installer/corehost/cli/hostpolicy/static/deps_resolver.cpp b/src/installer/corehost/cli/hostpolicy/deps_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/deps_resolver.cpp rename to src/installer/corehost/cli/hostpolicy/deps_resolver.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/deps_resolver.h b/src/installer/corehost/cli/hostpolicy/deps_resolver.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/deps_resolver.h rename to src/installer/corehost/cli/hostpolicy/deps_resolver.h diff --git a/src/installer/corehost/cli/hostpolicy/static/hostpolicy.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/hostpolicy.cpp rename to src/installer/corehost/cli/hostpolicy/hostpolicy.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.cpp rename to src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.h b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/hostpolicy_context.h rename to src/installer/corehost/cli/hostpolicy/hostpolicy_context.h diff --git a/src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy_init.cpp similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.cpp rename to src/installer/corehost/cli/hostpolicy/hostpolicy_init.cpp diff --git a/src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.h b/src/installer/corehost/cli/hostpolicy/hostpolicy_init.h similarity index 100% rename from src/installer/corehost/cli/hostpolicy/static/hostpolicy_init.h rename to src/installer/corehost/cli/hostpolicy/hostpolicy_init.h diff --git a/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt index f683ce7319d6b..6845e369bdac3 100644 --- a/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/static/CMakeLists.txt @@ -7,19 +7,18 @@ project(hostpolicy_static) set(DOTNET_PROJECT_NAME "hostpolicy_static") # Include directories -include_directories(../../fxr/shared) -include_directories(../../fxr/static) +include_directories(../../fxr) include_directories(../../json) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES - ./args.cpp - ./breadcrumbs.cpp - ./coreclr.cpp - ./deps_resolver.cpp - ./hostpolicy_context.cpp - ./hostpolicy.cpp - ./hostpolicy_init.cpp + ../args.cpp + ../breadcrumbs.cpp + ../coreclr.cpp + ../deps_resolver.cpp + ../hostpolicy_context.cpp + ../hostpolicy.cpp + ../hostpolicy_init.cpp ../../bundle/dir_utils.cpp ../../bundle/extractor.cpp ../../bundle/file_entry.cpp @@ -28,14 +27,14 @@ set(SOURCES ) set(HEADERS - ./args.h - ./breadcrumbs.h - ./coreclr.h - ../../corehost_context_contract.h - ./deps_resolver.h - ./hostpolicy_context.h + ../args.h + ../breadcrumbs.h + ../coreclr.h + ../deps_resolver.h + ../hostpolicy_context.h + ../hostpolicy_init.h ../../hostpolicy.h - ./hostpolicy_init.h + ../../corehost_context_contract.h ../../bundle/dir_utils.h ../../bundle/extractor.h ../../bundle/file_entry.h diff --git a/src/installer/corehost/cli/ijwhost/CMakeLists.txt b/src/installer/corehost/cli/ijwhost/CMakeLists.txt index d19b479785248..46387c0f29299 100644 --- a/src/installer/corehost/cli/ijwhost/CMakeLists.txt +++ b/src/installer/corehost/cli/ijwhost/CMakeLists.txt @@ -8,7 +8,6 @@ set(DOTNET_PROJECT_NAME "ijwhost") # Include directories include_directories(../fxr) -include_directories(../fxr/static) include_directories(${ARCH_SOURCES_DIR}) # CMake does not recommend using globbing since it messes with the freshness checks diff --git a/src/installer/corehost/cli/nethost/CMakeLists.txt b/src/installer/corehost/cli/nethost/CMakeLists.txt index 1e2688ea2aec0..864129970512c 100644 --- a/src/installer/corehost/cli/nethost/CMakeLists.txt +++ b/src/installer/corehost/cli/nethost/CMakeLists.txt @@ -8,7 +8,6 @@ set(DOTNET_PROJECT_NAME "nethost") # Include directories include_directories(../fxr) -include_directories(../fxr/static) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES diff --git a/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt b/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt index 5a78901dde848..d68eea66656fe 100644 --- a/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt +++ b/src/installer/corehost/cli/test_fx_ver/CMakeLists.txt @@ -8,7 +8,6 @@ set(EXE_NAME "test_fx_ver") include_directories(../../) include_directories(../) include_directories(../fxr) -include_directories(../fxr/static) include_directories(../hostmisc) set(SOURCES diff --git a/src/installer/corehost/cli/winrthost/CMakeLists.txt b/src/installer/corehost/cli/winrthost/CMakeLists.txt index 39f1ccd9633ca..22b32e998771a 100644 --- a/src/installer/corehost/cli/winrthost/CMakeLists.txt +++ b/src/installer/corehost/cli/winrthost/CMakeLists.txt @@ -7,7 +7,6 @@ set(DOTNET_PROJECT_NAME "winrthost") # Include directories include_directories(../fxr) -include_directories(../fxr/static) # CMake does not recommend using globbing since it messes with the freshness checks From 1efc302d24418d83c6ff289de0270e1b415edd26 Mon Sep 17 00:00:00 2001 From: vsadov Date: Sun, 26 Apr 2020 19:52:46 -0700 Subject: [PATCH 11/22] Fixes for Linux --- .../cli/apphost/static/CMakeLists.txt | 2 ++ .../static/hostpolicy_resolver.cpp | 0 .../corehost/cli/fxr/shared/CMakeLists.txt | 24 +++++++++---------- .../corehost/cli/fxr/static/CMakeLists.txt | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) rename src/installer/corehost/cli/{fxr => apphost}/static/hostpolicy_resolver.cpp (100%) diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index 8e0119720a682..3a864e0b95e17 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -18,10 +18,12 @@ endif() set(SKIP_VERSIONING 1) include_directories(..) +include_directories(../../json) set(SOURCES ../bundle_marker.cpp ./hostfxr_iface.cpp + ./hostpolicy_resolver.cpp ) set(HEADERS diff --git a/src/installer/corehost/cli/fxr/static/hostpolicy_resolver.cpp b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/static/hostpolicy_resolver.cpp rename to src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt index 7b9305a482808..0a2ea92174b6f 100644 --- a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/shared/CMakeLists.txt @@ -15,6 +15,18 @@ set(SOURCES ./hostpolicy_resolver.cpp ) +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 +) + if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES hostfxr.def) @@ -39,18 +51,6 @@ else(CLR_CMAKE_TARGET_WIN32) endif(CLR_CMAKE_HOST_SUNOS) endif(CLR_CMAKE_TARGET_WIN32) -set(HEADERS - ../command_line.h - ../corehost_init.h - ../fx_muxer.h - ../fx_resolver.h - ../framework_info.h - ../host_context.h - ../hostpolicy_resolver.h - ../sdk_info.h - ../sdk_resolver.h -) - include(../../lib.cmake) if(CLR_CMAKE_HOST_UNIX) diff --git a/src/installer/corehost/cli/fxr/static/CMakeLists.txt b/src/installer/corehost/cli/fxr/static/CMakeLists.txt index 1f59bc0590504..16c0951c5b21b 100644 --- a/src/installer/corehost/cli/fxr/static/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/static/CMakeLists.txt @@ -22,7 +22,6 @@ set(SOURCES ../host_context.cpp ../sdk_info.cpp ../sdk_resolver.cpp - ./hostpolicy_resolver.cpp ) set(HEADERS @@ -42,4 +41,5 @@ set(HEADERS ) set(SKIP_VERSIONING 1) +set(BUILD_OBJECT_LIBRARY 1) include(../../lib_static.cmake) From d381ab47eeb56bca48c0ebc47fdf441c2f80c9f6 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 27 Apr 2020 11:24:45 -0700 Subject: [PATCH 12/22] Fix for win-x86 --- .../corehost/cli/apphost/static/hostpolicy_resolver.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp index 8bf2371988ba1..a01758f7a3395 100644 --- a/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp +++ b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp @@ -11,10 +11,10 @@ extern "C" { - int corehost_load(const host_interface_t* init); - int corehost_unload(); - corehost_error_writer_fn corehost_set_error_writer(corehost_error_writer_fn error_writer); - int corehost_initialize(const corehost_initialize_request_t *init_request, int32_t options, /*out*/ corehost_context_contract *context_contract); + int HOSTPOLICY_CALLTYPE corehost_load(const host_interface_t* init); + int HOSTPOLICY_CALLTYPE corehost_unload(); + corehost_error_writer_fn HOSTPOLICY_CALLTYPE corehost_set_error_writer(corehost_error_writer_fn error_writer); + int HOSTPOLICY_CALLTYPE corehost_initialize(const corehost_initialize_request_t *init_request, int32_t options, /*out*/ corehost_context_contract *context_contract); } int hostpolicy_resolver::load( From 50d6cd6032bf5b48322b9c86988d99a82d5b48ae Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 27 Apr 2020 11:29:03 -0700 Subject: [PATCH 13/22] move HEADERS next to SOURCES similarly to other files. --- .../corehost/cli/hostpolicy/shared/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt index 41cb9d96275c6..d6631543f81b5 100644 --- a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt @@ -18,6 +18,9 @@ set(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp ) +set(HEADERS +) + if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES hostpolicy.def) @@ -42,10 +45,6 @@ else(CLR_CMAKE_TARGET_WIN32) endif(CLR_CMAKE_HOST_SUNOS) endif(CLR_CMAKE_TARGET_WIN32) - -set(HEADERS -) - include(../../lib.cmake) if(CLR_CMAKE_HOST_UNIX) From b9cd86a978823e8134776dde7eebb12a33ad9525 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 27 Apr 2020 11:56:38 -0700 Subject: [PATCH 14/22] PR feedback (simplifying hostpolicy_resolver::try_get_dir for static host) --- .../apphost/static/hostpolicy_resolver.cpp | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp index a01758f7a3395..03d9242fcd67b 100644 --- a/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp +++ b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp @@ -46,35 +46,10 @@ bool hostpolicy_resolver::try_get_dir( const std::vector& probe_realpaths, pal::string_t* impl_dir) { - // Get the expected directory that would contain hostpolicy. - pal::string_t expected; - if (get_app(fx_definitions).get_runtime_config().get_is_framework_dependent()) - { - // The hostpolicy is required to be in the root framework's location - expected.assign(get_root_framework(fx_definitions).get_dir()); - assert(pal::directory_exists(expected)); - } - else - { - // Native apps can be activated by muxer, native exe host or "corehost" - // 1. When activated with dotnet.exe or corehost.exe, check for hostpolicy in the deps dir or - // app dir. - // 2. When activated with native exe, the standalone host, check own directory. - assert(mode != host_mode_t::invalid); - switch (mode) - { - case host_mode_t::apphost: - case host_mode_t::libhost: - expected = dotnet_root; - break; + // static apphost is not supposed to be used in a framework-dependent app + assert(!get_app(fx_definitions).get_runtime_config().get_is_framework_dependent()); + assert(mode == host_mode_t::apphost); - default: - expected = get_directory(specified_deps_file.empty() ? app_candidate : specified_deps_file); - break; - } - } - - // Assume the internal hostpolicy is in the expected location. - impl_dir->assign(expected); + impl_dir->assign(dotnet_root); return true; } From 433db236fe507220f2e98b5813f7ee1944aa0482 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 27 Apr 2020 14:24:26 -0700 Subject: [PATCH 15/22] Publish static_apphost to Microsoft.NETCore.App.Host --- eng/SignCheckExclusionsFile.txt | 1 + eng/Signing.props | 2 +- .../runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props | 1 + .../projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/SignCheckExclusionsFile.txt b/eng/SignCheckExclusionsFile.txt index 2db3b79a9339e..0e7fdf4e5d5c1 100644 --- a/eng/SignCheckExclusionsFile.txt +++ b/eng/SignCheckExclusionsFile.txt @@ -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 +*static_apphost.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 diff --git a/eng/Signing.props b/eng/Signing.props index 05f2a8bcb3957..421b7aeb0885f 100644 --- a/eng/Signing.props +++ b/eng/Signing.props @@ -24,7 +24,7 @@ - + diff --git a/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props b/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props index c74da91a0f25c..8dcfb2e3cbd86 100644 --- a/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props +++ b/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props @@ -2,6 +2,7 @@ + diff --git a/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj b/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj index 10915e8d504d4..e97e758be4dfa 100644 --- a/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj +++ b/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj @@ -15,6 +15,7 @@ --> + @@ -29,4 +30,4 @@ true - \ No newline at end of file + From 8e91d8957ae81fef3aaa781eba4e3d401f93bb85 Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 1 May 2020 15:09:26 -0700 Subject: [PATCH 16/22] bind to entry points without probing, when in a static host. --- .../apphost/static/hostpolicy_resolver.cpp | 4 ++ src/installer/corehost/cli/fxr/fx_muxer.cpp | 38 ++++++++++++------- .../corehost/cli/fxr/hostpolicy_resolver.h | 6 ++- .../cli/fxr/shared/hostpolicy_resolver.cpp | 3 ++ 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp index 03d9242fcd67b..0b2a35639a2e1 100644 --- a/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp +++ b/src/installer/corehost/cli/apphost/static/hostpolicy_resolver.cpp @@ -15,6 +15,8 @@ extern "C" int HOSTPOLICY_CALLTYPE corehost_unload(); corehost_error_writer_fn HOSTPOLICY_CALLTYPE corehost_set_error_writer(corehost_error_writer_fn error_writer); int HOSTPOLICY_CALLTYPE corehost_initialize(const corehost_initialize_request_t *init_request, int32_t options, /*out*/ corehost_context_contract *context_contract); + int HOSTPOLICY_CALLTYPE corehost_main(const int argc, const pal::char_t* argv[]); + int HOSTPOLICY_CALLTYPE corehost_main_with_output_buffer(const int argc, const pal::char_t* argv[], pal::char_t buffer[], int32_t buffer_size, int32_t* required_buffer_size); } int hostpolicy_resolver::load( @@ -30,6 +32,8 @@ int hostpolicy_resolver::load( contract.unload = corehost_unload; contract.set_error_writer = corehost_set_error_writer; contract.initialize = corehost_initialize; + contract.corehost_main = corehost_main; + contract.corehost_main_with_output_buffer = corehost_main_with_output_buffer; hostpolicy_contract = contract; *dll = nullptr; diff --git a/src/installer/corehost/cli/fxr/fx_muxer.cpp b/src/installer/corehost/cli/fxr/fx_muxer.cpp index 0357513f11407..f41e9095ef064 100644 --- a/src/installer/corehost/cli/fxr/fx_muxer.cpp +++ b/src/installer/corehost/cli/fxr/fx_muxer.cpp @@ -66,16 +66,11 @@ namespace } } -template int load_hostpolicy( const pal::string_t& lib_dir, pal::dll_t* h_host, - hostpolicy_contract_t &hostpolicy_contract, - const char *main_entry_symbol, - T* main_fn) + hostpolicy_contract_t& hostpolicy_contract) { - assert(main_entry_symbol != nullptr && main_fn != nullptr); - int rc = hostpolicy_resolver::load(lib_dir, h_host, hostpolicy_contract); if (rc != StatusCode::Success) { @@ -83,11 +78,6 @@ int load_hostpolicy( return rc; } - // Obtain entrypoint symbol - *main_fn = reinterpret_cast(pal::get_symbol(*h_host, main_entry_symbol)); - if (*main_fn == nullptr) - return StatusCode::CoreHostEntryPointFailure; - return StatusCode::Success; } @@ -114,7 +104,18 @@ static int execute_app( hostpolicy_contract_t hostpolicy_contract{}; corehost_main_fn host_main = nullptr; - int code = load_hostpolicy(impl_dll_dir, &hostpolicy_dll, hostpolicy_contract, "corehost_main", &host_main); + int code = load_hostpolicy(impl_dll_dir, &hostpolicy_dll, hostpolicy_contract); + + // Obtain entrypoint symbol + if (code == StatusCode::Success) + { + host_main = hostpolicy_contract.corehost_main; + if (host_main == nullptr) + { + code = StatusCode::CoreHostEntryPointFailure; + } + } + if (code != StatusCode::Success) { handle_initialize_failure_or_abort(); @@ -164,7 +165,18 @@ static int execute_host_command( hostpolicy_contract_t hostpolicy_contract{}; corehost_main_with_output_buffer_fn host_main = nullptr; - int code = load_hostpolicy(impl_dll_dir, &hostpolicy_dll, hostpolicy_contract, "corehost_main_with_output_buffer", &host_main); + int code = load_hostpolicy(impl_dll_dir, &hostpolicy_dll, hostpolicy_contract); + + // Obtain entrypoint symbol + if (code == StatusCode::Success) + { + host_main = hostpolicy_contract.corehost_main_with_output_buffer; + if (host_main == nullptr) + { + code = StatusCode::CoreHostEntryPointFailure; + } + } + if (code != StatusCode::Success) return code; diff --git a/src/installer/corehost/cli/fxr/hostpolicy_resolver.h b/src/installer/corehost/cli/fxr/hostpolicy_resolver.h index 4348a53c778e0..35128327b7bca 100644 --- a/src/installer/corehost/cli/fxr/hostpolicy_resolver.h +++ b/src/installer/corehost/cli/fxr/hostpolicy_resolver.h @@ -20,6 +20,10 @@ struct hostpolicy_contract_t // 3.0+ contracts corehost_set_error_writer_fn set_error_writer; corehost_initialize_fn initialize; + + // 5.0+ contracts + corehost_main_fn corehost_main; + corehost_main_with_output_buffer_fn corehost_main_with_output_buffer; }; namespace hostpolicy_resolver @@ -38,4 +42,4 @@ namespace hostpolicy_resolver pal::string_t* impl_dir); }; -#endif // __HOSTPOLICY_RESOLVER_H__ \ No newline at end of file +#endif // __HOSTPOLICY_RESOLVER_H__ diff --git a/src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp b/src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp index de3291fecc5b5..67881d207944f 100644 --- a/src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp +++ b/src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp @@ -198,6 +198,9 @@ int hostpolicy_resolver::load( g_hostpolicy_contract.set_error_writer = reinterpret_cast(pal::get_symbol(g_hostpolicy, "corehost_set_error_writer")); g_hostpolicy_contract.initialize = reinterpret_cast(pal::get_symbol(g_hostpolicy, "corehost_initialize")); + g_hostpolicy_contract.corehost_main = reinterpret_cast(pal::get_symbol(g_hostpolicy, "corehost_main")); + g_hostpolicy_contract.corehost_main_with_output_buffer = reinterpret_cast(pal::get_symbol(g_hostpolicy, "corehost_main_with_output_buffer")); + // It's possible to not have corehost_set_error_writer and corehost_initialize. These were // introduced in 3.0, so 2.0 hostpolicy would not have the exports. In this case, we will // not propagate the error writer and errors will still be reported to stderr. Callers are From 444cd0a09d2013b536e57c9d9b7a6fecfafb9c79 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Mon, 4 May 2020 16:22:40 -0700 Subject: [PATCH 17/22] Add a test case --- .../AppHost.Bundle.Tests/StaticHost.cs | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs new file mode 100644 index 0000000000000..e29440cbfbe33 --- /dev/null +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs @@ -0,0 +1,98 @@ +// 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. + +using BundleTests.Helpers; +using Microsoft.DotNet.Cli.Build.Framework; +using Microsoft.DotNet.CoreSetup.Test; +using Microsoft.NET.HostModel.AppHost; +using Microsoft.NET.HostModel.Bundle; +using System; +using System.IO; +using System.Threading; +using Xunit; + +namespace AppHost.Bundle.Tests +{ + public class StaticHost : IClassFixture + { + private SharedTestState sharedTestState; + + public StaticHost(SharedTestState fixture) + { + sharedTestState = fixture; + } + + // This helper is used in lieu of SDK support for publishing apps using the static_apphost. + // It replaces the apphost with static_apphost, and along with appropeiate app.dll updates in the host. + // For now, we heave behind the hostpolicy and hostfxr DLLs in the publish directory, because + // removing them requires deps.json update. + void ReplaceApphostWithStaticHost(TestProjectFixture fixture) + { + var staticHost = Path.Combine(fixture.RepoDirProvider.HostArtifacts, + RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("static_apphost")); + HostWriter.CreateAppHost(staticHost, + BundleHelper.GetHostPath(fixture), + BundleHelper.GetAppPath(fixture)); + + } + + [Fact] + private void Can_Run_App_With_StatiHost() + { + var fixture = sharedTestState.TestFixture.Copy(); + var appExe = BundleHelper.GetHostPath(fixture); + + ReplaceApphostWithStaticHost(fixture); + + Command.Create(appExe) + .CaptureStdErr() + .CaptureStdOut() + .Execute() + .Should() + .Pass() + .And + .HaveStdOutContaining("Hello World"); + } + + [Fact] + private void Can_Run_SingleFile_App_With_StatiHost() + { + var fixture = sharedTestState.TestFixture.Copy(); + + ReplaceApphostWithStaticHost(fixture); + + string singleFile = BundleHelper.BundleApp(fixture); + + Command.Create(singleFile) + .CaptureStdErr() + .CaptureStdOut() + .Execute() + .Should() + .Pass() + .And + .HaveStdOutContaining("Hello World"); + } + + public class SharedTestState : IDisposable + { + public TestProjectFixture TestFixture { get; set; } + public RepoDirectoriesProvider RepoDirectories { get; set; } + + public SharedTestState() + { + RepoDirectories = new RepoDirectoriesProvider(); + TestFixture = new TestProjectFixture("StandaloneApp", RepoDirectories); + TestFixture + .EnsureRestoredForRid(TestFixture.CurrentRid, RepoDirectories.CorehostPackages) + .PublishProject(runtime: TestFixture.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(TestFixture)); + } + + public void Dispose() + { + TestFixture.Dispose(); + } + } + } +} From 818f5c66a3da47fa042abb63f1745fdfb1f96b61 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 4 May 2020 19:58:17 -0700 Subject: [PATCH 18/22] renamed hostfxr_iface --> hostfxr_resolver_t --- .../corehost/cli/apphost/shared/CMakeLists.txt | 4 ++-- .../{hostfxr_iface.cpp => hostfxr_resolver_t.cpp} | 14 +++++++------- .../corehost/cli/apphost/static/CMakeLists.txt | 4 ++-- .../{hostfxr_iface.cpp => hostfxr_resolver_t.cpp} | 14 +++++++------- src/installer/corehost/cli/dotnet/CMakeLists.txt | 2 +- src/installer/corehost/cli/exe.cmake | 2 +- src/installer/corehost/corehost.cpp | 4 ++-- .../{hostfxr_iface.h => hostfxr_resolver_t.h} | 6 +++--- 8 files changed, 25 insertions(+), 25 deletions(-) rename src/installer/corehost/cli/apphost/shared/{hostfxr_iface.cpp => hostfxr_resolver_t.cpp} (79%) rename src/installer/corehost/cli/apphost/static/{hostfxr_iface.cpp => hostfxr_resolver_t.cpp} (79%) rename src/installer/corehost/{hostfxr_iface.h => hostfxr_resolver_t.h} (90%) diff --git a/src/installer/corehost/cli/apphost/shared/CMakeLists.txt b/src/installer/corehost/cli/apphost/shared/CMakeLists.txt index e760a857b0eeb..60d9a103b12fb 100644 --- a/src/installer/corehost/cli/apphost/shared/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/shared/CMakeLists.txt @@ -21,12 +21,12 @@ include_directories(..) set(SOURCES ../bundle_marker.cpp - ./hostfxr_iface.cpp + ./hostfxr_resolver_t.cpp ) set(HEADERS ../bundle_marker.h - ../../../hostfxr_iface.h + ../../../hostfxr_resolver_t.h ) if(CLR_CMAKE_TARGET_WIN32) diff --git a/src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp b/src/installer/corehost/cli/apphost/shared/hostfxr_resolver_t.cpp similarity index 79% rename from src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp rename to src/installer/corehost/cli/apphost/shared/hostfxr_resolver_t.cpp index 044d3bf831a1d..4f3c3888428c5 100644 --- a/src/installer/corehost/cli/apphost/shared/hostfxr_iface.cpp +++ b/src/installer/corehost/cli/apphost/shared/hostfxr_resolver_t.cpp @@ -7,33 +7,33 @@ #include "pal.h" #include "fxr_resolver.h" #include "trace.h" -#include "hostfxr_iface.h" +#include "hostfxr_resolver_t.h" -hostfxr_main_bundle_startupinfo_fn hostfxr::resolve_main_bundle_startupinfo() +hostfxr_main_bundle_startupinfo_fn hostfxr_resolver_t::resolve_main_bundle_startupinfo() { assert(m_hostfxr_dll != nullptr); return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_bundle_startupinfo")); } -hostfxr_set_error_writer_fn hostfxr::resolve_set_error_writer() +hostfxr_set_error_writer_fn hostfxr_resolver_t::resolve_set_error_writer() { assert(m_hostfxr_dll != nullptr); return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_set_error_writer")); } -hostfxr_main_startupinfo_fn hostfxr::resolve_main_startupinfo() +hostfxr_main_startupinfo_fn hostfxr_resolver_t::resolve_main_startupinfo() { assert(m_hostfxr_dll != nullptr); return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_main_startupinfo")); } -hostfxr_main_fn hostfxr::resolve_main_v1() +hostfxr_main_fn hostfxr_resolver_t::resolve_main_v1() { assert(m_hostfxr_dll != nullptr); return reinterpret_cast(pal::get_symbol(m_hostfxr_dll, "hostfxr_main")); } -hostfxr::hostfxr(const pal::string_t& app_root) +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)) { @@ -52,7 +52,7 @@ hostfxr::hostfxr(const pal::string_t& app_root) } } -hostfxr::~hostfxr() +hostfxr_resolver_t::~hostfxr_resolver_t() { if (m_hostfxr_dll != nullptr) { diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index 3a864e0b95e17..31cbcc9397b54 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -22,13 +22,13 @@ include_directories(../../json) set(SOURCES ../bundle_marker.cpp - ./hostfxr_iface.cpp + ./hostfxr_resolver_t.cpp ./hostpolicy_resolver.cpp ) set(HEADERS ../bundle_marker.h - ../../../hostfxr_iface.h + ../../../hostfxr_resolver_t.h ) if(CLR_CMAKE_TARGET_WIN32) diff --git a/src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp b/src/installer/corehost/cli/apphost/static/hostfxr_resolver_t.cpp similarity index 79% rename from src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp rename to src/installer/corehost/cli/apphost/static/hostfxr_resolver_t.cpp index 83dfa626aa98f..2c7e2b87a5f6d 100644 --- a/src/installer/corehost/cli/apphost/static/hostfxr_iface.cpp +++ b/src/installer/corehost/cli/apphost/static/hostfxr_resolver_t.cpp @@ -5,7 +5,7 @@ #include #include "trace.h" #include "hostfxr.h" -#include "hostfxr_iface.h" +#include "hostfxr_resolver_t.h" extern "C" { @@ -15,32 +15,32 @@ extern "C" hostfxr_error_writer_fn HOSTFXR_CALLTYPE hostfxr_set_error_writer(hostfxr_error_writer_fn error_writer); } -hostfxr_main_bundle_startupinfo_fn hostfxr::resolve_main_bundle_startupinfo() +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::resolve_set_error_writer() +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::resolve_main_startupinfo() +hostfxr_main_startupinfo_fn hostfxr_resolver_t::resolve_main_startupinfo() { assert(m_hostfxr_dll == nullptr); return hostfxr_main_startupinfo; } -hostfxr_main_fn hostfxr::resolve_main_v1() +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::hostfxr(const pal::string_t& app_root) +hostfxr_resolver_t::hostfxr_resolver_t(const pal::string_t& app_root) { if (app_root.length() == 0) { @@ -58,6 +58,6 @@ hostfxr::hostfxr(const pal::string_t& app_root) } } -hostfxr::~hostfxr() +hostfxr_resolver_t::~hostfxr_resolver_t() { } diff --git a/src/installer/corehost/cli/dotnet/CMakeLists.txt b/src/installer/corehost/cli/dotnet/CMakeLists.txt index 8bf75e8cff873..be9e973199bcb 100644 --- a/src/installer/corehost/cli/dotnet/CMakeLists.txt +++ b/src/installer/corehost/cli/dotnet/CMakeLists.txt @@ -11,7 +11,7 @@ if(CLR_CMAKE_TARGET_WIN32) endif() list(APPEND SOURCES - ../apphost/shared/hostfxr_iface.cpp + ../apphost/shared/hostfxr_resolver_t.cpp ) include(../exe.cmake) diff --git a/src/installer/corehost/cli/exe.cmake b/src/installer/corehost/cli/exe.cmake index 920f332a662a3..3acc130174aa3 100644 --- a/src/installer/corehost/cli/exe.cmake +++ b/src/installer/corehost/cli/exe.cmake @@ -19,7 +19,7 @@ list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/../corehost.cpp ) list(APPEND HEADERS - ${CMAKE_CURRENT_LIST_DIR}/../hostfxr_iface.h + ${CMAKE_CURRENT_LIST_DIR}/../hostfxr_resolver_t.h ) add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES}) diff --git a/src/installer/corehost/corehost.cpp b/src/installer/corehost/corehost.cpp index bd73110e837f2..65cfb61f3ac64 100644 --- a/src/installer/corehost/corehost.cpp +++ b/src/installer/corehost/corehost.cpp @@ -9,7 +9,7 @@ #include "fx_ver.h" #include "trace.h" #include "utils.h" -#include "hostfxr_iface.h" +#include "hostfxr_resolver_t.h" #if defined(FEATURE_APPHOST) #include "bundle_marker.h" @@ -177,7 +177,7 @@ int exe_start(const int argc, const pal::char_t* argv[]) app_path.append(_X(".dll")); #endif - hostfxr fxr{app_root}; + hostfxr_resolver_t fxr{app_root}; // Obtain the entrypoints. int rc = fxr.status_code(); diff --git a/src/installer/corehost/hostfxr_iface.h b/src/installer/corehost/hostfxr_resolver_t.h similarity index 90% rename from src/installer/corehost/hostfxr_iface.h rename to src/installer/corehost/hostfxr_resolver_t.h index 93acb8fef201c..e4464c931e05c 100644 --- a/src/installer/corehost/hostfxr_iface.h +++ b/src/installer/corehost/hostfxr_resolver_t.h @@ -9,11 +9,11 @@ #include "pal.h" #include "error_codes.h" -class hostfxr +class hostfxr_resolver_t { public: - hostfxr(const pal::string_t& app_root); - ~hostfxr(); + hostfxr_resolver_t(const pal::string_t& app_root); + ~hostfxr_resolver_t(); StatusCode status_code() const { return m_status_code; } From d95d0cabbfed96b9693d51e9fa07cd359205a59c Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 4 May 2020 21:41:19 -0700 Subject: [PATCH 19/22] renamed shared --> standalone --- src/installer/corehost/cli/apphost/CMakeLists.txt | 2 +- .../corehost/cli/apphost/{shared => standalone}/CMakeLists.txt | 0 .../cli/apphost/{shared => standalone}/hostfxr_resolver_t.cpp | 0 src/installer/corehost/cli/dotnet/CMakeLists.txt | 2 +- src/installer/corehost/cli/fxr/CMakeLists.txt | 2 +- .../corehost/cli/fxr/{shared => standalone}/CMakeLists.txt | 0 .../corehost/cli/fxr/{shared => standalone}/hostfxr.def | 0 .../cli/fxr/{shared => standalone}/hostfxr_unixexports.src | 0 .../cli/fxr/{shared => standalone}/hostpolicy_resolver.cpp | 0 src/installer/corehost/cli/hostpolicy/CMakeLists.txt | 2 +- .../cli/hostpolicy/{shared => standalone}/CMakeLists.txt | 0 .../cli/hostpolicy/{shared => standalone}/hostpolicy.def | 0 .../{shared => standalone}/hostpolicy_unixexports.src | 0 13 files changed, 4 insertions(+), 4 deletions(-) rename src/installer/corehost/cli/apphost/{shared => standalone}/CMakeLists.txt (100%) rename src/installer/corehost/cli/apphost/{shared => standalone}/hostfxr_resolver_t.cpp (100%) rename src/installer/corehost/cli/fxr/{shared => standalone}/CMakeLists.txt (100%) rename src/installer/corehost/cli/fxr/{shared => standalone}/hostfxr.def (100%) rename src/installer/corehost/cli/fxr/{shared => standalone}/hostfxr_unixexports.src (100%) rename src/installer/corehost/cli/fxr/{shared => standalone}/hostpolicy_resolver.cpp (100%) rename src/installer/corehost/cli/hostpolicy/{shared => standalone}/CMakeLists.txt (100%) rename src/installer/corehost/cli/hostpolicy/{shared => standalone}/hostpolicy.def (100%) rename src/installer/corehost/cli/hostpolicy/{shared => standalone}/hostpolicy_unixexports.src (100%) diff --git a/src/installer/corehost/cli/apphost/CMakeLists.txt b/src/installer/corehost/cli/apphost/CMakeLists.txt index 886c9c33d996b..ec7e8e3e2ce4b 100644 --- a/src/installer/corehost/cli/apphost/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/CMakeLists.txt @@ -3,4 +3,4 @@ # See the LICENSE file in the project root for more information. add_subdirectory(static) -add_subdirectory(shared) +add_subdirectory(standalone) diff --git a/src/installer/corehost/cli/apphost/shared/CMakeLists.txt b/src/installer/corehost/cli/apphost/standalone/CMakeLists.txt similarity index 100% rename from src/installer/corehost/cli/apphost/shared/CMakeLists.txt rename to src/installer/corehost/cli/apphost/standalone/CMakeLists.txt diff --git a/src/installer/corehost/cli/apphost/shared/hostfxr_resolver_t.cpp b/src/installer/corehost/cli/apphost/standalone/hostfxr_resolver_t.cpp similarity index 100% rename from src/installer/corehost/cli/apphost/shared/hostfxr_resolver_t.cpp rename to src/installer/corehost/cli/apphost/standalone/hostfxr_resolver_t.cpp diff --git a/src/installer/corehost/cli/dotnet/CMakeLists.txt b/src/installer/corehost/cli/dotnet/CMakeLists.txt index be9e973199bcb..798ae4030ea0a 100644 --- a/src/installer/corehost/cli/dotnet/CMakeLists.txt +++ b/src/installer/corehost/cli/dotnet/CMakeLists.txt @@ -11,7 +11,7 @@ if(CLR_CMAKE_TARGET_WIN32) endif() list(APPEND SOURCES - ../apphost/shared/hostfxr_resolver_t.cpp + ../apphost/standalone/hostfxr_resolver_t.cpp ) include(../exe.cmake) diff --git a/src/installer/corehost/cli/fxr/CMakeLists.txt b/src/installer/corehost/cli/fxr/CMakeLists.txt index 886c9c33d996b..ec7e8e3e2ce4b 100644 --- a/src/installer/corehost/cli/fxr/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/CMakeLists.txt @@ -3,4 +3,4 @@ # See the LICENSE file in the project root for more information. add_subdirectory(static) -add_subdirectory(shared) +add_subdirectory(standalone) diff --git a/src/installer/corehost/cli/fxr/shared/CMakeLists.txt b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt similarity index 100% rename from src/installer/corehost/cli/fxr/shared/CMakeLists.txt rename to src/installer/corehost/cli/fxr/standalone/CMakeLists.txt diff --git a/src/installer/corehost/cli/fxr/shared/hostfxr.def b/src/installer/corehost/cli/fxr/standalone/hostfxr.def similarity index 100% rename from src/installer/corehost/cli/fxr/shared/hostfxr.def rename to src/installer/corehost/cli/fxr/standalone/hostfxr.def diff --git a/src/installer/corehost/cli/fxr/shared/hostfxr_unixexports.src b/src/installer/corehost/cli/fxr/standalone/hostfxr_unixexports.src similarity index 100% rename from src/installer/corehost/cli/fxr/shared/hostfxr_unixexports.src rename to src/installer/corehost/cli/fxr/standalone/hostfxr_unixexports.src diff --git a/src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp b/src/installer/corehost/cli/fxr/standalone/hostpolicy_resolver.cpp similarity index 100% rename from src/installer/corehost/cli/fxr/shared/hostpolicy_resolver.cpp rename to src/installer/corehost/cli/fxr/standalone/hostpolicy_resolver.cpp diff --git a/src/installer/corehost/cli/hostpolicy/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/CMakeLists.txt index 2070410114828..ec7e8e3e2ce4b 100644 --- a/src/installer/corehost/cli/hostpolicy/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/CMakeLists.txt @@ -3,4 +3,4 @@ # See the LICENSE file in the project root for more information. add_subdirectory(static) -add_subdirectory(shared) \ No newline at end of file +add_subdirectory(standalone) diff --git a/src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt similarity index 100% rename from src/installer/corehost/cli/hostpolicy/shared/CMakeLists.txt rename to src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt diff --git a/src/installer/corehost/cli/hostpolicy/shared/hostpolicy.def b/src/installer/corehost/cli/hostpolicy/standalone/hostpolicy.def similarity index 100% rename from src/installer/corehost/cli/hostpolicy/shared/hostpolicy.def rename to src/installer/corehost/cli/hostpolicy/standalone/hostpolicy.def diff --git a/src/installer/corehost/cli/hostpolicy/shared/hostpolicy_unixexports.src b/src/installer/corehost/cli/hostpolicy/standalone/hostpolicy_unixexports.src similarity index 100% rename from src/installer/corehost/cli/hostpolicy/shared/hostpolicy_unixexports.src rename to src/installer/corehost/cli/hostpolicy/standalone/hostpolicy_unixexports.src From 67cf394ad77a1a0df8e1843e68793edad005f884 Mon Sep 17 00:00:00 2001 From: vsadov Date: Tue, 5 May 2020 12:22:14 -0700 Subject: [PATCH 20/22] rename static_apphost --> singlefilehost --- src/installer/corehost/cli/apphost/static/CMakeLists.txt | 8 ++++---- src/installer/corehost/hostfxr_resolver_t.h | 6 +++--- ...ntime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props | 2 +- .../netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj | 2 +- .../AppHost.Bundle.Tests/StaticHost.cs | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index 31cbcc9397b54..967aebb24133a 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -2,8 +2,8 @@ # The .NET Foundation licenses this file to you under the MIT license. # See the LICENSE file in the project root for more information. -project(static_apphost) -set(DOTNET_PROJECT_NAME "static_apphost") +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 @@ -53,10 +53,10 @@ 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(static_apphost Advapi32.lib shell32.lib) + target_link_libraries(singlefilehost Advapi32.lib shell32.lib) endif() -target_link_libraries(static_apphost +target_link_libraries(singlefilehost libhostfxr_static libhostpolicy_static libhostcommon diff --git a/src/installer/corehost/hostfxr_resolver_t.h b/src/installer/corehost/hostfxr_resolver_t.h index e4464c931e05c..21047b56a3c89 100644 --- a/src/installer/corehost/hostfxr_resolver_t.h +++ b/src/installer/corehost/hostfxr_resolver_t.h @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#ifndef __HOSTFXR_IFACE_H__ -#define __HOSTFXR_IFACE_H__ +#ifndef __HOSTFXR_RESOLVER_T_H__ +#define __HOSTFXR_RESOLVER_T_H__ #include "hostfxr.h" #include "pal.h" @@ -37,4 +37,4 @@ class hostfxr_resolver_t StatusCode m_status_code; }; -#endif // __HOSTFXR_IFACE_H__ +#endif // __HOSTFXR_RESOLVER_T_H__ diff --git a/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props b/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props index 8dcfb2e3cbd86..6d52e1984f8ce 100644 --- a/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props +++ b/src/installer/pkg/projects/Microsoft.NETCore.DotNetAppHost/runtime.Windows_NT.Microsoft.NETCore.DotNetAppHost.props @@ -2,7 +2,7 @@ - + diff --git a/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj b/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj index e97e758be4dfa..8daa78d3ec711 100644 --- a/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj +++ b/src/installer/pkg/projects/netcoreapp/pkg/Microsoft.NETCore.App.Host.pkgproj @@ -15,7 +15,7 @@ --> - + diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs index e29440cbfbe33..dd91a1dc65baa 100644 --- a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs @@ -23,14 +23,14 @@ public StaticHost(SharedTestState fixture) sharedTestState = fixture; } - // This helper is used in lieu of SDK support for publishing apps using the static_apphost. - // It replaces the apphost with static_apphost, and along with appropeiate app.dll updates in the host. + // This helper is used in lieu of SDK support for publishing apps using the singlefilehost. + // It replaces the apphost with singlefilehost, and along with appropeiate app.dll updates in the host. // For now, we heave behind the hostpolicy and hostfxr DLLs in the publish directory, because // removing them requires deps.json update. void ReplaceApphostWithStaticHost(TestProjectFixture fixture) { var staticHost = Path.Combine(fixture.RepoDirProvider.HostArtifacts, - RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("static_apphost")); + RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("singlefilehost")); HostWriter.CreateAppHost(staticHost, BundleHelper.GetHostPath(fixture), BundleHelper.GetAppPath(fixture)); From eb30f92bb6aee5c811a9299ee5bc917d8a94cf96 Mon Sep 17 00:00:00 2001 From: vsadov Date: Tue, 5 May 2020 12:37:12 -0700 Subject: [PATCH 21/22] Signing exclusions for singlefilehost --- eng/SignCheckExclusionsFile.txt | 2 +- eng/Signing.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/SignCheckExclusionsFile.txt b/eng/SignCheckExclusionsFile.txt index 0e7fdf4e5d5c1..a78ad401525dd 100644 --- a/eng/SignCheckExclusionsFile.txt +++ b/eng/SignCheckExclusionsFile.txt @@ -7,7 +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 -*static_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 diff --git a/eng/Signing.props b/eng/Signing.props index 421b7aeb0885f..5ceb96ac54bf9 100644 --- a/eng/Signing.props +++ b/eng/Signing.props @@ -24,7 +24,7 @@ - + From 8669c80550de4399262e3937a06fa5f55abbb56a Mon Sep 17 00:00:00 2001 From: vsadov Date: Tue, 5 May 2020 12:51:20 -0700 Subject: [PATCH 22/22] switched StaticHost tst to a different asset (mostly a copy of StandaloneApp) --- .../Assets/TestProjects/StaticHostApp/Program.cs | 16 ++++++++++++++++ .../StaticHostApp/StaticHostApp.csproj | 13 +++++++++++++ .../AppHost.Bundle.Tests/StaticHost.cs | 6 +++--- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/installer/test/Assets/TestProjects/StaticHostApp/Program.cs create mode 100644 src/installer/test/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj diff --git a/src/installer/test/Assets/TestProjects/StaticHostApp/Program.cs b/src/installer/test/Assets/TestProjects/StaticHostApp/Program.cs new file mode 100644 index 0000000000000..c631d81d54048 --- /dev/null +++ b/src/installer/test/Assets/TestProjects/StaticHostApp/Program.cs @@ -0,0 +1,16 @@ +// 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. + +using System; + +namespace StaticHostApp +{ + public static class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/src/installer/test/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj b/src/installer/test/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj new file mode 100644 index 0000000000000..eff31e8532b40 --- /dev/null +++ b/src/installer/test/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj @@ -0,0 +1,13 @@ + + + + $(NETCoreAppFramework) + Exe + $(TestTargetRid) + $(MNAVersion) + + + + + + diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs index dd91a1dc65baa..78b5c9449fe1b 100644 --- a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs @@ -24,8 +24,8 @@ public StaticHost(SharedTestState fixture) } // This helper is used in lieu of SDK support for publishing apps using the singlefilehost. - // It replaces the apphost with singlefilehost, and along with appropeiate app.dll updates in the host. - // For now, we heave behind the hostpolicy and hostfxr DLLs in the publish directory, because + // It replaces the apphost with singlefilehost, and along with appropriate app.dll updates in the host. + // For now, we leave behind the hostpolicy and hostfxr DLLs in the publish directory, because // removing them requires deps.json update. void ReplaceApphostWithStaticHost(TestProjectFixture fixture) { @@ -82,7 +82,7 @@ public class SharedTestState : IDisposable public SharedTestState() { RepoDirectories = new RepoDirectoriesProvider(); - TestFixture = new TestProjectFixture("StandaloneApp", RepoDirectories); + TestFixture = new TestProjectFixture("StaticHostApp", RepoDirectories); TestFixture .EnsureRestoredForRid(TestFixture.CurrentRid, RepoDirectories.CorehostPackages) .PublishProject(runtime: TestFixture.CurrentRid,