Skip to content

Commit

Permalink
Initial work to port EventPipe library to NativeAOT (#80382)
Browse files Browse the repository at this point in the history
* CoreCLR shim files renamed to AOT

* change coreclr references to aot

* Native AOT runtime implementation

* hooks to EP library from AOT

* Container code

* Maanged to Native hooks

* build artifacts

* required changes to NativeAOT to support EP

* changes to common EP source

* sample EventSource test app

* Add EventPipe lib to the linker

* Additional conditions to include the EventPipe library

* Fixing the Checked and Release and Linux builds

* separating maanged and native EventSource switches

* Update src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets

Co-authored-by: Michal Strehovský <[email protected]>

* FB, build break and test fixes

* fix non-windows build breaks and using paldebugbreak for TODOs

* trying another option to get arounf inttypes.h and PRIu64

* reverting the changes in ep-json file in common code

* Add an NativeAOT EventSource test

* FB and only enabling FEATURE_PERFTRACING in Windows

* fix DiagnosticEventSource test

* FB

* Update src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets

Co-authored-by: Michal Strehovský <[email protected]>

* Added GuardCF version and a standalone test

* Moving NativeAOT headers away from EventPipe common code

* fix linux build break

* missed a needed definition in Linux

* inline eventpipe common source code

* Adding Evenpipe lib to a lib test

* Small cleanups

* Undo unnecessary changes
* Make sure runtime can build without FEATURE_PERFTRACING

* Fix linux build

---------

Co-authored-by: Michal Strehovský <[email protected]>
  • Loading branch information
LakshanF and MichalStrehovsky authored Feb 8, 2023
1 parent 5b2ceeb commit 081d93a
Show file tree
Hide file tree
Showing 39 changed files with 6,274 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ The .NET Foundation licenses this file to you under the MIT license.

<IlcRPath Condition="'$(IlcRPath)' == '' and '$(TargetOS)' != 'osx'">$ORIGIN</IlcRPath>
<IlcRPath Condition="'$(IlcRPath)' == '' and '$(TargetOS)' == 'osx'">@executable_path</IlcRPath>

<EventPipeName>libeventpipe-disabled</EventPipeName>
<EventPipeName Condition="'$(EnableNativeEventPipe)' == 'true'">libeventpipe-enabled</EventPipeName>
</PropertyGroup>

<ItemGroup>
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
<NativeLibrary Condition="'$(NativeLib)' == ''" Include="$(IlcSdkPath)libbootstrapper.a" />
<NativeLibrary Condition="'$(NativeLib)' != ''" Include="$(IlcSdkPath)libbootstrapperdll.a" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName).a" />
<NativeLibrary Include="$(IlcSdkPath)$(EventPipeName)$(LibFileExt)" />
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
<NativeLibrary Condition="'$(StaticNumaLinking)' == 'true'" Include="$(IlcSdkPath)libnumasupportstatic.a" />
<NativeLibrary Condition="'$(StaticNumaLinking)' != 'true'" Include="$(IlcSdkPath)libnumasupportdynamic.a" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<EntryPointSymbol Condition="'$(EntryPointSymbol)' == ''">wmainCRTStartup</EntryPointSymbol>
<LinkerSubsystem Condition="'$(OutputType)' == 'WinExe' and '$(LinkerSubsystem)' == ''">WINDOWS</LinkerSubsystem>
<LinkerSubsystem Condition="'$(OutputType)' == 'Exe' and '$(LinkerSubsystem)' == ''">CONSOLE</LinkerSubsystem>
<EventPipeName>eventpipe-disabled</EventPipeName>
<EventPipeName Condition="'$(EnableNativeEventPipe)' == 'true'">eventpipe-enabled</EventPipeName>
</PropertyGroup>

<!-- Ensure that runtime-specific paths have already been set -->
Expand All @@ -33,6 +35,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<ItemGroup>
<NativeLibrary Include="$(IlcSdkPath)$(BootstrapperName)$(LibrarySuffix)" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName)$(LibrarySuffix)" />
<NativeLibrary Include="$(IlcSdkPath)$(EventPipeName)$(LibrarySuffix)" />
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
</ItemGroup>

Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
<PropertyGroup>
<DefineConstants Condition="'$(FeatureObjCMarshal)' == 'true'">FEATURE_OBJCMARSHAL;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<FeaturePerfTracing>false</FeaturePerfTracing>
<FeaturePerfTracing Condition="'$(TargetsWindows)' == 'true'">true</FeaturePerfTracing>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">FEATURE_PERFTRACING;$(DefineConstants)</DefineConstants>
</PropertyGroup>


<!-- Platform specific properties -->
<PropertyGroup Condition="'$(Platform)' == 'x64'">
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/nativeaot/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ list(APPEND RUNTIME_SOURCES_ARCH_ASM
convert_to_absolute_path(ARCH_SOURCES_DIR ${ARCH_SOURCES_DIR})
include_directories(${ARCH_SOURCES_DIR})

if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
set(FEATURE_PERFTRACING 1)
endif()

if(FEATURE_PERFTRACING)
add_definitions(-DFEATURE_PERFTRACING)
endif()

add_definitions(-DFEATURE_BASICFREEZE)
add_definitions(-DFEATURE_CONSERVATIVE_GC)
add_definitions(-DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP)
Expand Down Expand Up @@ -263,6 +271,10 @@ else()
add_subdirectory(Portable)
endif()

if(FEATURE_PERFTRACING)
add_subdirectory(eventpipe)
endif()

if (CLR_CMAKE_TARGET_UNIX)
add_library(numasupportdynamic STATIC ${GC_DIR}/unix/numasupport.dynamic.cpp)
install_static_library(numasupportdynamic aotsdk nativeaot)
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/nativeaot/Runtime/DisabledEventPipeInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

void EventPipeAdapter_Initialize() {}

bool DiagnosticServerAdapter_Initialize() { return false; }
void DiagnosticServerAdapter_PauseForDiagnosticsMonitor() {}

void EventPipeAdapter_FinishInitialize() {}

void EventPipeAdapter_Shutdown() {}
bool DiagnosticServerAdapter_Shutdown() { return false; }
Loading

0 comments on commit 081d93a

Please sign in to comment.