Skip to content

Commit 4995b4d

Browse files
committed
Fix library search inclusion
First, it was far too strict, using the `Pkg.BinaryPlatforms.valid_dl_path()` function which wants to parse out a version number as well. Second, it wasn't properly collapsing symlinks and rejecting dependency artifact libraries because `bin_files` must contain all libraries, but `shlib_files` should not, it should only contain libraries built by this package.
1 parent a440851 commit 4995b4d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Auditor.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
6464
translate_symlinks(prefix.path; verbose=verbose)
6565

6666
# Inspect binary files, looking for improper linkage
67-
predicate = f -> (filemode(f) & 0o111) != 0 || valid_dl_path(f, platform)
67+
predicate = f -> (filemode(f) & 0o111) != 0 || valid_library_path(f, platform)
6868
bin_files = collect_files(prefix, predicate; exclude_externalities=false)
6969
for f in collapse_symlinks(bin_files)
7070
# If `f` is outside of our prefix, ignore it. This happens with files from our dependencies
@@ -115,7 +115,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
115115
end
116116

117117
# Find all dynamic libraries
118-
shlib_files = filter(f -> valid_dl_path(f, platform), bin_files)
118+
shlib_files = filter(f -> startswith(f, prefix.path) && valid_library_path(f, platform), collapse_symlinks(bin_files))
119119

120120
for f in shlib_files
121121
# Inspect all shared library files for our platform (but only if we're
@@ -185,7 +185,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
185185
# If we're targeting a windows platform, check to make sure no .dll
186186
# files are sitting in `$prefix/lib`, as that's a no-no. This is
187187
# not a fatal offense, but we'll yell about it.
188-
lib_dll_files = filter(f -> valid_dl_path(f, platform), collect_files(joinpath(prefix, "lib"), predicate))
188+
lib_dll_files = filter(f -> valid_library_path(f, platform), collect_files(joinpath(prefix, "lib"), predicate))
189189
for f in lib_dll_files
190190
if !silent
191191
@warn("$(relpath(f, prefix.path)) should be in `bin`!")

src/auditor/dynamic_linkage.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,16 @@ function is_default_lib(lib, ::ELFHandle)
249249
return lowercase(basename(lib)) in default_libs
250250
end
251251

252+
function valid_library_path(f::AbstractString, p::Platform)
253+
if Sys.iswindows(p)
254+
return endswith(f, ".dll")
255+
elseif Sys.isapple(p)
256+
return endswith(f, ".dylib")
257+
else
258+
return ismatch(r".*.so(\.[\d]+)*", f)
259+
end
260+
end
261+
252262
function patchelf_flags(p::Platform)
253263
flags = []
254264

0 commit comments

Comments
 (0)