Skip to content

Disable LTCG for the nethost's minipal_objects#130658

Merged
elinor-fung merged 1 commit into
dotnet:mainfrom
elinor-fung:host-minipal-disable-ltcg
Jul 14, 2026
Merged

Disable LTCG for the nethost's minipal_objects#130658
elinor-fung merged 1 commit into
dotnet:mainfrom
elinor-fung:host-minipal-disable-ltcg

Conversation

@elinor-fung

@elinor-fung elinor-fung commented Jul 14, 2026

Copy link
Copy Markdown
Member

libnethost is shipped as static libraries for external consumption. With #128420, it now includes minipal_objects, which was compiled with LTCG, producing object files that non-MSVC linkers such as lld-link reject with "is not a native COFF file".

Disable interprocedural optimization on the host's copy of minipal_objects. This mirrors the existing LTCG-disabling on libnethost itself (#71056).

cc @dotnet/appmodel @AaronRobinsonMSFT

libnethost.lib and libhostfxr.lib are shipped as static libraries for
external consumption. minipal_objects is embedded into them but was
compiled with LTCG (/GL), producing object files that non-MSVC linkers
such as lld-link reject with "is not a native COFF file".

Disable interprocedural optimization on the host's copy of
minipal_objects so the shipped static libraries remain consumable by a
variety of toolchains. This mirrors the existing LTCG-disabling on
libnethost/libhostfxr themselves and does not affect other consumers of
the shared minipal build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 45e02cdb-c6a2-4e6a-b749-379d4f1600b5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CoreHost CMake build so that minipal_objects is built without interprocedural optimization. This prevents the resulting libnethost / libhostfxr static libraries (which now embed minipal_objects) from containing LTCG/LTO-compiled objects that some non-MSVC linkers (e.g., lld-link) reject.

Changes:

  • Disable INTERPROCEDURAL_OPTIMIZATION on the minipal_objects target after adding the minipal subdirectory.
Show a summary per file
File Description
src/native/corehost/CMakeLists.txt Disables IPO/LTCG on minipal_objects so shipped static libraries remain consumable by non-MSVC linkers.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@MichalStrehovsky

Copy link
Copy Markdown
Member

We have a similar requirement for native-AOT shipped libraries and eng system refactors have broken this a couple times in the past. We now test for it in the CI: #111651. Not blocking, but this could probably be tested too.

@elinor-fung

Copy link
Copy Markdown
Member Author

We have a similar requirement for native-AOT shipped libraries and eng system refactors have broken this a couple times in the past. We now test for it in the CI: #111651. Not blocking, but this could probably be tested too.

Thanks! I wasn't sure what a good way to test this was. I'll look into something similar as a follow-up.

@elinor-fung

Copy link
Copy Markdown
Member Author

/ba-g #130678

@elinor-fung elinor-fung merged commit 48291d4 into dotnet:main Jul 14, 2026
173 of 180 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants