Embed debug info in host object libraries to avoid LNK4099 - #130933
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
|
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. |
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>
|
Workflow state for the Holistic Review Orchestrator. {
"version": 5,
"last_dispatched_commit": "82aa71ce7a53ac714aacf4328f25e12ebb87110b",
"last_dispatched_base_ref": "main",
"last_dispatched_base_sha": "e0e5f8304a80337e9d9ce2f8696dce994b8335a8",
"last_reviewed_commit": "82aa71ce7a53ac714aacf4328f25e12ebb87110b",
"last_reviewed_base_ref": "main",
"last_reviewed_base_sha": "e0e5f8304a80337e9d9ce2f8696dce994b8335a8",
"last_recorded_worker_run_id": "29685649080",
"review_attempt_commit": "",
"review_attempt_base_ref": "",
"review_attempt_count": 0,
"max_review_attempts": 5,
"review_history_format": "holistic-review-disclosure-v1",
"review_history": [
{
"commit": "82aa71ce7a53ac714aacf4328f25e12ebb87110b",
"review_id": 4730701015
}
]
} |
There was a problem hiding this comment.
Holistic Review
Motivation: The object libraries (minipal_objects, hostmisc_public, hostmisc_c) archived into the shipped static libraries libnethost.lib and libhostfxr.lib referenced an external vc140.pdb. Because CMake does not assign a compile PDB to OBJECT libraries, consumers who link these static libraries get LNK4099 warnings for the absent PDB. This fixes #116527.
Approach: Set MSVC_DEBUG_INFORMATION_FORMAT Embedded (i.e. /Z7) on the three affected targets under an if (MSVC) guard, so debug info is embedded directly in the object files instead of referencing an external PDB. This mirrors the existing precedent in NativeAOT (src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt) and the cDAC descriptor, as noted in the PR description.
Summary: The change is minimal, correctly scoped to MSVC only, and well-commented explaining the rationale. The MSVC_DEBUG_INFORMATION_FORMAT abstract property is honored here because the repo sets CMAKE_MSVC_DEBUG_INFORMATION_FORMAT globally in eng/native/configurecompiler.cmake (activating CMP0141), and the minimum CMake version (3.26) supports the property. Embedded only affects the static/object outputs' debug format and does not regress the normal PDB generation for the final shared libraries, which are separate link targets. The three targets modified are exactly those documented as being archived into the shipped static libraries. No correctness, portability, or maintainability concerns. LGTM.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 41.3 AIC · ⌖ 14.4 AIC · ⊞ 10K
|
/ba-g failures were #130961 |
|
@dotnet-policy-service rerun |
Follow-up to #130933: convert the `/Z7` compile options on the CoreCLR cDAC data descriptor and NativeAOT GC OBJECT libraries to the `MSVC_DEBUG_INFORMATION_FORMAT Embedded` target property. The property (added in CMake 3.25) is usable now that the repo minimum is 3.26. Also remove setting `COMPILE_PDB_NAME` for the cDAC descriptor, since it is embedded rather than a separate PDB.
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