Skip to content

Commit e3412cb

Browse files
committed
Prepare code for future endeavours into adding the GC
1 parent ac2d56f commit e3412cb

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/StaticCompiler.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ end
398398

399399
function static_code_llvm(@nospecialize(func), @nospecialize(types); target::StaticTarget=StaticTarget(), kwargs...)
400400
job, kwargs = static_job(func, types; target, kwargs...)
401-
GPUCompiler.code_llvm(stdout, job; kwargs...)
401+
GPUCompiler.code_llvm(stdout, job; libraries=false, kwargs...)
402402
end
403403

404404
function static_code_typed(@nospecialize(func), @nospecialize(types); target::StaticTarget=StaticTarget(), kwargs...)
@@ -408,7 +408,7 @@ end
408408

409409
function static_code_native(@nospecialize(f), @nospecialize(tt), fname=fix_name(f); target::StaticTarget=StaticTarget(), kwargs...)
410410
job, kwargs = static_job(f, tt; fname, target, kwargs...)
411-
GPUCompiler.code_native(stdout, job; kwargs...)
411+
GPUCompiler.code_native(stdout, job; libraries=false, kwargs...)
412412
end
413413

414414
# Return an LLVM module
@@ -418,7 +418,7 @@ function static_llvm_module(f, tt, name=fix_name(f); demangle=true, target::Stat
418418
end
419419
job, kwargs = static_job(f, tt; name, target, kwargs...)
420420
m = GPUCompiler.JuliaContext() do context
421-
m, _ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false)
421+
m, _ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false, libraries=false)
422422
locate_pointers_and_runtime_calls(m)
423423
m
424424
end
@@ -434,7 +434,7 @@ function static_llvm_module(funcs::Union{Array,Tuple}; demangle=true, target::St
434434
name_f = "julia_"*name_f
435435
end
436436
job, kwargs = static_job(f, tt; name = name_f, target, kwargs...)
437-
mod,_ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false)
437+
mod,_ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false, libraries=false)
438438
if length(funcs) > 1
439439
for func in funcs[2:end]
440440
f,tt = func
@@ -443,7 +443,7 @@ function static_llvm_module(funcs::Union{Array,Tuple}; demangle=true, target::St
443443
name_f = "julia_"*name_f
444444
end
445445
job, kwargs = static_job(f, tt; name = name_f, target, kwargs...)
446-
tmod,_ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false)
446+
tmod,_ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false, libraries=false)
447447
link!(mod,tmod)
448448
end
449449
end

src/target.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3233
end
3334

3435
clean_triple(platform::Platform) = arch(platform) * os_str(platform) * libc_str(platform)
3536
StaticTarget() = 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

4041
function StaticTarget(triple::String, cpu::String, features::String)
4142
platform = tryparse(Platform, triple)
@@ -50,6 +51,9 @@ Set the compiler for cross compilation
5051
"""
5152
set_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
8388
end
8489

@@ -115,6 +120,7 @@ GPUCompiler.runtime_module(::GPUCompiler.CompilerJob{<:StaticCompilerTarget, Sta
115120
GPUCompiler.can_throw(job::GPUCompiler.CompilerJob{<:StaticCompilerTarget, StaticCompilerParams}) = true
116121
GPUCompiler.can_throw(job::GPUCompiler.CompilerJob{<:StaticCompilerTarget}) = true
117122

123+
GPUCompiler.uses_julia_runtime(job::GPUCompiler.CompilerJob{<:StaticCompilerTarget}) = job.config.target.julia_runtime
118124
GPUCompiler.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

Comments
 (0)