Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ A number providing the pagesize of the given OS. Common values being 4kb or 64k
"""
global PAGESIZE::Clong

"""
Sys.BASE_SYSIMG_TARGET::String

A string representing the specific CPU target string used to compile the Base sysimage.

Note: Included in the detailed system information via `versioninfo(verbose=true)`.
"""
global BASE_SYSIMG_TARGET::String

function __init__()
env_threads = nothing
if haskey(ENV, "JULIA_CPU_THREADS")
Expand All @@ -169,6 +178,7 @@ function __init__()
global SC_CLK_TCK = ccall(:jl_SC_CLK_TCK, Clong, ())
global CPU_NAME = ccall(:jl_get_cpu_name, Ref{String}, ())
global JIT = ccall(:jl_get_JIT, Ref{String}, ())
global BASE_SYSIMG_TARGET = sysimage_target()
global PAGESIZE = Int(Sys.isunix() ? ccall(:jl_getpagesize, Clong, ()) : ccall(:jl_getallocationgranularity, Clong, ()))
__init_build()
nothing
Expand Down
2 changes: 2 additions & 0 deletions src/codegen-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ JL_DLLEXPORT void* JLJITMangleAndIntern_fallback(void* JIT, const char *Name) UN

JL_DLLEXPORT const char *JLJITGetTripleString_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT const char *JLJITGetCPUString_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT const char JLJITGetGlobalPrefix_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT const char *JLJITGetDataLayoutString_fallback(void* JIT) UNAVAILABLE
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@
YY(JLJITLookup) \
YY(JLJITMangleAndIntern) \
YY(JLJITGetTripleString) \
YY(JLJITGetCPUString) \
YY(JLJITGetGlobalPrefix) \
YY(JLJITGetDataLayoutString) \
YY(JLJITGetIRCompileLayer) \
Expand Down
7 changes: 7 additions & 0 deletions src/llvm_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ JLJITGetTripleString_impl(JuliaOJITRef JIT)
return unwrap(JIT)->getTargetTriple().str().c_str();
}

JL_DLLEXPORT_CODEGEN const char *
JLJITGetCPUString_impl(JuliaOJITRef JIT)
{
static std::string target_cpu = unwrap(JIT)->getTargetCPU().str();
return target_cpu.c_str();
}

JL_DLLEXPORT_CODEGEN char
JLJITGetGlobalPrefix_impl(JuliaOJITRef JIT)
{
Expand Down
64 changes: 38 additions & 26 deletions stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,40 @@ See also: [`VERSION`](@ref).
"""
function versioninfo(io::IO=stdout; verbose::Bool=false)
println(io, "Julia Version $VERSION")
println(io, "Build Info:")
if Base.isdebugbuild()
println(io, " DEBUG build")
end
if !isempty(Base.TAGGED_RELEASE_BANNER)
println(io, " ", Base.TAGGED_RELEASE_BANNER)
end
if !isempty(Base.GIT_VERSION_INFO.commit_short_raw)
println(io, "Commit $(Base.GIT_VERSION_INFO.commit_short) ($(Base.GIT_VERSION_INFO.date_string))")
println(io, " Commit $(Base.GIT_VERSION_INFO.commit_short) ($(Base.GIT_VERSION_INFO.date_string))")
end
println(io, " GC: ", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ())))
if verbose
println(io, " Sysimage: ", Sys.BASE_SYSIMG_TARGET, " (", Sys.MACHINE, ")")
end
official_release = Base.TAGGED_RELEASE_BANNER == "Official https://julialang.org release"
if Base.isdebugbuild() || !isempty(Base.TAGGED_RELEASE_BANNER) || (Base.GIT_VERSION_INFO.tagged_commit && !official_release)
println(io, "Build Info:")
if Base.isdebugbuild()
println(io, " DEBUG build")
end
if !isempty(Base.TAGGED_RELEASE_BANNER)
println(io, " ", Base.TAGGED_RELEASE_BANNER)
end
if Base.GIT_VERSION_INFO.tagged_commit && !official_release
println(io,
"""

Note: This is an unofficial build, please report bugs to the project
responsible for this build and not to the Julia project unless you can
reproduce the issue using official builds available at https://julialang.org
"""
)
end
if Base.GIT_VERSION_INFO.tagged_commit && !official_release
println(io,
"""

Note: This is an unofficial build, please report bugs to the project
responsible for this build and not to the Julia project unless you can
reproduce the issue using official builds available at https://julialang.org
"""
)
end

