Repository navigation
Add check that libnethost contains no LTCG objects - #130937
Merged
elinor-fung merged 2 commits intoJul 17, 2026
Merged
Conversation
libnethost is shipped as a static library for external consumption. Objects compiled with LTCG (/GL) are not native COFF and are rejected by non-MSVC linkers such as lld-link, so they must never be embedded into it. Add a CMake linker launcher on the existing nativehost_static test target that runs the real link and fails the build if MSVC reports "module compiled with /GL found". nativehost_static is linked with LTCG disabled (so MSVC surfaces the message) and against hostmisc_public (LTCG disabled) so libnethost is the only possible source of a /GL object in the link. Co-authored-by: Copilot <[email protected]> Copilot-Session: 61e02d3c-1880-44e5-9fa0-f9f3b4197ebb
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a build-time verification in the nativehost_static test link step to catch accidental inclusion of LTCG (/GL) objects when building libnethost on MSVC, by wrapping the linker invocation and failing if MSVC emits the “module compiled with /GL found” message.
Changes:
- Add a CMake linker-launcher script that runs the real link command and fails if MSVC reports LTCG objects were pulled in.
- Hook the launcher up to
nativehost_staticon MSVC and disable IPO for that test target to avoid self-inflicted /GL objects. - Switch
nativehost_staticfromhostmisctohostmisc_public(an OBJECT library with IPO disabled) to avoid pulling in LTCG-enabled objects fromhostmisc.
Show a summary per file
| File | Description |
|---|---|
| src/native/corehost/test/nativehost/run-linker-verify-no-ltcg.cmake | New linker launcher that inspects link output for the MSVC /GL restart message and fails the build. |
| src/native/corehost/test/nativehost/CMakeLists.txt | Wires the launcher into nativehost_static on MSVC and adjusts dependencies to avoid LTCG noise from hostmisc. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
elinor-fung
commented
Jul 17, 2026
Co-authored-by: Michal Strehovský <[email protected]> Co-authored-by: Elinor Fung <[email protected]>
MichalStrehovsky
approved these changes
Jul 17, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
We have ended up with LTCG objects in libnethost more than once. Add a CMake linker launcher on the existing
nativehost_statictest that runs the link and fails the build if MSVC reports "module compiled with /GL found" (similar to the output check in #111651).cc @dotnet/appmodel @AaronRobinsonMSFT