Skip to content

StaticCompiler upgraded to Julia v1.11 #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kylincaster
Copy link

Dear all,

After repeated testing, I’m glad to report that StaticCompiler.jl now works with Julia v1.11.

  • Updated to support GPUCompiler v1.5.2
  • Version number has been bumped v0.7.3
  • Everything runs stably in current tests

If you run into any issues, feel free to leave a comment or open an issue.

Upcoming: StaticLLVM.jl

I’m also working on a new package called StaticLLVM.jl, which builds on the infrastructure of StaticCompiler.jl and StaticTools.jl. It is designed to assist with processing LLVM IR for static compilation workflows.

If you have any feature suggestions or specific needs, feel free to let me know!

Thanks!

Kylin

@brenhinkeller
Copy link
Collaborator

Great to have this running on 1.11! I'll merge if no objections. While it looks like there may still be a few more issues to track down in the integration tests, this is more green than we've seen in CI for quite a while!

@brenhinkeller
Copy link
Collaborator

Fixes #166 #170

@brenhinkeller
Copy link
Collaborator

Given that windows tests also seem to be passing pretty well I'm also going to say fixes #158 #163

Copy link
Collaborator

@MasonProtter MasonProtter left a comment

Choose a reason for hiding this comment

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

This looks really great. Thank you for taking this on!

I think it probably doesn't make sense to try and have so many if version(...) checks in here, and we should just increase our version support bounds.

If people aren't able to upgrade to newer versions of julia or GPUCompiler, they will get stuck with older versions of StaticCompiler which is fine.

Also, the pkgversion function was added in v1.9, so using it will break the v1.8 tests.

Since v1.10 is the current julia LTS, I say we drop support for v1.8 and 1.9, and drop support for GPUCompiler < 1.5

That should make this simpler and hopefully more robust too.

Comment on lines +592 to +601
@static if VERSION < v"1.9"
obj, _ = GPUCompiler.emit_asm(fakejob, mod; strip=strip_asm, validate=false, format=LLVM.API.LLVMObjectFile)
obj
else
@static if pkgversion(GPUCompiler) < v"1.3.0"
obj, _ = GPUCompiler.emit_asm(fakejob, mod; strip=strip_asm, validate=false, format=LLVM.API.LLVMObjectFile)
else
obj, _ = GPUCompiler.emit_asm(fakejob, mod, LLVM.API.LLVMObjectFile)
end
end
obj
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that the new way to handle kwargs like strip and validate is GPUCompierConfig: JuliaGPU/GPUCompiler.jl#668

Copy link
Author

Choose a reason for hiding this comment

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

Indeed, GPUCompiler has changed significantly between versions 0.x and 1.x.
Supporting both versions requires considerable effort, and dropping support for older versions would make maintenance much smoother.

Comment on lines 5 to +6
using GPUCompiler:
@safe_debug, AbstractCompilerParams, CodeCache, CompilerJob, methodinstance
@safe_debug, AbstractCompilerParams, CompilerJob, methodinstance, CodeInstance, inference_params, optimization_params, get_inference_world
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it'd be better to import some of this stuff from Core.Compiler where it's defined rather than `GPUCompiler.

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately, Core.Compiler is an internal API and not guaranteed to be stable or long-term supported.
Since all the compilation-related data originates from GPUCompiler, I believe it's better to import the necessary functionality from GPUCompiler rather than relying directly on Core.Compiler.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Those functions and types are not part of the public interface of GPUCompiler either. By importing them from GPUCompiler, you're relying on GPUCompiler internals and Core.Compiler internals. By importing those names out of GPUCompiler, you make it more vulnerable to instability, not less.

Comment on lines -40 to +76
# abstractarray.jl
@device_override @noinline Base.throw_boundserror(A, I) =
@print_and_throw c"Out-of-bounds array access"
# abstractarray.jl
# Base.throw_boundserror is removed since v1.11
if VERSION < v"1.11"
@device_override @noinline Base.throw_boundserror(A, I) =
@print_and_throw c"Out-of-bounds array access"
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Base.throw_boundserror definitely was not removed in v1.11.

Copy link
Author

@kylincaster kylincaster Jun 15, 2025

Choose a reason for hiding this comment

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

In my tests, Bumper v0.6.0 fails to work with Julia v1.11 due to its attempt to override Base.throw_boundserror.

However, when switching to Bumper v0.7.0, everything works smoothly, as this version uses a different backend (UnsafeArrays).

Although the throw_boundserror function still exists in Julia v1.11, its definition has been moved from abstractarray.jl to essential.jl, which might indicate that it has been made non-overridable.

Copy link
Collaborator

@MasonProtter MasonProtter Jun 15, 2025

Choose a reason for hiding this comment

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

Weird. Let's just drop Bumper 0.6 support then and put a compat bound with Bumper v0.7 as the minimum.

Please restore the device overrride for the boundserror in v1.11+, we need that.

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately, Bumper v0.6 is required by StaticTools.jl. However, I believe that updating Bumper in StaticTools will not affect its functionality. Currently, I’m helping the developers with some new functionality for StaticTools.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The version of StaticTools that we registered yesterday (0.8.11) should support Bumper v0.7 since the PR right before yours bumped the compat bounds on Bumper

@@ -18,11 +18,11 @@ StaticTools = "86c06d3c-3f03-46de-9781-57580aa96d0a"

[compat]
CodeInfoTools = "0.3"
GPUCompiler = "0.21, 0.22, 0.23, 0.24, 0.25, 0.26"
LLVM = "6"
GPUCompiler = "0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 1.5, 1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the 1 shouldn't be here, just 1.5

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.

3 participants