Skip to content

Commit

Permalink
corehost: Build intermediate library to avoid building twice (dotnet#…
Browse files Browse the repository at this point in the history
…2123)

Some files are built twice in the hosting layer, so create two separate
static libraries that are then linked with all targets that need them.

Fixes [core-setup/8276](https://github.com/dotnet/core-setup/issues/8276).
  • Loading branch information
lpereira authored Feb 8, 2020
1 parent d9d4401 commit 9013928
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 111 deletions.
2 changes: 2 additions & 0 deletions src/installer/corehost/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(hostmisc)
add_subdirectory(hostcommon)
add_subdirectory(apphost)
add_subdirectory(dotnet)
add_subdirectory(fxr)
Expand Down
2 changes: 0 additions & 2 deletions src/installer/corehost/cli/apphost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ endif()
set(SKIP_VERSIONING 1)

set(SOURCES
../fxr/fx_ver.cpp
./bundle/file_entry.cpp
./bundle/manifest.cpp
./bundle/header.cpp
Expand All @@ -30,7 +29,6 @@ set(SOURCES
)

set(HEADERS
../fxr/fx_ver.h
./bundle/file_type.h
./bundle/file_entry.h
./bundle/manifest.h
Expand Down
5 changes: 1 addition & 4 deletions src/installer/corehost/cli/comhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ set(SOURCES
../fxr_resolver.cpp
clsidmap.cpp
../redirected_error_writer.cpp
../fxr/fx_ver.cpp
../json_parser.cpp
)

set(HEADERS
comhost.h
../fxr/fx_ver.h
../json_parser.h
)

if(CLR_CMAKE_TARGET_WIN32)
Expand All @@ -48,3 +44,4 @@ endif()

install(TARGETS comhost DESTINATION corehost)
install_symbols(comhost corehost)
target_link_libraries(comhost libhostcommon)
38 changes: 9 additions & 29 deletions src/installer/corehost/cli/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,7 @@ endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
include_directories(${CMAKE_CURRENT_LIST_DIR}/)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../)
include_directories(${CMAKE_CURRENT_LIST_DIR}/../common)

list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/../common/trace.cpp
${CMAKE_CURRENT_LIST_DIR}/../common/utils.cpp)

list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/../common/trace.h
${CMAKE_CURRENT_LIST_DIR}/../common/utils.h
${CMAKE_CURRENT_LIST_DIR}/../common/pal.h
${CMAKE_CURRENT_LIST_DIR}/../error_codes.h)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/../common/pal.windows.cpp
${CMAKE_CURRENT_LIST_DIR}/../common/longfile.windows.cpp)
list(APPEND HEADERS
${CMAKE_CURRENT_LIST_DIR}/../common/longfile.h)
else()
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/../common/pal.unix.cpp
${VERSION_FILE_PATH})
endif()
include_directories(${CMAKE_CURRENT_LIST_DIR}/hostmisc)

set(RESOURCES)
if(CLR_CMAKE_TARGET_WIN32 AND NOT SKIP_VERSIONING)
Expand All @@ -67,12 +45,14 @@ function(set_common_libs TargetType)
endif()
endif()

# Specify the import library to link against for Arm32 build since the default set is minimal
if (CLR_CMAKE_TARGET_ARCH_ARM)
if (CLR_CMAKE_TARGET_WIN32)
target_link_libraries(${DOTNET_PROJECT_NAME} shell32.lib)
else()
target_link_libraries(${DOTNET_PROJECT_NAME} atomic.a)
if (NOT ${TargetType} STREQUAL "lib-static")
# Specify the import library to link against for Arm32 build since the default set is minimal
if (CLR_CMAKE_TARGET_ARCH_ARM)
if (CLR_CMAKE_TARGET_WIN32)
target_link_libraries(${DOTNET_PROJECT_NAME} shell32.lib)
else()
target_link_libraries(${DOTNET_PROJECT_NAME} atomic.a)
endif()
endif()
endif()
endfunction()
8 changes: 0 additions & 8 deletions src/installer/corehost/cli/dotnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
project(dotnet)
set(DOTNET_PROJECT_NAME "dotnet")

set(SOURCES
../fxr/fx_ver.cpp
)

