Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/native/corehost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ if(NOT CLR_CMAKE_TARGET_BROWSER)
# consumption (libnethost, libhostfxr), so LTCG must be disabled to ensure
# that non-MSVC toolchains can work with them.
set_target_properties(minipal_objects PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
if (MSVC)
# Embed debug info in the object files (/Z7). CMake does not assign a
# compile PDB to OBJECT libraries, so the objects archived into the shipped
# libnethost/libhostfxr would otherwise reference an absent vc140.pdb,
# producing LNK4099 for consumers.
set_target_properties(minipal_objects PROPERTIES MSVC_DEBUG_INFORMATION_FORMAT Embedded)
endif()

add_subdirectory(hostcommon)
add_subdirectory(hostmisc)
Expand Down
12 changes: 12 additions & 0 deletions src/native/corehost/hostmisc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ if(NOT CLR_CMAKE_TARGET_BROWSER)
target_link_libraries(hostmisc_public PUBLIC minipal_objects)
endif()
set_target_properties(hostmisc_public PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
if (MSVC)
# Embed debug info in the object files (/Z7). CMake does not assign a compile
# PDB to OBJECT libraries, so the objects archived into the shipped libhostfxr
# would otherwise reference an absent vc140.pdb, producing LNK4099 for consumers.
set_target_properties(hostmisc_public PROPERTIES MSVC_DEBUG_INFORMATION_FORMAT Embedded)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the official way to do this? All the other places seem to pass /Z7 instead of this approach. Not sure which way is better, but it would be nice if they all looked the same.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to update the others? Perhaps in a follow up PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSVC_DEBUG_INFORMATION_FORMAT was introduced in cmake 3.25. Our minimum is 3.26 now, so we can use it. I'll update the others in a follow-up

endif()

add_library(hostmisc::public ALIAS hostmisc_public)

Expand All @@ -90,3 +96,9 @@ if(NOT CLR_CMAKE_TARGET_BROWSER)
target_link_libraries(hostmisc_c PUBLIC minipal_objects)
endif()
set_target_properties(hostmisc_c PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
if (MSVC)
# Embed debug info in the object files (/Z7). CMake does not assign a compile
# PDB to OBJECT libraries, so the objects archived into the shipped libnethost
# would otherwise reference an absent vc140.pdb, producing LNK4099 for consumers.
set_target_properties(hostmisc_c PROPERTIES MSVC_DEBUG_INFORMATION_FORMAT Embedded)
endif()
Loading