Register deferred_codegen in GlobalJD on Julia 1.14+.#802
Merged
Conversation
JuliaLang/julia#60988 changed `JITDylib(jljit)` to return a fresh private dylib that's only searched outward (to GlobalJD/SessionJD), so defining "deferred_codegen" there is invisible to JIT-compiled user code in JD. Use `LLVM.lookup_dylib(es, "JuliaGlobals")` to grab the existing GlobalJD — which JD links to with `MatchExportedSymbolsOnly` — and define the absolute symbol there. JD's lookup chain then resolves "deferred_codegen" through GlobalJD. The pre-1.14 branch is unchanged.
Member
Author
|
Hmm, if we register with |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #802 +/- ##
==========================================
+ Coverage 75.05% 75.68% +0.62%
==========================================
Files 25 25
Lines 3901 3878 -23
==========================================
+ Hits 2928 2935 +7
+ Misses 973 943 -30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
JuliaLang/julia#60988 changed
JITDylib(jljit)to return a fresh private dylib that's only searched outward (to GlobalJD/SessionJD), so defining "deferred_codegen" there is invisible to JIT-compiled user code in JD.Use
LLVM.lookup_dylib(es, "JuliaGlobals")to grab the existing GlobalJD — which JD links to withMatchExportedSymbolsOnly— and define the absolute symbol there. JD's lookup chain then resolves "deferred_codegen" through GlobalJD.The pre-1.14 branch is unchanged.
Old approach was more idiomatic, using an intrinsic, but broken Enzyme and had some inlining issues because of the Ptr ABI switch. So let's go with the simpler solution now.
Julia 1.14 (JuliaLang/julia#60988) removed the shared ExternalJD, so registering "deferred_codegen" as an absolute symbol on a fresh JITDylib is no longer visible to JIT-compiled user code. Instead, emit the marker function with a linkonce_odr passthrough body inline via Base.llvmcall, making the IR self-contained on every Julia version. GPUCompiler still finds and rewrites the calls as before; only the JIT-link fallback path changes.
Shouldn't be breaking, and works with CUDA.jl. Of course, Enzyme.jl reaches into GPUCompiler.jl internals so is broken by this 🤷