Skip to content

Register deferred_codegen in GlobalJD on Julia 1.14+.#802

Merged
maleadt merged 1 commit into
mainfrom
tb/deferred
May 19, 2026
Merged

Register deferred_codegen in GlobalJD on Julia 1.14+.#802
maleadt merged 1 commit into
mainfrom
tb/deferred

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented May 19, 2026

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.


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 🤷

@maleadt maleadt requested a review from vchuravy May 19, 2026 16:57
@maleadt maleadt marked this pull request as draft May 19, 2026 17:29
@maleadt maleadt removed the request for review from vchuravy May 19, 2026 17:29
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.
@maleadt
Copy link
Copy Markdown
Member Author

maleadt commented May 19, 2026

Hmm, if we register with JuliaGlobals instead things keep working as they previously did. But it's not particularly idiomatic...

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.68%. Comparing base (ef59201) to head (2880d21).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/driver.jl 75.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt maleadt changed the title Self-contain the deferred_codegen marker via Base.llvmcall. Register deferred_codegen in GlobalJD on Julia 1.14+. May 19, 2026
@maleadt maleadt marked this pull request as ready for review May 19, 2026 18:16
@maleadt maleadt merged commit 7f09f23 into main May 19, 2026
33 of 37 checks passed
@maleadt maleadt deleted the tb/deferred branch May 19, 2026 18:17
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.

1 participant