jit_cpu, jit_triple = let _jit = ccall(:JLJITGetJuliaOJIT, Ptr{Cvoid}, ())
_cpu = unsafe_string(ccall(:JLJITGetCPUString, Cstring, (Ptr{Cvoid},), _jit))
_triple = unsafe_string(ccall(:JLJITGetTripleString, Cstring, (Ptr{Cvoid},), _jit))
_cpu, _triple
end
println(io, "Platform Info:")
println(io, " OS: ", Sys.iswindows() ? "Windows" : Sys.isapple() ?
"macOS" : Sys.KERNEL, " (", Sys.MACHINE, ")")
"macOS" : Sys.KERNEL, " (", jit_triple, ")")

if verbose
lsb = ""
Expand All @@ -148,25 +156,29 @@ function versioninfo(io::IO=stdout; verbose::Bool=false)
if verbose
cpuio = IOBuffer() # print cpu_summary with correct alignment
Sys.cpu_summary(cpuio)
for (i, line) in enumerate(split(chomp(takestring!(cpuio)), "\n"))
for (i, _line) in enumerate(split(chomp(takestring!(cpuio)), "\n"))
prefix = i == 1 ? " CPU: " : " "
line = if i == 1
strip(x -> isspace(x) || x == ':', _line) * " (" * Sys.CPU_NAME * "):"
else
_line
end
println(io, prefix, line)
end
else
cpu = Sys.cpu_info()
println(io, " CPU: ", length(cpu), " × ", cpu[1].model)
println(io, " CPU: ", length(cpu), " × ", cpu[1].model, " (", Sys.CPU_NAME, ")")
end

if verbose
println(io, " Memory: $(Sys.total_memory()/2^30) GB ($(Sys.free_memory()/2^20) MB free)")
println(io, " Memory: $(Sys.total_memory()/2^30) GiB ($(Sys.free_memory()/2^20) MiB free)")
try println(io, " Uptime: $(Sys.uptime()) sec"); catch; end
print(io, " Load Avg: ")
Base.print_matrix(io, Sys.loadavg()')
println(io)
println(io, " WORD_SIZE: ", Sys.WORD_SIZE)
end
println(io, " WORD_SIZE: ", Sys.WORD_SIZE)
println(io, " LLVM: libLLVM-",Base.libllvm_version," (", Sys.JIT, ", ", Sys.CPU_NAME, ")")
println(io, " GC: ", unsafe_string(ccall(:jl_gc_active_impl, Ptr{UInt8}, ())))
println(io, " LLVM: libLLVM-", Base.libllvm_version, " (", Sys.JIT, ", ", jit_cpu, ")")
println(io, """Threads: $(Threads.nthreads(:default)) default, $(Threads.nthreads(:interactive)) interactive, \
$(Threads.ngcthreads()) GC (on $(Sys.CPU_THREADS) virtual cores)""")

Expand Down
13 changes: 10 additions & 3 deletions test/llvmcall2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ end
function JLJITGetTripleString(JIT)
ccall(:JLJITGetTripleString, Cstring, (Ptr{Cvoid},), JIT)
end
function JLJITGetCPUString(JIT)
ccall(:JLJITGetCPUString, Cstring, (Ptr{Cvoid},), JIT)
end
jit = JLJITGetJuliaOJIT()
str = JLJITGetTripleString(jit)
jl_str = unsafe_string(str)
@test length(jl_str) > 4
triple_str = JLJITGetTripleString(jit)
jl_triple_str = unsafe_string(triple_str)
@test length(jl_triple_str) > 4

cpu_str = JLJITGetCPUString(jit)
jl_cpu_str = unsafe_string(cpu_str)
@test length(jl_cpu_str) > 4
end


Expand Down
Loading