Skip to content
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

Mark project as not Native AoT ready #173

Open
boarnoah opened this issue Jun 21, 2024 · 3 comments
Open

Mark project as not Native AoT ready #173

boarnoah opened this issue Jun 21, 2024 · 3 comments
Labels
bug This issue is a bug. module/sys-mgr-ext p2 This is a standard priority issue queued

Comments

@boarnoah
Copy link

Describe the bug

With #168 there was bump for AWSSDK.Extensions.NETCore.Setup from 3.7.1 (2021) to 3.7.300 (2023).

In the interim AWSSDK.Extensions.NETCore.Setup has been marked not trimming safe for Native AoT (aws/aws-sdk-net#3044) with .NET 8.

I think that means, Amazon.Extensions.Configuration.SystemsManager should also be marked not trimming friendly for Native AoT now? Since with .NET 7.0 on-wards IIUC libraries need to opt out of trimming support.

Since there are now trimming warnings when including this package in a NativeAoT application + runtime errors.

Expected Behavior

Amazon.Extensions.Configuration.SystemsManager should not be trimmed since it doesn't support trimming

Current Behavior

Build succeeds with trim warnings,
With package 6.1.0+:

    <PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="6.2.0" />

we now get trim warnings on a successful build:

warning IL2104: Assembly 'Amazon.Extensions.Configuration.SystemsManager' produced trim warnings.

here is the same warning with <TrimmerSingleWarn>false</TrimmerSingleWarn>:

ILC : Trim analysis warning IL2026: Amazon.Extensions.Configuration.SystemsManager.Internal.AwsOptionsProvider.GetAwsOptions(IConfigurationBuilder): Using member 'Microsoft.Extensions.Configuration.ConfigurationExtensions.GetAWSOptions(IConfiguration)' which has 'RequiresUnrefer
encedCodeAttribute' can break functionality when trimming application code. The AWSSDK.Extensions.NETCore.Setup package has not been updated to support Native AOT compilations.

There is runtime errors in the application as a result ex:

System.NullReferenceException: Object reference not set to an instance of an object.\n at Amazon.Extensions.NETCore.Setup.ClientFactory.CreateConfig(Type, AWSOptions) + 0x8a\n at Amazon.Extensions.NETCore.Setup.ClientFactory.CreateServiceClient(ILogger, Type, AWSOptions) + 0x8f\n at Amazon.Extensions.NETCore.Setup.AWSOptions.CreateServiceClient[T]() + 0x2c\n at Amazon.Extensions.Configuration.SystemsManager.Internal.SystemsManagerProcessor.<GetParametersByPathAsync>d__6.MoveNex

Reproduction Steps

Sorry, setting a Native AoT project is a little involved, I can cook up a PoC if its really needed.

  1. Include Amazon.Extensions.Configuration.SystemsManager > 6.1.0 in project
  2. Setup project for Native AoT build
  3. Notice null reference exceptions w/ the package

Possible Solution

I believe we can mark the project with:

<IsAotCompatible>false</IsAotCompatible>

https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net8plus#aot-compatibility-analyzers

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Extensions.Configuration.SystemsManager 6.1.0+

Targeted .NET Platform

.NET 8

Operating System and version

AmazonLinux, scratch

@boarnoah boarnoah added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 21, 2024
@ashishdhingra ashishdhingra added needs-review p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jun 21, 2024
@ashishdhingra
Copy link
Contributor

Needs review with the team.

@boarnoah
Copy link
Author

boarnoah commented Jun 25, 2024

Did some more testing excluding various assemblies (that are transitive deps from this) from trimming,

Was able to eliminate runtime errors with:

  <ItemGroup>
    <TrimmerRootAssembly Include="AWSSDK.SimpleSystemsManagement" />
  </ItemGroup>

I believe that is the actual culprit here (at least with the runtime error I see).

There appears to already be an issue in the core SDK re: trimming problems that reports this: aws/aws-sdk-net#3173

EDIT: Sorry my understanding of trimming was a bit wrong, it was issues with AWSSDK.Extensions.NETCore.Setup that lead to AWSSDK.SimpleSystemsManagement being trimmed out incorrectly, which is why hoisting it up as a root assembly resolves the issue.

@normj
Copy link
Member

normj commented Jun 25, 2024

@boarnoah I just pushed out a PR AWSSDK.Extensions.NETCore.Setup to make it AOT compatible. That is part of in development V4 of the SDK. aws/aws-sdk-net#3353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/sys-mgr-ext p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

4 participants