@@ -29,13 +29,14 @@ mutable struct StaticTarget
2929 platform:: Union{Platform,Nothing}
3030 tm:: LLVM.TargetMachine
3131 compiler:: Union{String,Nothing}
32+ julia_runtime:: Bool
3233end
3334
3435clean_triple (platform:: Platform ) = arch (platform) * os_str (platform) * libc_str (platform)
3536StaticTarget () = StaticTarget (HostPlatform (), unsafe_string (LLVM. API. LLVMGetHostCPUName ()), unsafe_string (LLVM. API. LLVMGetHostCPUFeatures ()))
36- StaticTarget (platform:: Platform ) = StaticTarget (platform, LLVM. TargetMachine (LLVM. Target (triple = clean_triple (platform)), clean_triple (platform)), nothing )
37- StaticTarget (platform:: Platform , cpu:: String ) = StaticTarget (platform, LLVM. TargetMachine (LLVM. Target (triple = clean_triple (platform)), clean_triple (platform), cpu), nothing )
38- StaticTarget (platform:: Platform , cpu:: String , features:: String ) = StaticTarget (platform, LLVM. TargetMachine (LLVM. Target (triple = clean_triple (platform)), clean_triple (platform), cpu, features), nothing )
37+ StaticTarget (platform:: Platform ) = StaticTarget (platform, LLVM. TargetMachine (LLVM. Target (triple = clean_triple (platform)), clean_triple (platform)), nothing , false )
38+ StaticTarget (platform:: Platform , cpu:: String ) = StaticTarget (platform, LLVM. TargetMachine (LLVM. Target (triple = clean_triple (platform)), clean_triple (platform), cpu), nothing , false )
39+ StaticTarget (platform:: Platform , cpu:: String , features:: String ) = StaticTarget (platform, LLVM. TargetMachine (LLVM. Target (triple = clean_triple (platform)), clean_triple (platform), cpu, features), nothing , false )
3940
4041function StaticTarget (triple:: String , cpu:: String , features:: String )
4142 platform = tryparse (Platform, triple)
@@ -50,6 +51,9 @@ Set the compiler for cross compilation
5051"""
5152set_compiler! (target:: StaticTarget , compiler:: String ) = (target. compiler = compiler)
5253
54+
55+ set_runtime! (target:: StaticTarget , julia_runtime:: Bool ) = (target. julia_runtime = julia_runtime)
56+
5357"""
5458```julia
5559@device_override old_bad_method(arg1::Type1, arg2::Type2) = new_good_method(arg1, arg2)
@@ -79,6 +83,7 @@ struct StaticCompilerTarget{MT} <: GPUCompiler.AbstractCompilerTarget
7983 triple:: String
8084 cpu:: String
8185 features:: String
86+ julia_runtime:: Bool
8287 method_table:: MT
8388end
8489
@@ -115,6 +120,7 @@ GPUCompiler.runtime_module(::GPUCompiler.CompilerJob{<:StaticCompilerTarget, Sta
115120GPUCompiler. can_throw (job:: GPUCompiler.CompilerJob{<:StaticCompilerTarget, StaticCompilerParams} ) = true
116121GPUCompiler. can_throw (job:: GPUCompiler.CompilerJob{<:StaticCompilerTarget} ) = true
117122
123+ GPUCompiler. uses_julia_runtime (job:: GPUCompiler.CompilerJob{<:StaticCompilerTarget} ) = job. config. target. julia_runtime
118124GPUCompiler. get_interpreter (job:: GPUCompiler.CompilerJob{<:StaticCompilerTarget, StaticCompilerParams} ) =
119125 StaticInterpreter (job. config. params. cache, GPUCompiler. method_table (job), job. world,
120126 GPUCompiler. inference_params (job), GPUCompiler. optimization_params (job))
@@ -131,7 +137,7 @@ function static_job(@nospecialize(func::Function), @nospecialize(types::Type);
131137 )
132138 source = methodinstance (typeof (func), Base. to_tuple_type (types))
133139 tm = target. tm
134- gputarget = StaticCompilerTarget (LLVM. triple (tm), LLVM. cpu (tm), LLVM. features (tm), method_table)
140+ gputarget = StaticCompilerTarget (LLVM. triple (tm), LLVM. cpu (tm), LLVM. features (tm), target . julia_runtime, method_table)
135141 params = StaticCompilerParams ()
136142 config = GPUCompiler. CompilerConfig (gputarget, params, name = name, kernel = kernel)
137143 StaticCompiler. CompilerJob (source, config), kwargs
@@ -145,7 +151,7 @@ function static_job(@nospecialize(func), @nospecialize(types);
145151)
146152 source = methodinstance (typeof (func), Base. to_tuple_type (types))
147153 tm = target. tm
148- gputarget = StaticCompilerTarget (LLVM. triple (tm), LLVM. cpu (tm), LLVM. features (tm), method_table)
154+ gputarget = StaticCompilerTarget (LLVM. triple (tm), LLVM. cpu (tm), LLVM. features (tm), target . julia_runtime, method_table)
149155 params = StaticCompilerParams ()
150156 config = GPUCompiler. CompilerConfig (gputarget, params, name = name, kernel = kernel)
151157 StaticCompiler. CompilerJob (source, config), kwargs
0 commit comments