Skip to content

Reduce size of AOT SDK images by removing unnecessary packages#7231

Merged
lbussell merged 3 commits into
dotnet:nightlyfrom
lbussell:smaller-aot
Jun 11, 2026
Merged

Reduce size of AOT SDK images by removing unnecessary packages#7231
lbussell merged 3 commits into
dotnet:nightlyfrom
lbussell:smaller-aot

Conversation

@lbussell

@lbussell lbussell commented Jun 9, 2026

Copy link
Copy Markdown
Member

Native AOT compilation only needs a linker and something to drive it. The .NET runtime defaults to clang but falls back to gcc when clang isn't present. Both are used to drive the same bfd linker under the hood, so clang/llvm is not needed. Here is where the runtime calculates the toolchain/linker: https://github.com/dotnet/runtime/blob/4832002fd28748322015287b8fb3b8126334865f/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets#L18-L26

We also replace the heavyweight build-base/build-essential meta-packages with just the packages AOT linking actually requires (gcc, binutils, libc dev headers, zlib dev).

This is applied only to .NET 11; changing the toolchain on .NET 10 and earlier would be a breaking change.

Size impact:

Image Before After Saved
dotnet/sdk:11.0-preview-alpine3.23-aot 401.2 MB 277.3 MB 123.9 MB (30.9%)
dotnet/sdk:11.0-preview-azurelinux3.0-aot 565.5 MB 415.9 MB 149.6 MB (26.5%)
dotnet/sdk:11.0-preview-resolute-aot 429.5 MB 362.7 MB 66.8 MB (15.6%)
dotnet/sdk:11.0-preview-azurelinux4.0-aot 380.4 MB 380.4 MB unchanged (already gcc-only)

@lbussell lbussell requested a review from a team as a code owner June 9, 2026 17:52
@lbussell lbussell requested review from baronfel and richlander June 9, 2026 17:52
@lbussell

Copy link
Copy Markdown
Member Author

This PR is ready for review, but it should be merged only after #7234 is merged.

@lbussell lbussell merged commit e5925da into dotnet:nightly Jun 11, 2026
128 checks passed
@lbussell lbussell deleted the smaller-aot branch June 11, 2026 15:00
@github-actions github-actions Bot added the needs-backport PR that should be backported to another branch label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-backport PR that should be backported to another branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants