Skip to content

Commit

Permalink
Add NativeRuntimeEventSource metadata to NativeAot CoreLib
Browse files Browse the repository at this point in the history
This is necessary to allow consumers to parse the payload.

Delete unnecessary runtimeflavor argument of genRuntimeEventSources.py script.

Fixes dotnet#105556
  • Loading branch information
jkotas committed Aug 19, 2024
1 parent 729d314 commit 4d8338f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
11 changes: 3 additions & 8 deletions src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,6 @@
<ProjectReference Include="$(LibrariesProjectRoot)\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
<!-- This is the T4 template service and is added by VS anytime you modify a T4 template. Required for .tt files. -->
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

<Import Project="CreateRuntimeRootILLinkDescriptorFile.targets" />

<Target Name="CreateRuntimeRootIlLinkDescFile" BeforeTargets="CoreCompile" DependsOnTargets="_CreateILLinkRuntimeRootDescriptorFile" />
Expand All @@ -312,15 +307,15 @@
<ItemGroup>
<EventingGenerationScript Include="$(CoreClrProjectRoot)scripts/genRuntimeEventSources.py" />
<EventManifestFile Include="$(CoreClrProjectRoot)vm/ClrEtwAll.man" />
<EventingSourceFile Include="$(IntermediateOutputPath)..\..\..\Eventing\$(TargetArchitecture)\$(Configuration)\NativeRuntimeEventSource.CoreCLR.cs" Condition="'$(FeaturePerfTracing)' == 'true' ">
<Link>src\System\Diagnostics\Eventing\Generated\NativeRuntimeEventSource.CoreCLR.cs</Link>
<EventingSourceFile Include="$(IntermediateOutputPath)NativeRuntimeEventSource.Generated.cs" Condition="'$(FeaturePerfTracing)' == 'true' ">
<Link>src\System\Diagnostics\Eventing\NativeRuntimeEventSource.Generated.cs</Link>
</EventingSourceFile>
<Compile Include="@(EventingSourceFile)" />
</ItemGroup>

<Target Name="GenerateEventingFiles" Inputs="@(EventingGenerationScript);@(EventManifestFile)" Outputs="@(EventingSourceFile)" DependsOnTargets="FindPython" BeforeTargets="BeforeCompile">

<Error Condition="'$(PYTHON)' == ''" Text="Unable to locate Python. NativeRuntimeEventSource.CoreCLR.cs cannot be generated without Python installed on the machine. Either install Python in your path or point to it with the PYTHON environment variable." />
<Error Condition="'$(PYTHON)' == ''" Text="Unable to locate Python. NativeRuntimeEventSource.Generated.cs cannot be generated without Python installed on the machine. Either install Python in your path or point to it with the PYTHON environment variable." />
<PropertyGroup>
<_PythonWarningParameter>-Wall</_PythonWarningParameter>
<_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror</_PythonWarningParameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,34 @@
<ProjectReference Include="$(LibrariesProjectRoot)\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

<!-- Setup eventing file generation -->
<ItemGroup>
<!-- This is the T4 template service and is added by VS anytime you modify a T4 template. Required for .tt files. -->
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
<EventingGenerationScript Include="$(CoreClrProjectRoot)scripts/genRuntimeEventSources.py" />
<EventManifestFile Include="$(CoreClrProjectRoot)vm/ClrEtwAll.man" />
<EventingSourceFile Include="$(IntermediateOutputPath)NativeRuntimeEventSource.Generated.cs" Condition="'$(FeaturePerfTracing)' == 'true' ">
<Link>src\System\Diagnostics\Eventing\NativeRuntimeEventSource.Generated.cs</Link>
</EventingSourceFile>
<Compile Include="@(EventingSourceFile)" />
</ItemGroup>

<Target Name="GenerateEventingFiles"
Inputs="@(EventingGenerationScript);@(EventManifestFile)"
Outputs="@(EventingSourceFile)"
DependsOnTargets="FindPython"
BeforeTargets="BeforeCompile">

<Error Condition="'$(PYTHON)' == ''" Text="Unable to locate Python. NativeRuntimeEventSource.Generared.cs cannot be generated without Python installed on the machine. Either install Python in your path or point to it with the PYTHON environment variable." />
<PropertyGroup>
<_PythonWarningParameter>-Wall</_PythonWarningParameter>
<_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror</_PythonWarningParameter>
<_EventingSourceFileDirectory>%(EventingSourceFile.RootDir)%(EventingSourceFile.Directory)</_EventingSourceFileDirectory>
<_EventingSourceFileDirectory Condition="HasTrailingSlash('$(_EventingSourceFileDirectory)')">$(_EventingSourceFileDirectory.TrimEnd('\'))</_EventingSourceFileDirectory>
</PropertyGroup>

<Exec Command="&quot;$(PYTHON)&quot; -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot;" />

<ItemGroup>
<FileWrites Include="@(EventingSourceFile)" />
</ItemGroup>
</Target>
</Project>
25 changes: 7 additions & 18 deletions src/coreclr/scripts/genRuntimeEventSources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import xml.dom.minidom as DOM
from utilities import open_for_update
from genEventing import RuntimeFlavor
import argparse
import sys

Expand All @@ -24,12 +23,8 @@
########################################################################
# START CONFIGURATION
########################################################################
coreCLRManifestsToGenerate = {
"Microsoft-Windows-DotNETRuntime" : "NativeRuntimeEventSource.CoreCLR.cs"
}

monoManifestsToGenerate = {
"Microsoft-Windows-DotNETRuntime" : "NativeRuntimeEventSource.Mono.cs"
manifestsToGenerate = {
"Microsoft-Windows-DotNETRuntime" : "NativeRuntimeEventSource.Generated.cs"
}

providerNameToClassNameMap = {
Expand Down Expand Up @@ -77,11 +72,8 @@ def writeOutput(outputFile, str):
def getCSharpTypeFromManifestType(manifestType):
return manifestTypeToCSharpTypeMap[manifestType]

def getManifestsToGenerate(runtimeFlavor):
if runtimeFlavor.coreclr:
return coreCLRManifestsToGenerate
elif runtimeFlavor.mono:
return monoManifestsToGenerate
def getManifestsToGenerate():
return manifestsToGenerate

def generateEvent(eventNode, providerNode, outputFile, stringTable):

Expand Down Expand Up @@ -338,7 +330,7 @@ def loadStringTable(manifest):

return stringTable

def generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlavor):
def generateEventSources(manifestFullPath, intermediatesDirFullPath):

# Open the manifest for reading.
manifest = DOM.parse(manifestFullPath)
Expand All @@ -347,7 +339,7 @@ def generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlav
stringTable = loadStringTable(manifest)

# Iterate over each provider that we want to generate an EventSource for.
for providerName, outputFileName in getManifestsToGenerate(runtimeFlavor).items():
for providerName, outputFileName in getManifestsToGenerate().items():
for node in manifest.getElementsByTagName("provider"):
if node.getAttribute("name") == providerName:
providerNode = node
Expand Down Expand Up @@ -413,16 +405,13 @@ def main(argv):
help='full path to manifest containing the description of events')
required.add_argument('--intermediate', type=str, required=True,
help='full path to eventprovider intermediate directory')
required.add_argument('--runtimeflavor', type=str,default="CoreCLR",
help='runtime flavor')
args, unknown = parser.parse_known_args(argv)
if unknown:
print('Unknown argument(s): ', ', '.join(unknown))
return 1

manifestFullPath = args.man
intermediatesDirFullPath = args.intermediate
runtimeFlavor = RuntimeFlavor(args.runtimeflavor)

# Ensure the intermediates directory exists.
try:
Expand All @@ -432,7 +421,7 @@ def main(argv):
raise

# Generate event sources.
generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlavor)
generateEventSources(manifestFullPath, intermediatesDirFullPath)
return 0

if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@
<ItemGroup>
<EventingGenerationScript Include="$(CoreClrProjectRoot)scripts/genRuntimeEventSources.py" />
<EventManifestFile Include="$(CoreClrProjectRoot)vm/ClrEtwAll.man" />
<EventingSourceFile Include="$(IntermediateOutputPath)..\..\..\Eventing\$(TargetArchitecture)\$(Configuration)\NativeRuntimeEventSource.Mono.cs" Condition="'$(FeaturePerfTracing)' == 'true' ">
<Link>src\System\Diagnostics\Eventing\Generated\NativeRuntimeEventSource.Mono.cs</Link>
<EventingSourceFile Include="$(IntermediateOutputPath)NativeRuntimeEventSource.Generated.cs" Condition="'$(FeaturePerfTracing)' == 'true' ">
<Link>src\System\Diagnostics\Eventing\NativeRuntimeEventSource.Generated.cs</Link>
</EventingSourceFile>
<Compile Include="@(EventingSourceFile)" />
</ItemGroup>
Expand All @@ -327,15 +327,15 @@
DependsOnTargets="FindPython"
BeforeTargets="BeforeCompile">

<Error Condition="'$(PYTHON)' == ''" Text="Unable to locate Python. NativeRuntimeEventSource.Mono.cs cannot be generated without Python installed on the machine. Either install Python in your path or point to it with the PYTHON environment variable." />
<Error Condition="'$(PYTHON)' == ''" Text="Unable to locate Python. NativeRuntimeEventSource.Generated.cs cannot be generated without Python installed on the machine. Either install Python in your path or point to it with the PYTHON environment variable." />
<PropertyGroup>
<_PythonWarningParameter>-Wall</_PythonWarningParameter>
<_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror</_PythonWarningParameter>
<_EventingSourceFileDirectory>%(EventingSourceFile.RootDir)%(EventingSourceFile.Directory)</_EventingSourceFileDirectory>
<_EventingSourceFileDirectory Condition="HasTrailingSlash('$(_EventingSourceFileDirectory)')">$(_EventingSourceFileDirectory.TrimEnd('\'))</_EventingSourceFileDirectory>
</PropertyGroup>

<Exec Command="&quot;$(PYTHON)&quot; -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot; --runtimeflavor mono" />
<Exec Command="&quot;$(PYTHON)&quot; -B $(_PythonWarningParameter) &quot;@(EventingGenerationScript)&quot; --man &quot;@(EventManifestFile)&quot; --intermediate &quot;$(_EventingSourceFileDirectory)&quot;" />

<ItemGroup>
<FileWrites Include="@(EventingSourceFile)" />
Expand Down
3 changes: 0 additions & 3 deletions src/tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,6 @@

<!-- NativeAOT specific -->
<ItemGroup Condition="'$(XunitTestBinBase)' != '' and '$(TestBuildMode)' == 'nativeaot' and '$(RuntimeFlavor)' == 'coreclr'">
<ExcludeList Include="$(XunitTestBinBase)/tracing/eventlistener/EventListenerThreadPool/**">
<Issue>https://github.com/dotnet/runtime/issues/105556</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/baseservices/threading/regressions/beta2/437017/**">
<Issue>https://github.com/dotnet/runtime/issues/102544</Issue>
</ExcludeList>
Expand Down

0 comments on commit 4d8338f

Please sign in to comment.