Skip to content

Commit

Permalink
cache musl version
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed Aug 19, 2021
1 parent fce4f2f commit db598ae
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/runtime_musl_workaround.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,21 @@ function get_musl_dso_type(musl_version::VersionNumber)
end
end

_musl_version = Ref{Union{Nothing,VersionNumber}}(nothing)
function get_musl_version()
if _musl_version[] !== nothing
return _musl_version[]
end

stderr = IOBuffer()
run(pipeline(ignorestatus(`/lib/libc.musl-x86_64.so.1 --version`); stdout=Base.devnull, stderr))

version = nothing
for line in split(String(take!(stderr)), "\n")
if startswith(line, "Version ")
version = parse(VersionNumber, line[9:end])
_musl_version[] = parse(VersionNumber, line[9:end])
end
end
return version
return _musl_version[]
end

function parse_soname(dso::musl_dso)
Expand Down Expand Up @@ -186,7 +190,7 @@ function replace_musl_shortname(lib_handle::Ptr{Cvoid})
end
@debug("Auto-detected musl version", version=musl_version)

dso_type = get_musl_dso_type(musl_version)
dso_type = get_musl_dso_type()
if dso_type === nothing
@debug("Unsupported musl ABI version", musl_version)
return lib_handle
Expand Down

0 comments on commit db598ae

Please sign in to comment.