Description
BEGIN_ILLINK_FEATURE_SWITCH
/END_ILLINK_FEATURE_SWITCH
were added to corelib.h to allow trimming of classes that are only used by the runtime when a specific feature switch is enabled/disabled.
runtime/src/coreclr/vm/corelib.h
Lines 72 to 83 in e0024e2
In checked/debug, the runtime does a consistency check between corelib and the runtime based on what was defined in corelib.h
runtime/src/coreclr/vm/appdomain.cpp
Lines 1536 to 1541 in e0024e2
With the usage of *_ILLINK_FEATURE_SWITCH
, some of these items can now be trimmed away, but the consistency check doesn't handle that possibility. As a result, running a trimmed app on on checked/debug runtime fails.
Currently, System.Runtime.InteropServices.BuiltInComInterop.IsSupported
is the only switch that uses this mechanism. One way to repro is to build/run one of the TrimmingTests in libraries (with that feature switch disabled) against a checked/debug coreclr, which results in something like:
Assert failure(PID 324 [0x00000144], Thread: 22480 [0x57d0]): pFD != NULL
CORECLR! CoreLibBinder::Check + 0x4D1 (0x00007ff9`5fcff9a1)
CORECLR! SystemDomain::LoadBaseSystemClasses + 0x5B8 (0x00007ff9`5fcb3748)
CORECLR! SystemDomain::Init + 0x3FE (0x00007ff9`5fcad48e)
CORECLR! EEStartupHelper + 0xCA3 (0x00007ff9`60a74f43)
CORECLR! `EEStartup'::`9'::__Body::Run + 0x59 (0x00007ff9`60a77fb9)
CORECLR! EEStartup + 0x85 (0x00007ff9`60a74215)
CORECLR! EnsureEEStarted + 0x221 (0x00007ff9`60a753a1)
CORECLR! CorHost2::Start + 0x1D0 (0x00007ff9`5fe008b0)
CORECLR! coreclr_initialize + 0x341 (0x00007ff9`60a82a11)
HOSTPOLICY! <no symbol> + 0x0 (0x00007ff9`c3363c57)
File: C:\repos\runtime\src\coreclr\vm\binder.cpp Line: 573
Image: C:\repos\runtime\artifacts\bin\trimmingTests\projects\System.Runtime.TrimmingTests\TypeBuilderComDisabled\win-x64\bin\Release\net6.0\win-x64\publish\project.exe
cc @LakshanF
Metadata
Metadata
Assignees
Labels
Type
Projects
Status