Skip to content

Deprecate 3-arg link_libraries! in favor of lazy loading/linking#784

Merged
maleadt merged 7 commits into
masterfrom
tb/link_libraries
Apr 24, 2026
Merged

Deprecate 3-arg link_libraries! in favor of lazy loading/linking#784
maleadt merged 7 commits into
masterfrom
tb/link_libraries

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Apr 23, 2026

Simplifies the API using JuliaLLVM/LLVM.jl#547
Non-breaking; deprecations are in place.

maleadt and others added 3 commits April 23, 2026 16:52
Instead parse and link things lazily.
Use `parse(LLVM.Module, bytes; lazy=true)` when reading the cached runtime
bitcode, and link it with `only_needed=true` so the LLVM linker materializes
just the functions `ir` references. This replaces the pre-scan over runtime
function names and the conditional `link!`/`dispose` branch with a single
unconditional call.

`lower_gc_frame!` introduces `gc_pool_alloc` calls _after_ linking, so
pre-declare it in `ir` when `julia.gc_alloc_obj` is present, ensuring the
linker still picks the definition up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@maleadt maleadt force-pushed the tb/link_libraries branch from 143a7d2 to 5dab6d0 Compare April 23, 2026 14:52
@maleadt
Copy link
Copy Markdown
Member Author

maleadt commented Apr 24, 2026

Oh great, we're back at Enzyme invoking GPUCompiler from a generated function 🤦

ERROR: LoadError: code reflection cannot be used from generated functions
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] methods_including_ambiguous(f::Any, t::Any)
    @ Base ./reflection.jl:1235
  [3] showerror(io::IO, ex::MethodError)
    @ Base ./errorshow.jl:255
  [4] (::Base.var"#46#47"{MethodError})(io::IOBuffer)
    @ Base ./reflection.jl:2226
  [5] sprint(::Function; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:114
  [6] sprint(::Function)
    @ Base ./strings/io.jl:107
  [7] which(f::Any, t::Any)
    @ Base ./reflection.jl:2224
  [8] has_legacy_link_libraries
    @ /cache/build/tester-amdci4-13/julialang/gpucompiler-dot-jl/src/deprecated.jl:34 [inlined]
  [9] macro expansion
    @ /cache/build/tester-amdci4-13/julialang/gpucompiler-dot-jl/src/driver.jl:311 [inlined]
 [10] emit_llvm(job::GPUCompiler.CompilerJob; kwargs::@Kwargs{})
    @ GPUCompiler /cache/build/tester-amdci4-13/julialang/gpucompiler-dot-jl/src/utils.jl:112
 [11] emit_llvm
    @ /cache/build/tester-amdci4-13/julialang/gpucompiler-dot-jl/src/utils.jl:110 [inlined]
 [12] compile_unhooked(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget{GPUCompiler.NativeCompilerTarget}, Enzyme.Compiler.EnzymeCompilerParams{Enzyme.Compiler.PrimalCompilerParams}})
    @ Enzyme.Compiler /cache/julia-buildkite-plugin/depots/434649b0-c238-47db-be11-cc2d12bef086/dev/Enzyme/src/compiler.jl:5190
 [13] #compile#159
    @ /cache/build/tester-amdci4-13/julialang/gpucompiler-dot-jl/src/driver.jl:67 [inlined]

@maleadt maleadt merged commit 38feab2 into master Apr 24, 2026
36 of 37 checks passed
@maleadt maleadt deleted the tb/link_libraries branch April 24, 2026 07:47
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