set(HEADERS
../fxr/fx_ver.h
)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
dotnet.manifest)
Expand Down
4 changes: 2 additions & 2 deletions src/installer/corehost/cli/exe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr)
list(APPEND SOURCES
${CMAKE_CURRENT_LIST_DIR}/fxr_resolver.cpp
${CMAKE_CURRENT_LIST_DIR}/../corehost.cpp
${CMAKE_CURRENT_LIST_DIR}/../common/trace.cpp
${CMAKE_CURRENT_LIST_DIR}/../common/utils.cpp)
)

add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES})
target_link_libraries(${DOTNET_PROJECT_NAME} libhostmisc)

if(NOT CLR_CMAKE_TARGET_WIN32)
disable_pax_mprotect(${DOTNET_PROJECT_NAME})
Expand Down
21 changes: 1 addition & 20 deletions src/installer/corehost/cli/fxr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,9 @@ include_directories(../json)

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
../deps_format.cpp
../deps_entry.cpp
../host_startup_info.cpp
../roll_forward_option.cpp
../runtime_config.cpp
../fx_definition.cpp
../fx_reference.cpp
../version.cpp
../version_compatibility_range.cpp
../json_parser.cpp
./command_line.cpp
./corehost_init.cpp
./hostfxr.cpp
./fx_ver.cpp
./fx_muxer.cpp
./fx_resolver.cpp
./fx_resolver.messages.cpp
Expand All @@ -37,21 +26,12 @@ set(SOURCES

set(HEADERS
../corehost_context_contract.h
../deps_format.h
../deps_entry.h
../host_startup_info.h
../hostpolicy.h
../runtime_config.h
../fx_definition.h
../fx_reference.h
../roll_forward_option.h
../roll_fwd_on_no_candidate_fx_option.h
../version.h
../version_compatibility_range.h
../json_parser.h
./command_line.h
./corehost_init.h
./fx_ver.h
./fx_muxer.h
./fx_resolver.h
./framework_info.h
Expand All @@ -65,3 +45,4 @@ include(../lib.cmake)

install(TARGETS hostfxr DESTINATION corehost)
install_symbols(hostfxr corehost)
target_link_libraries(hostfxr libhostcommon)
44 changes: 44 additions & 0 deletions src/installer/corehost/cli/hostcommon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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(hostcommon)

set(DOTNET_PROJECT_NAME "hostcommon")

# Include directories
include_directories(../fxr)
include_directories(../json)

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
../json_parser.cpp
../deps_format.cpp
../deps_entry.cpp
../host_startup_info.cpp
../roll_forward_option.cpp
../fx_definition.cpp
../fx_reference.cpp
../fxr/fx_ver.cpp
../version.cpp
../version_compatibility_range.cpp
../runtime_config.cpp
)

set(HEADERS
../json_parser.h
../deps_format.h
../deps_entry.h
../host_startup_info.h
../roll_forward_option.h
../fx_definition.h
../fx_reference.h
../fxr/fx_ver.h
../version.h
../version_compatibility_range.h
../runtime_config.h
)

set(SKIP_VERSIONING 1)
include(../lib_static.cmake)

38 changes: 38 additions & 0 deletions src/installer/corehost/cli/hostmisc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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(hostmisc)

set(DOTNET_PROJECT_NAME "hostmisc")

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
trace.cpp
utils.cpp
../fxr/fx_ver.cpp
)

set(HEADERS
trace.h
utils.h
pal.h
../../error_codes.h
../fxr/fx_ver.h
)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
pal.windows.cpp
longfile.windows.cpp)
list(APPEND HEADERS
longfile.h)
else()
list(APPEND SOURCES
pal.unix.cpp
${VERSION_FILE_PATH})
endif()

set(SKIP_VERSIONING 1)
include(../lib_static.cmake)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 4 additions & 24 deletions src/installer/corehost/cli/hostpolicy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,24 @@ set(SOURCES
./breadcrumbs.cpp
./coreclr.cpp
./deps_resolver.cpp
./hostpolicy.cpp
./hostpolicy_context.cpp
./hostpolicy.cpp
./hostpolicy_init.cpp
../roll_forward_option.cpp
../runtime_config.cpp
../fxr/fx_ver.cpp
../host_startup_info.cpp
../deps_format.cpp
../deps_entry.cpp
../fx_definition.cpp
../fx_reference.cpp
../version.cpp
../version_compatibility_range.cpp
../json_parser.cpp
)

