Skip to content

Commit 1b8452f

Browse files
Teach audit to check multiple CSL libraries (#932)
* Teach audit to check multiple CSL libraries In addition to `libgomp`, it's possible that a library links against libatomic, so we need to check also that one. * Update src/auditor/compiler_abi.jl Co-authored-by: Elliot Saba <[email protected]> Co-authored-by: Elliot Saba <[email protected]>
1 parent a00f297 commit 1b8452f

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/Auditor.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
9090
if isdynamic(oh)
9191
# Check that the libgfortran version matches
9292
all_ok &= check_libgfortran_version(oh, platform; verbose=verbose, has_csl = has_csl)
93-
# Check whether the library depends on libgomp
94-
all_ok &= check_libgomp(oh, platform; verbose=verbose, has_csl = has_csl)
93+
# Check whether the library depends on any of the most common
94+
# libraries provided by `CompilerSupportLibraries_jll`.
95+
all_ok &= check_csl_libs(oh, platform; verbose=verbose, has_csl=has_csl)
9596
# Check that the libstdcxx string ABI matches
9697
all_ok &= check_cxxstring_abi(oh, platform; verbose=verbose)
9798
# Check that this binary file's dynamic linkage works properly. Note to always

src/auditor/compiler_abi.jl

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,33 @@ function check_libgfortran_version(oh::ObjectHandle, platform::AbstractPlatform;
6363
return true
6464
end
6565

66-
function check_libgomp(oh::ObjectHandle, platform::AbstractPlatform; verbose::Bool = false,
67-
has_csl::Bool = true)
68-
has_libgomp = false
69-
try
70-
libs = basename.(path.(DynamicLinks(oh)))
71-
has_libgomp = length(filter(l -> occursin("libgomp", l), libs)) >= 1
66+
function check_csl_libs(oh::ObjectHandle, platform::AbstractPlatform; verbose::Bool=false,
67+
has_csl::Bool=true, csl_libs::Vector{String}=["libgomp", "libatomic"])
68+
if has_csl
69+
# No need to do any check, CompilerSupportLibraries_jll is already a dependency
70+
return true
71+
end
72+
73+
# Collect list of dependencies
74+
libs = try
75+
basename.(path.(DynamicLinks(oh)))
7276
catch e
7377
if isa(e, InterruptException)
7478
rethrow(e)
7579
end
76-
@warn "$(path(oh)) could not be scanned for libgomp dependency!" exception=(e, catch_backtrace())
80+
@warn "$(path(oh)) could not be scanned for $(lib) dependency!" exception=(e, catch_backtrace())
7781
return true
7882
end
7983

80-
if !has_csl && has_libgomp
81-
csl_warning("libgomp")
82-
return false
84+
# If any of the libs is a library provided by
85+
# `CompilerSupportLibraries_jll`, suggest to add the package as dependency
86+
for lib in csl_libs
87+
if length(filter(l -> occursin(lib, l), libs)) >= 1
88+
csl_warning(lib)
89+
return false
90+
end
8391
end
92+
8493
return true
8594
end
8695

0 commit comments

Comments
 (0)