Skip to content

libnethost is built containing objects with /LTCG enabled #111788

@Windows10CE

Description

@Windows10CE

Description

nethost has this inside its build configuration:
https://github.com/dotnet/runtime/blob/main/src/native/corehost/nethost/CMakeLists.txt#L54-L60

fxr_resolver, which nethost depends on, also contains this:
https://github.com/dotnet/runtime/blob/main/src/native/corehost/fxr/staticlib/CMakeLists.txt#L39-L45

However, hostmisc, also bundled into nethost, does not strip /LTCG from its arguments, and builds with it enabled. This is then brought in as a dependency of nethost, causing nethost to not be able to be linked with any other linker than link.exe.

Reproduction Steps

Attempting to use lld-link to link nethost with anything should reproduce this, but I do not know if this is actually the case on Windows.

Expected behavior

nethost can be linked against using any linker, as seems to be the original intention.

Actual behavior

nethost fails to be linked against with other linkers, as they do not recognize the whole program opts information:

    lld-link : error : hostmisc\CMakeFiles\hostmisc.dir\trace.cpp.obj: is not a native COFF file. Recompile without /GL?
    lld-link : error : hostmisc\CMakeFiles\hostmisc.dir\utils.cpp.obj: is not a native COFF file. Recompile without /GL?
    lld-link : error : hostmisc\CMakeFiles\hostmisc.dir\pal.windows.cpp.obj: is not a native COFF file. Recompile without /GL?
    lld-link : error : hostmisc\CMakeFiles\hostmisc.dir\__\fxr\fx_ver.cpp.obj: is not a native COFF file. Recompile without /GL?

Regression?

Unsure.

Known Workarounds

Manually building nethost with the same /LTCG opt out in hostmisc/CMakeLists.txt causes things to work as intended again.

Configuration

  • .NET 9
  • Linking on Arch Linux, with lld-link

Other information

No response

Metadata

Metadata

Assignees

Labels

area-Hostin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions