Skip to content

Commit e524be6

Browse files
Use a platform-neutral name for Microsoft.DiaSymReader.Native (#125165)
Fixes issues that we're running into when rebootstrapping the dotnet/dotnet build (dotnet/dotnet#5155 (comment)). `Microsoft.DiaSymReader.Native.(x86|x64|arm64).dll` clashes with the same name DLL in the runtime pack. Not having a suffix is simpler in the end.
1 parent 9515659 commit e524be6

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

src/coreclr/scripts/superpmi_collect_setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
"KernelTraceControl.Win61.dll",
163163
"llvm-mca.exe",
164164
"mcs.exe",
165+
"Microsoft.DiaSymReader.Native.dll",
165166
"Microsoft.DiaSymReader.Native.amd64.dll",
166167
"Microsoft.DiaSymReader.Native.x86.dll",
167168
"mscordaccore.dll",

src/coreclr/tools/aot/ILCompiler.Diagnostics/PdbWriter.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,6 @@ public partial class PdbWriter
9292
UIntPtr _pdbMod;
9393
ISymNGenWriter2 _ngenWriter;
9494

95-
static PdbWriter()
96-
{
97-
NativeLibrary.SetDllImportResolver(typeof(PdbWriter).Assembly, DllImportResolver);
98-
}
99-
100-
private static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
101-
{
102-
IntPtr libraryHandle = IntPtr.Zero;
103-
if (libraryName == DiaSymReaderLibrary)
104-
{
105-
string archSuffix = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
106-
if (archSuffix == "x64")
107-
{
108-
archSuffix = "amd64";
109-
}
110-
libraryHandle = NativeLibrary.Load(DiaSymReaderLibrary + "." + archSuffix + ".dll", assembly, searchPath);
111-
}
112-
return libraryHandle;
113-
}
114-
11595
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.SafeDirectories)]
11696
[LibraryImport(DiaSymReaderLibrary, StringMarshalling = StringMarshalling.Utf16)]
11797
private static partial void CreateNGenPdbWriter(

src/coreclr/tools/aot/crossgen2/crossgen2.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@
8989
<DiaSymReaderTargetArchFileName>Microsoft.DiaSymReader.Native.$(DiaSymReaderTargetArch).dll</DiaSymReaderTargetArchFileName>
9090
<DiaSymReaderTargetArchPath Condition="'$(PkgMicrosoft_DiaSymReader_Native)' != ''">$(PkgMicrosoft_DiaSymReader_Native)\runtimes\win\native\$(DiaSymReaderTargetArchFileName)</DiaSymReaderTargetArchPath>
9191
<!-- When publishing we won't have the NuGet packages, so use the copy from the build artifacts directory. -->
92-
<DiaSymReaderTargetArchPath Condition="'$(PkgMicrosoft_DiaSymReader_Native)' == ''">$(CoreCLRArtifactsPath)crossgen2/$(DiaSymReaderTargetArchFileName)</DiaSymReaderTargetArchPath>
92+
<DiaSymReaderTargetArchPath Condition="'$(PkgMicrosoft_DiaSymReader_Native)' == ''">$(CoreCLRArtifactsPath)crossgen2/Microsoft.DiaSymReader.Native.dll</DiaSymReaderTargetArchPath>
9393
</PropertyGroup>
9494

9595
<ItemGroup Condition="'$(TargetOS)' == 'windows'">
9696
<Content Include="$(DiaSymReaderTargetArchPath)"
9797
CopyToOutputDirectory="PreserveNewest"
9898
CopyToPublishDirectory="PreserveNewest"
9999
ExcludeFromSingleFile="$(PublishSingleFile)"
100-
Link="%(FileName)%(Extension)"
100+
Link="Microsoft.DiaSymReader.Native.dll"
101+
TargetPath="Microsoft.DiaSymReader.Native.dll"
101102
/>
102103
</ItemGroup>
103104
</Project>

src/coreclr/tools/r2rdump/Program.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using System.Reflection.Metadata.Ecma335;
1111
using System.Reflection.PortableExecutable;
12+
using System.Runtime.InteropServices;
1213
using System.Text;
1314
using ILCompiler.Diagnostics;
1415
using ILCompiler.Reflection.ReadyToRun;
@@ -395,6 +396,22 @@ public RuntimeFunction FindRuntimeFunction(ReadyToRunReader r2r, int rtfQuery)
395396

396397
public int Run()
397398
{
399+
NativeLibrary.SetDllImportResolver(typeof(PdbWriter).Assembly,
400+
(string libraryName, System.Reflection.Assembly assembly, DllImportSearchPath? searchPath) =>
401+
{
402+
IntPtr libraryHandle = IntPtr.Zero;
403+
if (libraryName == "Microsoft.DiaSymReader.Native")
404+
{
405+
string archSuffix = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
406+
if (archSuffix == "x64")
407+
{
408+
archSuffix = "amd64";
409+
}
410+
libraryHandle = NativeLibrary.Load(libraryName + "." + archSuffix + ".dll", assembly, searchPath);
411+
}
412+
return libraryHandle;
413+
});
414+
398415
Disassembler disassembler = null;
399416
List<string> inputs = Get(_command.In);
400417
bool inlineSignatureBinary = Get(_command.InlineSignatureBinary);

0 commit comments

Comments
 (0)