Skip to content

Commit db598ae

Browse files
committed
cache musl version
1 parent fce4f2f commit db598ae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/runtime_musl_workaround.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,21 @@ function get_musl_dso_type(musl_version::VersionNumber)
127127
end
128128
end
129129

130+
_musl_version = Ref{Union{Nothing,VersionNumber}}(nothing)
130131
function get_musl_version()
132+
if _musl_version[] !== nothing
133+
return _musl_version[]
134+
end
135+
131136
stderr = IOBuffer()
132137
run(pipeline(ignorestatus(`/lib/libc.musl-x86_64.so.1 --version`); stdout=Base.devnull, stderr))
133138

134-
version = nothing
135139
for line in split(String(take!(stderr)), "\n")
136140
if startswith(line, "Version ")
137-
version = parse(VersionNumber, line[9:end])
141+
_musl_version[] = parse(VersionNumber, line[9:end])
138142
end
139143
end
140-
return version
144+
return _musl_version[]
141145
end
142146

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

189-
dso_type = get_musl_dso_type(musl_version)
193+
dso_type = get_musl_dso_type()
190194
if dso_type === nothing
191195
@debug("Unsupported musl ABI version", musl_version)
192196
return lib_handle

0 commit comments

Comments
 (0)