Disable LTCG for the nethost's minipal_objects#130658
Conversation
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
There was a problem hiding this comment.
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_OPTIMIZATIONon theminipal_objectstarget after adding theminipalsubdirectory.
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
|
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. |
|
/ba-g #130678 |
libnethostis 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