Skip to content

Conversation

@radical
Copy link
Member

@radical radical commented Jul 24, 2025

  • These are cross compiled on linux-x64 images.
    Co-authored by Alexander Köplinger [email protected]

  • Add a check for the output of 'file' command on unix, to confirm that the native binary is for the correct arch. This is meant as a simply sanity check.

Contributes to #10288

radical added 2 commits July 24, 2025 18:59
These are cross compiled on linux-x64 images.

Authored by Alexander Köplinger <[email protected]>
… that the native binary is for the correct arch
@radical radical marked this pull request as ready for review July 24, 2025 23:03
Copilot AI review requested due to automatic review settings July 24, 2025 23:03
@github-actions github-actions bot added the area-engineering-systems infrastructure helix infra engineering repo stuff label Jul 24, 2025
@radical
Copy link
Member Author

radical commented Jul 24, 2025

This comment was marked as outdated.

@radical radical requested a review from akoeplinger July 24, 2025 23:04
@radical radical requested a review from Copilot July 24, 2025 23:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables Native AOT compilation for the Aspire CLI on linux-arm64 and linux-musl-x64 platforms by setting up cross-compilation infrastructure and adding binary validation checks.

  • Configures cross-compilation containers and build environment for ARM64 and musl targets
  • Adds linker arguments and file signature validation to ensure correct native binary generation
  • Removes previous limitations that disabled Native AOT for these platforms

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Aspire.Cli/Aspire.Cli.csproj Adds linker arguments for linux-musl-x64 cross-compilation
eng/pipelines/templates/build_sign_native.yml Configures container selection for cross-compilation builds
eng/pipelines/azure-pipelines.yml Defines cross-compilation containers with appropriate environments
eng/clipack/Common.projitems Implements file signature validation for native binaries on Unix platforms
eng/clipack/Aspire.Cli.osx-x64.csproj Adds file signature regex for macOS x64 binaries
eng/clipack/Aspire.Cli.osx-arm64.csproj Adds file signature regex for macOS ARM64 binaries
eng/clipack/Aspire.Cli.linux-x64.csproj Adds file signature regex for Linux x64 binaries
eng/clipack/Aspire.Cli.linux-musl-x64.csproj Enables Native AOT and adds file signature regex for musl x64
eng/clipack/Aspire.Cli.linux-arm64.csproj Enables Native AOT and adds file signature regex for ARM64

@radical radical mentioned this pull request Jul 24, 2025
6 tasks
@radical radical requested a review from danmoseley July 24, 2025 23:46
@radical radical added this to the 9.4 milestone Jul 24, 2025
@radical radical merged commit 6d8d04d into dotnet:main Jul 25, 2025
276 checks passed
@radical radical deleted the linux-cross branch July 25, 2025 01:12
@radical
Copy link
Member Author

radical commented Jul 25, 2025

/backport to release/9.4

@github-actions
Copy link
Contributor

Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16511371828

</PropertyGroup>

<ItemGroup Condition="'$(PublishAot)' == 'true'">
<LinkerArg Condition="'$(RuntimeIdentifier)' == 'linux-musl-x64'" Include="--target=x86_64-alpine-linux-musl" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? This doesn't seem right that we have to do this.

cc @agocke @MichalStrehovsky

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this is fixed in net9.0 but Aspire.Cli targets net8.0 . cc @akoeplinger

Copy link
Member

@eerhardt eerhardt Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should find a time to update to net10.0. I started in #10167. Maybe when .NET 10 RC (or maybe preview7?) comes out, it would be a good time to switch to the latest. Advantages:

  1. I noticed a decent disk size drop when I was trying it.
  2. It would allow us to do "warnings as errors", which was also fixed in net9.0.
  3. We could do RID-specific dotnet tool (dnx). So the AOT'd version would be in dotnet tool install

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that mean that we could no longer publish a dotnet tool that is installable in 8 or 9 SDKs though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( not saying that would be ab locker, just trying to understand the implications)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that mean that we could no longer publish a dotnet tool that is installable in 8 or 9 SDKs though?

Potentionally, yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think thats is the case

cc @baronfel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? This doesn't seem right that we have to do this.

FWIW this was fixed in dotnet/runtime#101213, looks like there's an LLVM bug asking why this is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that mean that we could no longer publish a dotnet tool that is installable in 8 or 9 SDKs though?

Yes, or at minimum you could publish a 8/9 to but it would need to be a different package id.

Copy link
Member

@akoeplinger akoeplinger Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichalStrehovsky FYI that's not really the issue here, the problem is that in 8.0 we only consider a cross build if the architecture doesn't match: https://github.com/dotnet/runtime/blob/43906bfc26e75a36b1e317211a085f2886862f1e/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L35

But in this case we're cross-building from AzureLinux x64 -> Alpine Musl x64. Passing the linker flag directly works around that.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-cli area-engineering-systems infrastructure helix infra engineering repo stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants