Skip to content

Commit ff15684

Browse files
committed
Addressing Simon's PR feedback, msbuild project fixes for x86
Based on Simon's suggestion I moved the PDB / PerfMap-specific code to a new file SymbolFileBuilder as I concur that its squatting in the MapFileBuilder was somewhat hacky. Both classes use a new helper class ObjectInfoBuilder that collects the information common to both - I was reluctant to make it a base class of the *FileBuilder's as we'd have to collect all the elements twice. Thanks Tomas
1 parent 20f7ba0 commit ff15684

File tree

10 files changed

+374
-267
lines changed

10 files changed

+374
-267
lines changed

src/coreclr/tools/aot/ILCompiler.Diagnostics/ILCompiler.Diagnostics.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<OutputType>Library</OutputType>
54
<AssemblyName>ILCompiler.Diagnostics</AssemblyName>
5+
<OutputType>Library</OutputType>
6+
<IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
67
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
78
<DefineConstants>READYTORUN;$(DefineConstants)</DefineConstants>
8-
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
9-
<Platforms>x64;x86</Platforms>
9+
<Platforms>x64;x86;arm;arm64</Platforms>
1010
<PlatformTarget>AnyCPU</PlatformTarget>
1111
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1212

src/coreclr/tools/aot/ILCompiler.ReadyToRun/CodeGen/ReadyToRunObjectWriter.cs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,21 @@ internal class ReadyToRunObjectWriter
5050
/// </summary>
5151
private readonly IEnumerable<DependencyNode> _nodes;
5252

53+
/// <summary>
54+
/// Set to non-null when the executable generator should output a map or symbol file.
55+
/// </summary>
56+
private readonly ObjectInfoBuilder _objectInfoBuilder;
57+
5358
/// <summary>
5459
/// Set to non-null when the executable generator should output a map file.
5560
/// </summary>
5661
private readonly MapFileBuilder _mapFileBuilder;
5762

63+
/// <summary>
64+
/// Set to non-null when generating symbol info (PDB / PerfMap).
65+
/// </summary>
66+
private readonly SymbolFileBuilder _symbolFileBuilder;
67+
5868
/// <summary>
5969
/// True when the map file builder should emit a textual map file
6070
/// </summary>
@@ -133,10 +143,23 @@ public ReadyToRunObjectWriter(
133143
_pdbPath = pdbPath;
134144
_generatePerfMapFile = generatePerfMapFile;
135145
_perfMapPath = perfMapPath;
136-
137-
if (generateMapFile || generateMapCsvFile || generatePdbFile || generatePerfMapFile)
146+
147+
bool generateMap = (generateMapFile || generateMapCsvFile);
148+
bool generateSymbols = (generatePdbFile || generatePerfMapFile);
149+
150+
if (generateMap || generateSymbols)
138151
{
139-
_mapFileBuilder = new MapFileBuilder();
152+
_objectInfoBuilder = new ObjectInfoBuilder();
153+
154+
if (generateMap)
155+
{
156+
_mapFileBuilder = new MapFileBuilder(_objectInfoBuilder);
157+
}
158+
159+
if (generateSymbols)
160+
{
161+
_symbolFileBuilder = new SymbolFileBuilder(_objectInfoBuilder);
162+
}
140163
}
141164
}
142165

@@ -244,12 +267,12 @@ public void EmitPortableExecutable()
244267
}
245268
}
246269

247-
EmitObjectData(r2rPeBuilder, nodeContents, nodeIndex, name, node.Section, _mapFileBuilder);
270+
EmitObjectData(r2rPeBuilder, nodeContents, nodeIndex, name, node.Section);
248271
lastWrittenObjectNode = node;
249272

250273
if ((_generatePdbFile || _generatePerfMapFile) && node is MethodWithGCInfo methodNode)
251274
{
252-
_mapFileBuilder.AddMethod(methodNode, nodeContents.DefinedSymbols[0]);
275+
_objectInfoBuilder.AddMethod(methodNode, nodeContents.DefinedSymbols[0]);
253276
}
254277
}
255278

@@ -289,9 +312,9 @@ public void EmitPortableExecutable()
289312
}
290313
}
291314

292-
if (_mapFileBuilder != null)
315+
if (_objectInfoBuilder != null)
293316
{
294-
r2rPeBuilder.AddSections(_mapFileBuilder);
317+
r2rPeBuilder.AddSections(_objectInfoBuilder);
295318

296319
if (_generateMapFile)
297320
{
@@ -313,7 +336,7 @@ public void EmitPortableExecutable()
313336
{
314337
path = Path.GetDirectoryName(_objectFilePath);
315338
}
316-
_mapFileBuilder.SavePdb(path, _objectFilePath);
339+
_symbolFileBuilder.SavePdb(path, _objectFilePath);
317340
}
318341

319342
if (_generatePerfMapFile)
@@ -323,7 +346,7 @@ public void EmitPortableExecutable()
323346
{
324347
path = Path.GetDirectoryName(_objectFilePath);
325348
}
326-
_mapFileBuilder.SavePerfMap(path, _objectFilePath);
349+
_symbolFileBuilder.SavePerfMap(path, _objectFilePath);
327350
}
328351
}
329352

@@ -361,8 +384,7 @@ public void EmitPortableExecutable()
361384
/// <param name="nodeIndex">Logical index of the emitted node for diagnostic purposes</param>
362385
/// <param name="name">Textual representation of the ObjecData blob in the map file</param>
363386
/// <param name="section">Section to emit the blob into</param>
364-
/// <param name="mapFile">Map file output stream</param>
365-
private void EmitObjectData(R2RPEBuilder r2rPeBuilder, ObjectData data, int nodeIndex, string name, ObjectNodeSection section, MapFileBuilder mapFileBuilder)
387+
private void EmitObjectData(R2RPEBuilder r2rPeBuilder, ObjectData data, int nodeIndex, string name, ObjectNodeSection section)
366388
{
367389
#if DEBUG
368390
for (int symbolIndex = 0; symbolIndex < data.DefinedSymbols.Length; symbolIndex++)
@@ -381,7 +403,7 @@ private void EmitObjectData(R2RPEBuilder r2rPeBuilder, ObjectData data, int node
381403
}
382404
#endif
383405

384-
r2rPeBuilder.AddObjectData(data, section, name, mapFileBuilder);
406+
r2rPeBuilder.AddObjectData(data, section, name, _objectInfoBuilder);
385407
}
386408

387409
public static void EmitObject(

src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<DefineConstants>READYTORUN;$(DefineConstants)</DefineConstants>
88
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
9-
<Platforms>x64;x86</Platforms>
9+
<Platforms>x64;x86;arm;arm64</Platforms>
1010
<PlatformTarget>AnyCPU</PlatformTarget>
1111
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1212

@@ -196,6 +196,8 @@
196196
<Compile Include="IL\Stubs\PInvokeILEmitter.cs" />
197197
<Compile Include="Interop\IL\Marshaller.ReadyToRun.cs" />
198198
<Compile Include="Compiler\PerfEventSource.cs" />
199+
<Compile Include="ObjectWriter\ObjectInfoBuilder.cs" />
200+
<Compile Include="ObjectWriter\SymbolFileBuilder.cs" />
199201
<Compile Include="Win32Resources\ResourceData.cs" />
200202
<Compile Include="Win32Resources\ResourceData.Reader.cs" />
201203
<Compile Include="Win32Resources\ResourceData.ResourcesDataModel.cs" />

0 commit comments

Comments
 (0)