feat: Native AOT support - #11
Merged
Merged
Conversation
unsafePtr
force-pushed
the
feat/nativeaot
branch
from
August 19, 2026 10:00
32700ea to
7c75941
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Native AOT support, and the CI to keep it honest.
Native AOT
PublishAotis opt-in per publish, so ordinary builds stay on the JIT.aot-tests.ymlpublishes the suite natively for linux-x64 (default baseline andx86-64-v3), linux-arm64, osx-arm64 and win-x64, asserts the library emits no trim/AOT warnings, and runs the binary.The per-baseline legs aren't redundant. ILC resolves
Vector256/Vector128.IsHardwareAcceleratedat build time against an instruction-set baseline rather than the live CPU, so the default x64 baseline compiles theVector128kernel even on AVX2 hardware. Thex86-64-v3legs guarantee AVX2, so between them the matrix compiles both. The scalar fallback stays JIT-only, since SSE2 and AdvSimd are architectural baselinesIlcInstructionSetcannot drop — which is whyVectorInstructionSetTestsskips itself in a native run.xunit packaging
Running under AOT needs xunit v3 4.0.0 and source-generated discovery; before that the runner resolved the test assembly through
Assembly.Location, which is empty in a native image.The
.aotpackage is now selected only whenPublishAot=true. It also pullsxunit.v3.assert.aot, whose reflection-free formatter renders every object asBox { ... }and obsoletesAssert.Equivalent— a cost that landed on ordinary JIT runs, where the failure message is the whole point.Swapping the package opens a silent gap, since a test the generator cannot see yields no test rather than an error.
aot-tests.ymlnow compares the native and JIT test counts on the linux-x64 leg.CI coverage
tests.ymlis new: the JIT suite on linux-x64, linux-arm64, win-x64 and osx-arm64, every push and PR, no path filter. Previously the only JIT run lived inpublish-nuget.yml, filtered tosrc/Base58Encoding/**and pinned to an arm64 runner, so a test-only change ran nothing and every x64 execution in CI came out of ILC. That mattered most forVectorInstructionSetTests, which drives its coverage throughDOTNET_EnableAVX2andDOTNET_EnableHWIntrinsic: ILC bakes past both and arm64 ignores the first, so the Vector128 and scalar fallbacks never actually ran anywhere.publish-nuget.ymlis narrowed tov*.*.*tags andworkflow_dispatch, keeping a test step scoped to the publishing path —tests.ymlnever runs on a tag, because abranches:filter does not matchrefs/tags/*.Also
SimpleBase 5.6.2 → 5.6.4, lifting the pin from 32613b3.
Verification
JIT reports 141 tests on each of 4 platforms, the native binary reports 141 on each of 5, and the parity step prints
native discovered 141, JIT discovered 141. The counts differ only inSkipped(1 vs 3 — the twoVectorInstructionSetTestscases that skip natively).