set(HEADERS
./args.h
./breadcrumbs.h
./coreclr.h
../corehost_context_contract.h
./deps_resolver.h
./hostpolicy_context.h
./hostpolicy_init.h
../corehost_context_contract.h
../hostpolicy.h
../runtime_config.h
../fxr/fx_ver.h
../host_startup_info.h
../deps_format.h
../deps_entry.h
../fx_definition.h
../fx_reference.h
../version.h
../version_compatibility_range.h
../json_parser.h
./hostpolicy_init.h
)

include(../lib.cmake)

install(TARGETS hostpolicy DESTINATION corehost)
install_symbols(hostpolicy corehost)
target_link_libraries(hostpolicy libhostcommon)
3 changes: 0 additions & 3 deletions src/installer/corehost/cli/ijwhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ set(SOURCES
ijwthunk.cpp
ijwhost.cpp
../fxr_resolver.cpp
../../common/trace.cpp
../../common/utils.cpp
../fxr/fx_ver.cpp
pedecoder.cpp
bootstrap_thunk_chunk.cpp
${ARCH_SPECIFIC_FOLDER_NAME}/bootstrap_thunk.cpp
Expand Down
1 change: 1 addition & 0 deletions src/installer/corehost/cli/lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ add_definitions(-D_NO_PPLXIMP)
add_definitions(-DEXPORT_SHARED_API=1)

add_library(${DOTNET_PROJECT_NAME} SHARED ${SOURCES} ${RESOURCES})
target_link_libraries(${DOTNET_PROJECT_NAME} libhostmisc)

set_target_properties(${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE)

Expand Down
2 changes: 1 addition & 1 deletion src/installer/corehost/cli/lib_static.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ add_library(lib${DOTNET_PROJECT_NAME} STATIC ${SOURCES} ${RESOURCES})
set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE)
set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES PREFIX "")

set_common_libs("lib")
set_common_libs("lib-static")
1 change: 0 additions & 1 deletion src/installer/corehost/cli/nethost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ include_directories(../fxr)
set(SOURCES
nethost.cpp
../fxr_resolver.cpp
../fxr/fx_ver.cpp
)

if(CLR_CMAKE_TARGET_WIN32)
Expand Down
16 changes: 3 additions & 13 deletions src/installer/corehost/cli/test_fx_ver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,11 @@ project(test_fx_ver)
set(EXE_NAME "test_fx_ver")

include_directories(../fxr)
include_directories(../../common)
include_directories(../hostmisc)

set(SOURCES
test_fx_ver.cpp
../fxr/fx_ver.cpp
../../common/trace.cpp
../../common/utils.cpp)

if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
../../common/pal.windows.cpp
../../common/longfile.windows.cpp)
else()
list(APPEND SOURCES
../../common/pal.unix.cpp)
endif()
)

if(CLR_CMAKE_HOST_WIN32)
add_compile_options($<$<CONFIG:RelWithDebInfo>:/MT>)
Expand All @@ -32,6 +21,7 @@ else()
endif()

add_executable(${EXE_NAME} ${SOURCES})
target_link_libraries(${EXE_NAME} libhostmisc libhostcommon)

install(TARGETS ${EXE_NAME} DESTINATION corehost_test)

Expand Down
5 changes: 1 addition & 4 deletions src/installer/corehost/cli/winrthost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ set (SOURCES
winrthost.cpp
../redirected_error_writer.cpp
../fxr_resolver.cpp
../../common/trace.cpp
../../common/utils.cpp
../fxr/fx_ver.cpp
)

if(CLR_CMAKE_TARGET_WIN32)
Expand All @@ -33,7 +30,7 @@ if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_AR
target_link_libraries(winrthost Advapi32.lib Ole32.lib OleAut32.lib)
endif()

target_link_libraries(winrthost RuntimeObject.lib)
target_link_libraries(winrthost RuntimeObject.lib libhostmisc libhostcommon)

install(TARGETS winrthost DESTINATION corehost)
install_symbols(winrthost corehost)

0 comments on commit 9013928

Please sign in to comment.