Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFact
foreach (var map in _assemblyTypeMaps.Maps)
{
var groupType = map.Key;
if (map.Value.TargetModules.Count == 0)
continue; // No resolved targets; no entry will be emitted for this group

dependencies.Add(new DependencyListEntry(_importReferenceProvider.GetImportToType(groupType), "Type Map Assembly Target"));
foreach (var targetModule in map.Value.TargetModules)
{
Expand Down Expand Up @@ -60,6 +63,9 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
foreach (var map in _assemblyTypeMaps.Maps)
{
var groupType = map.Key;
if (map.Value.TargetModules.Count == 0)
continue; // No resolved targets; runtime will fall back to attribute processing

Vertex groupTypeVertex = _importReferenceProvider.EncodeReferenceToType(writer, groupType);
VertexSequence modules = new();
foreach (var targetModule in map.Value.TargetModules)
Expand Down
22 changes: 12 additions & 10 deletions src/coreclr/vm/assemblynative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1773,16 +1773,18 @@ extern "C" void QCALLTYPE TypeMapLazyDictionary_ProcessAttributes(
(newProxyTypeEntry != nullptr && !hasPrecachedProxy) ||
!hasPrecachedTargets)
{
// Only fall back to attribute parsing for the assembly targets if they were
// not found in the pre-cached R2R section.
if (!hasPrecachedTargets)
{
ProcessTypeMapAttribute(
TypeMapAssemblyTargetAttributeName,
assemblies,
groupTypeMT,
currAssembly);
}
// Re-process assembly target attributes whenever we are in fallback mode (i.e., any
// precached map is missing or invalid). This is needed because when CrossGen2 encounters
// an unresolvable assembly target, it still emits an assembly targets entry with count=0
// while also marking the type map as invalid via an exception stub. Without re-processing
// the assembly target attributes here, the count=0 precached entry would prevent the
// runtime from attempting to load the missing assembly, silently swallowing the error.
// AssemblyTargetProcessor deduplicates, so re-processing is safe.
ProcessTypeMapAttribute(
TypeMapAssemblyTargetAttributeName,
assemblies,
groupTypeMT,
currAssembly);

// We will only process the specific type maps if we have a callback to process
// the entry and the precached map was not calculated for this module.
Expand Down
Loading