Skip to content

Conversation

@joelreymont
Copy link

  • Enable imaging-mode PLT lookups only on Julia versions that expose use_jlplt,
    preserving older compat.
  • Make StaticCompiler host targets emit relocatable TLS getters by rewriting
    intrinsic and inttoptr forms and ensuring the pass runs after upstream
    transforms.
  • Update docs and fix the native ccall test message match.
  • Tests: julia --project -q -e 'using Pkg; Pkg.test()'.

These changes are required for runtime-linked StaticCompiler targets. Without these GPUCompiler patches, executables that link the Julia runtime would bake absolute TLS addresses and crash at startup.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/execution.jl b/src/execution.jl
index 22dd592..c37f264 100644
--- a/src/execution.jl
+++ b/src/execution.jl
@@ -280,11 +280,11 @@ end
                 error(
                     """Did not find CodeInstance for $job.
 
-                    Pleaase make sure that the `compiler` function passed to `cached_compilation`
-                    invokes GPUCompiler with exactly the same configuration as passed to the API.
+                                        Pleaase make sure that the `compiler` function passed to `cached_compilation`
+                                        invokes GPUCompiler with exactly the same configuration as passed to the API.
 
-                    Note that you should do this by calling `GPUCompiler.compile`, and not by
-                    using reflection functions (which alter the compiler configuration)."""
+                                        Note that you should do this by calling `GPUCompiler.compile`, and not by
+                                        using reflection functions (which alter the compiler configuration)."""
                 )
             end
             key = (ci, cfg)
diff --git a/src/ptx.jl b/src/ptx.jl
index 0a340b9..f4ae4bd 100644
--- a/src/ptx.jl
+++ b/src/ptx.jl
@@ -459,8 +459,8 @@ function nvvm_reflect!(fun::LLVM.Function)
             end
             if !isa(sym, LLVM.GlobalVariable)
                 @safe_error """Unrecognized format of __nvvm_reflect call:
-                $(string(call))
-                Operand should be a global variable, got a $(typeof(sym)). Please file an issue."""
+                                $(string(call))
+                                Operand should be a global variable, got a $(typeof(sym)). Please file an issue."""
                 continue
             end
             sym_op = operands(sym)[1]
diff --git a/test/helpers/test.jl b/test/helpers/test.jl
index 8e9c996..432e246 100644
--- a/test/helpers/test.jl
+++ b/test/helpers/test.jl
@@ -22,17 +22,17 @@ end
 @inline @generated function sink(i::T, ::Val{addrspace} = Val(0)) where {T <: Union{Int32, UInt32}, addrspace}
     as_str = addrspace > 0 ? " addrspace($addrspace)" : ""
     llvmcall_str = """%slot = alloca i32$(addrspace > 0 ? ", addrspace($addrspace)" : "")
-    store volatile i32 %0, i32$(as_str)* %slot
-    %value = load volatile i32, i32$(as_str)* %slot
-    ret i32 %value"""
+        store volatile i32 %0, i32$(as_str)* %slot
+        %value = load volatile i32, i32$(as_str)* %slot
+        ret i32 %value"""
     return :(Base.llvmcall($llvmcall_str, T, Tuple{T}, i))
 end
 @inline @generated function sink(i::T, ::Val{addrspace} = Val(0)) where {T <: Union{Int64, UInt64}, addrspace}
     as_str = addrspace > 0 ? " addrspace($addrspace)" : ""
     llvmcall_str = """%slot = alloca i64$(addrspace > 0 ? ", addrspace($addrspace)" : "")
-    store volatile i64 %0, i64$(as_str)* %slot
-    %value = load volatile i64, i64$(as_str)* %slot
-    ret i64 %value"""
+        store volatile i64 %0, i64$(as_str)* %slot
+        %value = load volatile i64, i64$(as_str)* %slot
+        ret i64 %value"""
     return :(Base.llvmcall($llvmcall_str, T, Tuple{T}, i))
 end
 
@@ -112,10 +112,10 @@ module FileCheck
             seekstart(output_io)
             filecheck_io = Pipe()
             cmd = ```$(filecheck_exe())
-            --color
-            --allow-unused-prefixes
-            --check-prefixes $(join(prefixes, ','))
-            $path```
+                        --color
+                        --allow-unused-prefixes
+                        --check-prefixes $(join(prefixes, ','))
+                        $path```
             proc = run(pipeline(ignorestatus(cmd); stdin = output_io, stdout = filecheck_io, stderr = filecheck_io); wait = false)
             close(filecheck_io.in)
 
diff --git a/test/native.jl b/test/native.jl
index c6d9916..db8418b 100644
--- a/test/native.jl
+++ b/test/native.jl
@@ -388,15 +388,15 @@ end
             Base.llvmcall(
                 (
                     """
-                    declare void @barrier() #1
+                                        declare void @barrier() #1
 
-                    define void @entry() #0 {
-                        call void @barrier()
-                        ret void
-                    }
+                                        define void @entry() #0 {
+                                            call void @barrier()
+                                            ret void
+                                        }
 
-                    attributes #0 = { alwaysinline }
-                    attributes #1 = { convergent }""", "entry",
+                                        attributes #0 = { alwaysinline }
+                                        attributes #1 = { convergent }""", "entry",
                 ),
                 Nothing, Tuple{}
             )

@maleadt maleadt requested a review from vchuravy November 24, 2025 07:53
@vchuravy
Copy link
Member

Could you for review undo the formatting commit? We haven't transitioned the entire repo and so there are lots of unrelated stuff that makes it harder to review your actual changes.

@matkoniecz
Copy link

I wonder if this is an AI-generated pull request, without human review. This is based on their other pull requests to many different projects.

See say ocaml/ocaml#14369 (comment)

@gdalle
Copy link

gdalle commented Nov 28, 2025

See also tshort/StaticCompiler.jl#180

@joelreymont
Copy link
Author

Yes, that Julia PR requires this one.


# Make sure any lingering TLS getters are rewritten even if upstream LLVM passes
# transformed them before the GPULowerPTLSPass had a chance to run.
if occursin("StaticCompilerTarget", string(typeof(job.config.target))) &&
Copy link
Member

Choose a reason for hiding this comment

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

This is the opposite of the code pattern we use, we should never hard code a specific target here, but rather expose hooks for a target to configure the pipeline

Copy link
Author

Choose a reason for hiding this comment

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

Will fix.

Copy link
Member

Choose a reason for hiding this comment

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

I would strongly prefer small, self contained PRs with tests for each features.

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.

4 participants