-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AOT Compilation Canary #7458
base: v1.6
Are you sure you want to change the base?
AOT Compilation Canary #7458
Changes from all commits
35530d1
342a1cc
7fb1d00
43a87d3
6f29e4a
d8d4a57
4993a4f
1898e56
4aff06e
3d1f43c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
parameters: | ||
name: '' | ||
displayName: '' | ||
vmImage: '' | ||
run_if: true | ||
timeoutInMinutes: 10 | ||
|
||
jobs: | ||
- job: ${{ parameters.name }} | ||
condition: eq( ${{ parameters.run_if }}, true ) | ||
displayName: ${{ parameters.displayName }} | ||
timeoutInMinutes: ${{ parameters.timeoutInMinutes }} | ||
pool: | ||
vmImage: ${{ parameters.vmImage }} | ||
steps: | ||
- task: UseDotNet@2 | ||
displayName: 'Use .NET 8 SDK 8.0.402' | ||
inputs: | ||
version: 8.0.402 | ||
|
||
|
||
# Option 1: Use inline script to handle paths properly | ||
- task: PowerShell@2 | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
./tools/test-aot-compatibility.ps1 net8.0 | ||
pwsh: true | ||
|
||
- script: 'echo 1>&2' | ||
failOnStderr: true | ||
displayName: 'If above is partially succeeded, then fail' | ||
condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues') |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,3 +152,15 @@ jobs: | |
scriptArgs: CreateNuget nugetprerelease=dev incremental | ||
outputDirectory: "bin/nuget" | ||
artifactName: "nuget_pack-$(Build.BuildId)" | ||
|
||
- template: azure.aot.template.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do AOT on both Windows and Linux just in-case there are platform-specific issues. Should never happen, but you never know. |
||
parameters: | ||
name: "aot_linux" | ||
displayName: "AOT Compilation (Linux)" | ||
vmImage: "ubuntu-latest" | ||
|
||
- template: azure.aot.template.yaml | ||
parameters: | ||
name: "aot_windows" | ||
displayName: "AOT Compilation (Windows)" | ||
vmImage: "windows-latest" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="AotReceiveActor.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2025 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2025 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using Akka.Actor; | ||
|
||
namespace Akka.AOT.App.Actors; | ||
|
||
public class AotReceiveActor : ReceiveActor | ||
{ | ||
public AotReceiveActor() | ||
{ | ||
ReceiveAny(o => Sender.Tell(o)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We know |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="AotUntypedActor.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2025 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2025 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using Akka.Actor; | ||
|
||
namespace Akka.AOT.App.Actors; | ||
|
||
public class AotUntypedActor : UntypedActor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need to add more cases to the canary over time, such as:
Just to gradually add full trim coverage to everything in the default |
||
{ | ||
protected override void OnReceive(object message) | ||
{ | ||
Sender.Tell(message); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>$(NetTestVersion)</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Label="AotSettings"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all the MSBUILD settings needed to get the compiler to produce the AOT warnings we're looking for |
||
<PublishAot>true</PublishAot> | ||
<TrimmerSingleWarn>false</TrimmerSingleWarn> | ||
<SelfContained>true</SelfContained> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\core\Akka\Akka.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Akka.Actor; | ||
using Akka.AOT.App.Actors; | ||
|
||
namespace Akka.AOT.App; | ||
|
||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
var system = ActorSystem.Create("MySystem"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does some end to end messaging and uses the default configuration loading, which currently triggers a number of AOT warnings due to how we load |
||
|
||
// create AotUntypedActor | ||
var untypedActorProps = Props.Create(() => new AotUntypedActor()); | ||
var untypedActor = system.ActorOf(untypedActorProps, "untyped-actor"); | ||
|
||
// create AotReceiveActor | ||
var receiveActorProps = Props.Create(() => new AotReceiveActor()); | ||
var receiveActor = system.ActorOf(receiveActorProps, "receive-actor"); | ||
|
||
// send a message to both actors | ||
Console.WriteLine(await untypedActor.Ask("Hello, untyped actor!")); | ||
Console.WriteLine(await receiveActor.Ask("Hello, receive actor!")); | ||
|
||
// terminate the actor system | ||
await system.Terminate(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
param([string]$targetNetFramework = "net8.0") | ||
|
||
$rootDirectory = Split-Path $PSScriptRoot -Parent | ||
$publishOutput = dotnet publish $rootDirectory/src/aot/Akka.AOT.App/Akka.AOT.App.csproj -nodeReuse:false /p:UseSharedCompilation=false /p:ExposeExperimentalFeatures=true | ||
|
||
$actualWarningCount = 0 | ||
|
||
foreach ($line in $($publishOutput -split "`r`n")) | ||
{ | ||
if ($line -like "*analysis warning IL*") | ||
{ | ||
Write-Host $line | ||
|
||
$actualWarningCount += 1 | ||
} | ||
} | ||
|
||
# Determine the OS-specific folder | ||
$osPlatform = [System.Runtime.InteropServices.RuntimeInformation]::OSDescription | ||
if ($osPlatform -match "Windows") { | ||
$osFolder = "win-x64" | ||
} else { | ||
$osFolder = "linux-x64" | ||
# Default to linux | ||
} | ||
|
||
$testAppPath = Join-Path -Path $rootDirectory/src/aot/Akka.AOT.App/bin/Release/$targetNetFramework -ChildPath $osFolder/publish | ||
|
||
if (-Not (Test-Path $testAppPath)) { | ||
Write-Error "Test App path does not exist: $testAppPath" | ||
Exit 1 | ||
} | ||
|
||
Write-Host $testAppPath | ||
pushd $testAppPath | ||
|
||
Write-Host "Executing test App..." | ||
if ($osPlatform -match "Windows") { | ||
./Akka.AOT.App.exe | ||
} else { | ||
# Default to linux | ||
./Akka.AOT.App | ||
} | ||
|
||
Write-Host "Finished executing test App" | ||
|
||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode | ||
} | ||
|
||
popd | ||
|
||
Write-Host "Actual warning count is:", $actualWarningCount | ||
$expectedWarningCount = 0 | ||
|
||
$testPassed = 0 | ||
if ($actualWarningCount -ne $expectedWarningCount) | ||
{ | ||
$testPassed = 1 | ||
Write-Host "Actual warning count:", $actualWarningCount, "is not as expected. Expected warning count is:", $expectedWarningCount | ||
} | ||
|
||
Exit $testPassed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses a PowerShell script to tabulate the total number of AOT trim warnings and throw an exception if they're above 0 - taken from one of Microsoft's blogs on AOT support for library authors