Embed debug info in host object libraries to avoid LNK4099#130933
Open
elinor-fung wants to merge 1 commit into
Open
Embed debug info in host object libraries to avoid LNK4099#130933elinor-fung wants to merge 1 commit into
elinor-fung wants to merge 1 commit into
Conversation
The object libraries embedded into the shipped libnethost.lib and
libhostfxr.lib (minipal_objects, hostmisc_c, hostmisc_public) were
compiled with /Zi, so their objects reference a build-time vc140.pdb
that is not shipped. Consumers linking these static libraries get
LNK4099 warnings ("cannot use debug info ... vc140.pdb: no such file").
Compile these object libraries with embedded debug info (/Z7) instead,
so the debug info travels inside the objects and no external PDB path is
referenced. COMPILE_PDB_NAME/INTERPROCEDURAL_OPTIMIZATION on the final
libnethost/libhostfxr targets don't propagate to linked object
libraries, so the setting must be applied to each object library.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 45e02cdb-c6a2-4e6a-b749-379d4f1600b5
| # 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) |
Member
There was a problem hiding this comment.
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.
Member
There was a problem hiding this comment.
Would you be able to update the others? Perhaps in a follow up PR.
Member
There was a problem hiding this comment.
Member
Author
There was a problem hiding this comment.
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
|
Azure Pipelines: Successfully started running 8 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. Some pipeline(s) encountered errors during trigger evaluation. |
AaronRobinsonMSFT
approved these changes
Jul 16, 2026
Copilot AI
added a commit
that referenced
this pull request
Jul 16, 2026
Per #130933 (comment), update places using /Z7 directly to use the CMake MSVC_DEBUG_INFORMATION_FORMAT target property (introduced in CMake 3.25; our minimum is now 3.26). Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
This was referenced Jul 17, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The object libraries embedded into the shipped libnethost.lib and libhostfxr.lib were referencing a vc140.pdb. Consumers linking these static libraries get LNK4099 warnings.
Compile these object libraries with embedded debug info (/Z7) instead. This matches what we do for NativeAOT Runtime.GC.* and for the cDAC descriptor.
cc @dotnet/appmodel @AaronRobinsonMSFT
Fixes #116527