Skip to content

Commit ececa9a

Browse files
committed
Include JIT target cpu and target triple in versioninfo
1 parent 5bd0671 commit ececa9a

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

src/codegen-stubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ JL_DLLEXPORT void* JLJITMangleAndIntern_fallback(void* JIT, const char *Name) UN
156156

157157
JL_DLLEXPORT const char *JLJITGetTripleString_fallback(void* JIT) UNAVAILABLE
158158

159+
JL_DLLEXPORT const char *JLJITGetCPUString_fallback(void* JIT) UNAVAILABLE
160+
159161
JL_DLLEXPORT const char JLJITGetGlobalPrefix_fallback(void* JIT) UNAVAILABLE
160162

161163
JL_DLLEXPORT const char *JLJITGetDataLayoutString_fallback(void* JIT) UNAVAILABLE

src/jl_exported_funcs.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@
560560
YY(JLJITLookup) \
561561
YY(JLJITMangleAndIntern) \
562562
YY(JLJITGetTripleString) \
563+
YY(JLJITGetCPUString) \
563564
YY(JLJITGetGlobalPrefix) \
564565
YY(JLJITGetDataLayoutString) \
565566
YY(JLJITGetIRCompileLayer) \

src/llvm_api.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ JLJITGetTripleString_impl(JuliaOJITRef JIT)
123123
return unwrap(JIT)->getTargetTriple().str().c_str();
124124
}
125125

126+
JL_DLLEXPORT_CODEGEN const char *
127+
JLJITGetCPUString_impl(JuliaOJITRef JIT)
128+
{
129+
static std::string target_cpu = unwrap(JIT)->getTargetCPU().str();
130+
return target_cpu.c_str();
131+
}
132+
126133
JL_DLLEXPORT_CODEGEN char
127134
JLJITGetGlobalPrefix_impl(JuliaOJITRef JIT)
128135
{

stdlib/InteractiveUtils/src/InteractiveUtils.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,15 @@ function versioninfo(io::IO=stdout; verbose::Bool=false)
127127
"""
128128
)
129129
end
130+
131+
jit_cpu, jit_triple = let _jit = ccall(:JLJITGetJuliaOJIT, Ptr{Cvoid}, ())
132+
_cpu = unsafe_string(ccall(:JLJITGetCPUString, Cstring, (Ptr{Cvoid},), _jit))
133+
_triple = unsafe_string(ccall(:JLJITGetTripleString, Cstring, (Ptr{Cvoid},), _jit))
134+
_cpu, _triple
135+
end
130136
println(io, "Platform Info:")
131137
println(io, " OS: ", Sys.iswindows() ? "Windows" : Sys.isapple() ?
132-
"macOS" : Sys.KERNEL, " (", Sys.MACHINE, ")")
138+
"macOS" : Sys.KERNEL, " (", jit_triple, ")")
133139

134140
if verbose
135141
lsb = ""
@@ -172,7 +178,7 @@ function versioninfo(io::IO=stdout; verbose::Bool=false)
172178
println(io)
173179
println(io, " WORD_SIZE: ", Sys.WORD_SIZE)
174180
end
175-
println(io, " LLVM: libLLVM-", Base.libllvm_version, " (", Sys.JIT, ")")
181+
println(io, " LLVM: libLLVM-", Base.libllvm_version, " (", Sys.JIT, ", ", jit_cpu, ")")
176182
println(io, """Threads: $(Threads.nthreads(:default)) default, $(Threads.nthreads(:interactive)) interactive, \
177183
$(Threads.ngcthreads()) GC (on $(Sys.CPU_THREADS) virtual cores)""")
178184

test/llvmcall2.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ end
6868
function JLJITGetTripleString(JIT)
6969
ccall(:JLJITGetTripleString, Cstring, (Ptr{Cvoid},), JIT)
7070
end
71+
function JLJITGetCPUString(JIT)
72+
ccall(:JLJITGetCPUString, Cstring, (Ptr{Cvoid},), JIT)
73+
end
7174
jit = JLJITGetJuliaOJIT()
72-
str = JLJITGetTripleString(jit)
73-
jl_str = unsafe_string(str)
74-
@test length(jl_str) > 4
75+
triple_str = JLJITGetTripleString(jit)
76+
jl_triple_str = unsafe_string(triple_str)
77+
@test length(jl_triple_str) > 4
78+
79+
cpu_str = JLJITGetCPUString(jit)
80+
jl_cpu_str = unsafe_string(cpu_str)
81+
@test length(jl_cpu_str) > 4
7582
end
7683

7784

0 commit comments

Comments
 (0)