Skip to content

Conversation

ZingBallyhoo
Copy link
Contributor

Removes ~1.5mb of dead code from the resulting binary when compiling with NativeAOT.

@sebastienros
Copy link
Owner

Is the intent that the whole compilation chain becomes removed from the final bit and only the standard behavior used? Which I am fine with, just want to understand how this behaves then. I assume this automatically makes the library safer for nativeaot support.

@ZingBallyhoo
Copy link
Contributor Author

Is the intent that the whole compilation chain becomes removed from the final bit and only the standard behavior used?

Yes. While System.Linq.Expressions can work when trimming and under NativeAOT(via an interpreter), the implementation in Parlot+FastExpressionCompiler can't. The interpreter is quite big and just ends up being dead code as the AOT compiler can't reason that CompilationThreshold is never set to anything that isn't 0.

Apart from that, the library is fully trim compatible. Just annotating it is awkward because it requires adding

[RequiresUnreferencedCode("...incompatible with trimming")]
[RequiresDynamicCode("...incompatible with aot")]
public CompilationResult Compile(CompilationContext context)

on every single implementation of ICompilable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants