Repository navigation
Make the runtime's boxing functions linkable on the host - #1067
Merged
Merged
Conversation
The runtime's `box_*` functions read their type tag by declaring the data symbol `jl_<type>_type` as a function and loading through it. Sysimage builds and package images compile these functions for the host, where this only links if the symbol is resolved by name at load time: on Windows, lld can't link it, which keeps KernelAbstractions from precompiling a kernel launch on Julia 1.11. Write the tag as Julia does instead: a constant for the types in `jl_small_typeof`, and the address of the type object otherwise.
This was referenced Oct 28, 2026
Member
Author
|
CI failures unrelated, fixed downstream. |
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.
The runtime's
box_*functions get their type tag by declaring the data symboljl_<type>_typeas an LLVM function and loading through it. These are ordinary host methods. Sysimage builds compile them for the host: Julia 1.12+ compiles every concrete method, and on 1.11, native code instances leak in. Package images do the same on 1.11. That only links when the symbol is resolved by name at load time. On Windows, lld can't link it:This is why KernelAbstractions doesn't precompile a kernel launch on Julia 1.11 on Windows.
Nothing in these functions is device-specific, so instead of hiding them from the host, this writes the tag the way Julia's
jl_set_typeofdoes. The types injl_small_typeof(all the integers andBool) get their small tag, a constant for a given build of Julia.Float32andFloat64get the address of their type object, which goes through the existing relocation of Julia values in the runtime library. This is the same header decoding asmaterialize_box!.Tested with the full suite on 1.12, plus the native tests on 1.10 and 1.13. The new test checks that the host IR of every
box_*is free ofjl_*_typereferences, and that the tags match Julia's. In a Windows VM on Julia 1.11, KernelAbstractions (with JuliaGPU/KernelAbstractions.jl#930) now precompiles with its kernel-launch workload enabled, and loads and runs kernels.