I'm presently working on reactivating AOT-compilation for ClojureCLR on .NET 9.
Unfortunately, it is not as simple as just calling Save. There is new kind of assembly builder and it has some limitations that do now play well. If you are interested in the details check out https://dmiller.github.io/clojure-clr-next/general/2025/02/20/AOT-compilation-issues.html.
Once you start digging, it's hard to stop. I've had to go back and take a look at some of the decisions I made a long time ago dealing with the differences between the JVM and the CLR in how they handle types and how that manifests in ClojureCLR compared to Clojure(JVM). If you are interested in some deep internals, keep reading:
• https://dmiller.github.io/clojure-clr-next/general/2025/02/28/function-naming.html
• https://dmiller.github.io/clojure-clr-next/general/2025/03/01/are-you-my-type.html
For those of you keeping score:
On the plus side: I have managed to compile/save a (simple) Clojure source file under .Net 9. And subsequently one can load the resulting DLL with the intended results.
On the minus side: Well, I still have a lot of testing to do.
If you've read the blog posts mentioned above, the technique I used was "double code generation" -- each top-level form goes through the entire analysis/code-gen process twice, once to emit to the DLL to be saved, once to do side-effects in the current runtime. So compilation will be a bit slower. But the whole point is to do that effort once and get the payoff in faster startup and runtime performance.
Doing the double code generation was easier than I had feared. Where I ran into some problems was dealing with direct linking. The issues with direct linking in general is covered in the second post above. The biggest problem I ran into here was figuring out that the CLR was doing some nasty sleight-of-hand with reflection.
The big test will be seeing if I can compile core.clj and other parts of the runtime loading. Plus making sure gen-class and other things that rely on compilation function correctly. But mostly they are built on top of the things that seem to be working now.
At that point, I'll be able to get a sense of the speedup for Clojure startup.
After that, restoring the build process so the .NET 9 version compiles all these things and they get bundled with the runtime that gets distributed. So there's still some work to do. But hopefully just some straightforward plumbing.