Skip to content

Issue 112#114

Closed
ancapdev wants to merge 2 commits intocarstenbauer:mainfrom
ancapdev:issue-112
Closed

Issue 112#114
ancapdev wants to merge 2 commits intocarstenbauer:mainfrom
ancapdev:issue-112

Conversation

@ancapdev
Copy link
Copy Markdown

@ancapdev ancapdev commented Jan 2, 2026

Fixes #112

I tried various forms of ccall() and ran into the same kinds of errors. Explicit dynamic resolution seems to work.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Julia 1.13-alpha/nightly compilation failures in src/mkl.jl by avoiding @ccall with a non-literal library expression and instead resolving MKL symbols dynamically at runtime.

Changes:

  • Added Libdl dependency to enable dynamic symbol lookup.
  • Replaced @ccall mkl_fullpath().… usages with dlopen/dlsym + ccall for mkl_get_dynamic and mkl_set_dynamic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mkl.jl
Comment on lines +45 to +47
function mkl_get_dynamic()
sym = Libdl.dlsym(Libdl.dlopen(mkl_fullpath()), :mkl_get_dynamic)
ccall(sym, Cint, ())
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libdl.dlopen(mkl_fullpath()) is executed on every call, and the resulting handle is never explicitly closed or cached. This can add overhead and may temporarily increase the dlopen refcount until GC runs. Consider caching the handle (e.g., a const Ref initialized once) or using the Libdl.dlopen(path) do lib ... end form to ensure timely dlclose.

Copilot uses AI. Check for mistakes.
Comment thread src/mkl.jl
Comment on lines 55 to +57
function mkl_set_dynamic(flag::Integer)
@ccall mkl_fullpath().MKL_Set_Dynamic(flag::Cint)::Cvoid
sym = Libdl.dlsym(Libdl.dlopen(mkl_fullpath()), :MKL_Set_Dynamic)
ccall(sym, Cvoid, (Cint,), flag)
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opens the MKL shared library and resolves the symbol on every call. To avoid repeated dlopen/dlsym work (and accumulating handles until GC), cache the dlopen handle/symbol in module-level const refs, or wrap the call in a Libdl.dlopen(...) do lib ... end block so the handle is closed immediately.

Copilot uses AI. Check for mistakes.
@carstenbauer
Copy link
Copy Markdown
Owner

Superseded by #116. But thank you anyway!!

@ancapdev ancapdev deleted the issue-112 branch March 26, 2026 19:15
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.

Compilation error on Julia 1.13-alpha2

3 participants