Skip to content

Commit

Permalink
Possible fix for R2R failure on CI
Browse files Browse the repository at this point in the history
Improved exception message
  • Loading branch information
kg committed Sep 13, 2024
1 parent 399ae75 commit c444b83
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Reflection.Metadata;

namespace ILCompiler.Reflection.ReadyToRun
{
public interface IAssemblyResolver
{
IAssemblyMetadata FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile);
IAssemblyMetadata FindAssembly(string simpleName, string parentFile);
IAssemblyMetadata FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile, List<string> probedPaths = null);
IAssemblyMetadata FindAssembly(string simpleName, string parentFile, List<string> probedPaths = null);
}

public class SignatureFormattingOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ private void CountRuntimeFunctions(bool[] isEntryPoint, IDictionary<int, int[]>
count++;
i++;
} while (i < isEntryPoint.Length && !isEntryPoint[i] && i < firstColdRuntimeFunction);

if (dHotColdMap.ContainsKey(runtimeFunctionId))
{
int coldSize = dHotColdMap[runtimeFunctionId].Length;
Expand Down Expand Up @@ -1582,11 +1582,13 @@ internal IAssemblyMetadata OpenReferenceAssembly(int refAsmIndex)
}
else
{
result = _assemblyResolver.FindAssembly(metadataReader, assemblyReferenceHandle, Filename);
var probedPaths = new List<string>();
result = _assemblyResolver.FindAssembly(metadataReader, assemblyReferenceHandle, Filename, probedPaths);
if (result == null)
{
string name = metadataReader.GetString(metadataReader.GetAssemblyReference(assemblyReferenceHandle).Name);
throw new Exception($"Missing reference assembly: {name}");
string probedPathsList = string.Join(", ", probedPaths);
throw new Exception($"Missing reference assembly: {name}.\nPaths probed: {probedPathsList}");
}
}
while (_assemblyCache.Count <= refAsmIndex)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/dotnet-pgo/TraceTypeSystemContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ public MetadataStringDecoder GetMetadataStringDecoder()
return _metadataStringDecoder;
}

IAssemblyMetadata IAssemblyResolver.FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile)
IAssemblyMetadata IAssemblyResolver.FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile, List<string> probedPaths)
{
using var triggerErrors = new ModuleLoadLogger.LoadFailuresAsErrors();
EcmaAssembly ecmaAssembly = (EcmaAssembly)this.GetModuleForSimpleName(metadataReader.GetString(metadataReader.GetAssemblyReference(assemblyReferenceHandle).Name), false);
return new StandaloneAssemblyMetadata(ecmaAssembly.PEReader);
}

IAssemblyMetadata IAssemblyResolver.FindAssembly(string simpleName, string parentFile)
IAssemblyMetadata IAssemblyResolver.FindAssembly(string simpleName, string parentFile, List<string> probedPaths)
{
using var triggerErrors = new ModuleLoadLogger.LoadFailuresAsErrors();
EcmaAssembly ecmaAssembly = (EcmaAssembly)this.GetModuleForSimpleName(simpleName, false);
Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/tools/r2rdump/DumpModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ internal sealed class DumpModel : IAssemblyResolver
/// <param name="assemblyReferenceHandle">Handle representing the assembly reference</param>
/// <param name="parentFile">Name of assembly from which we're performing the lookup</param>
/// <returns></returns>
public IAssemblyMetadata FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile)
public IAssemblyMetadata FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile, List<string> probedPaths = null)
{
string simpleName = metadataReader.GetString(metadataReader.GetAssemblyReference(assemblyReferenceHandle).Name);
return FindAssembly(simpleName, parentFile);
return FindAssembly(simpleName, parentFile, probedPaths);
}

/// <summary>
Expand All @@ -58,7 +58,7 @@ public IAssemblyMetadata FindAssembly(MetadataReader metadataReader, AssemblyRef
/// <param name="simpleName">Simple name of the assembly to look up</param>
/// <param name="parentFile">Name of assembly from which we're performing the lookup</param>
/// <returns></returns>
public IAssemblyMetadata FindAssembly(string simpleName, string parentFile)
public IAssemblyMetadata FindAssembly(string simpleName, string parentFile, List<string> probedPaths = null)
{
foreach (string refAsm in Reference)
{
Expand All @@ -78,6 +78,7 @@ public IAssemblyMetadata FindAssembly(string simpleName, string parentFile)
try
{
string probeFile = Path.Combine(refPath, simpleName + extension);
probedPaths?.Add(probeFile);
if (File.Exists(probeFile))
{
return Open(probeFile);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/JIT/Intrinsics/BitCast.il
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.assembly extern System.Runtime {}
.assembly extern xunit.core {}
.assembly extern System.Console {}
.assembly Bitcast {}
.assembly BitCast {}

.class public abstract auto ansi sealed beforefieldinit Program
extends [System.Runtime]System.Object
Expand Down

0 comments on commit c444b83

Please sign in to comment.