Skip to content

Commit 96bccb8

Browse files
committed
Show the plaform triplet in each warning and error from the auditor
Makes it a bit easier to nail down which platforms are producing the warnings.
1 parent 3bdbf48 commit 96bccb8

9 files changed

+49
-49
lines changed

src/Auditor.jl

+14-14
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
8484
readmeta(f) do oh
8585
if !is_for_platform(oh, platform)
8686
if verbose
87-
@warn("Skipping binary analysis of $(relpath(f, prefix.path)) (incorrect platform)")
87+
@warn("Skipping binary analysis of $(relpath(f, prefix.path)) (incorrect platform)", platform=triplet(platform))
8888
end
8989
else
9090
# Check that the ISA isn't too high
@@ -97,7 +97,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
9797
# should be done when autofix=true, but we have to run this fix on MKL
9898
# for Windows, for which however we have to set autofix=false:
9999
# https://github.com/JuliaPackaging/Yggdrasil/pull/922.
100-
all_ok &= ensure_executability(oh; verbose, silent)
100+
all_ok &= ensure_executability(oh, platform; verbose, silent)
101101

102102
# If this is a dynamic object, do the dynamic checks
103103
if isdynamic(oh)
@@ -168,7 +168,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
168168
# TODO: Use the relevant ObjFileBase packages to inspect why
169169
# this file is being nasty to us.
170170
if !silent
171-
@warn("$(relpath(f, prefix.path)) cannot be dlopen()'ed")
171+
@warn("$(relpath(f, prefix.path)) cannot be dlopen()'ed", platform=triplet(platform))
172172
end
173173
all_ok = false
174174
end
@@ -181,7 +181,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
181181
end
182182

183183
# Ensure that this library is available at its own SONAME
184-
all_ok &= symlink_soname_lib(f; verbose=verbose, autofix=autofix)
184+
all_ok &= symlink_soname_lib(f, platform; verbose=verbose, autofix=autofix)
185185
end
186186

187187
# remove *.la files generated by GNU libtool
@@ -228,7 +228,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
228228
lib_dll_files = filter(f -> valid_library_path(f, platform), collect_files(joinpath(prefix, "lib"), predicate))
229229
for f in lib_dll_files
230230
if !silent
231-
@warn("$(relpath(f, prefix.path)) should be in `bin`!")
231+
@warn("$(relpath(f, prefix.path)) should be in `bin`!", platform=triplet(platform))
232232
end
233233
end
234234

@@ -239,7 +239,7 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
239239
outside_dll_files = [f for f in shlib_files if !(f in lib_dll_files)]
240240
if autofix && !isempty(lib_dll_files) && isempty(outside_dll_files)
241241
if !silent
242-
@warn("Simple buildsystem detected; Moving all `.dll` files to `bin`!")
242+
@warn("Simple buildsystem detected; Moving all `.dll` files to `bin`!", platform=triplet(platform))
243243
end
244244

245245
mkpath(joinpath(prefix, "bin"))
@@ -269,10 +269,10 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
269269
all_files = collect_files(prefix, predicate)
270270

271271
# Search for absolute paths in this prefix
272-
all_ok &= check_absolute_paths(prefix, all_files; silent=silent)
272+
all_ok &= check_absolute_paths(prefix, platform, all_files; silent=silent)
273273

274274
# Search for case-sensitive ambiguities
275-
all_ok &= check_case_sensitivity(prefix)
275+
all_ok &= check_case_sensitivity(prefix, platform)
276276
return all_ok
277277
end
278278

@@ -320,7 +320,7 @@ function check_isa(oh, platform, prefix;
320320
Minimum instruction set detected for $(relpath(path(oh), prefix.path)) is
321321
$(detected_march), not $(last(platform_marchs)) as desired.
322322
""", '\n' => ' ')
323-
@warn(strip(msg))
323+
@warn(strip(msg), platform=triplet(platform))
324324
end
325325
return false
326326
elseif detected_march != last(platform_marchs)
@@ -334,7 +334,7 @@ function check_isa(oh, platform, prefix;
334334
$(detected_march), not $(last(platform_marchs)) as desired.
335335
You may be missing some optimization flags during compilation.
336336
""", '\n' => ' ')
337-
@warn(strip(msg))
337+
@warn(strip(msg), platform=triplet(platform))
338338
end
339339
end
340340
return true
@@ -392,22 +392,22 @@ function check_dynamic_linkage(oh, prefix, bin_files;
392392
end
393393
else
394394
if !silent
395-
@warn("Linked library $(libname) could not be resolved and could not be auto-mapped")
395+
@warn("Linked library $(libname) could not be resolved and could not be auto-mapped", platform=triplet(platform))
396396
if is_troublesome_library_link(libname, platform)
397-
@warn("Depending on $(libname) is known to cause problems at runtime, make sure to link against the JLL library instead")
397+
@warn("Depending on $(libname) is known to cause problems at runtime, make sure to link against the JLL library instead", platform=triplet(platform))
398398
end
399399
end
400400
all_ok = false
401401
end
402402
else
403403
if !silent
404-
@warn("Linked library $(libname) could not be resolved within the given prefix")
404+
@warn("Linked library $(libname) could not be resolved within the given prefix", platform=triplet(platform))
405405
end
406406
all_ok = false
407407
end
408408
elseif !startswith(libs[libname], prefix.path)
409409
if !silent
410-
@warn("Linked library $(libname) (resolved path $(libs[libname])) is not within the given prefix")
410+
@warn("Linked library $(libname) (resolved path $(libs[libname])) is not within the given prefix", platform=triplet(platform))
411411
end
412412
all_ok = false
413413
end

src/AutoBuild.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ function autobuild(dir::AbstractString,
958958
products_info[p] = Dict("path" => relpath(product_path, dest_prefix.path))
959959
if p isa LibraryProduct || p isa FrameworkProduct
960960
products_info[p]["soname"] = something(
961-
Auditor.get_soname(product_path),
961+
Auditor.get_soname(product_path, platform),
962962
basename(product_path),
963963
)
964964
end
@@ -969,7 +969,7 @@ function autobuild(dir::AbstractString,
969969
cleanup_dependencies(prefix, target_artifact_paths, concrete_platform)
970970

971971
# Search for dead links in dest_prefix; raise warnings about them.
972-
Auditor.warn_deadlinks(dest_prefix.path)
972+
Auditor.warn_deadlinks(dest_prefix.path, platform)
973973

974974
# Cull empty directories, for neatness' sake, unless auditing is disabled
975975
if !skip_audit
@@ -1216,7 +1216,7 @@ function rebuild_jll_package(name::String, build_version::VersionNumber, sources
12161216
products_info[p] = Dict("path" => relpath(product_path, dest_prefix))
12171217
if p isa LibraryProduct || p isa FrameworkProduct
12181218
products_info[p]["soname"] = something(
1219-
Auditor.get_soname(product_path),
1219+
Auditor.get_soname(product_path, platform),
12201220
basename(product_path),
12211221
)
12221222
end

src/auditor/compiler_abi.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function check_libgfortran_version(oh::ObjectHandle, platform::AbstractPlatform;
3737
if isa(e, InterruptException)
3838
rethrow(e)
3939
end
40-
@warn "$(path(oh)) could not be scanned for libgfortran dependency!" exception=(e, catch_backtrace())
40+
@warn "$(path(oh)) could not be scanned for libgfortran dependency!" platform=triplet(platform) exception=(e, catch_backtrace())
4141
return true
4242
end
4343

@@ -57,7 +57,7 @@ function check_libgfortran_version(oh::ObjectHandle, platform::AbstractPlatform;
5757
definition in your `build_tarballs.jl` file, add the line:
5858
""", '\n' => ' '))
5959
msg *= "\n\n platforms = expand_gfortran_versions(platforms)"
60-
@warn(msg)
60+
@warn(msg, platform=triplet(platform))
6161
return false
6262
end
6363

@@ -67,7 +67,7 @@ function check_libgfortran_version(oh::ObjectHandle, platform::AbstractPlatform;
6767
for libgfortran$(libgfortran_version(platform).major). This usually indicates that
6868
the build system is somehow ignoring our choice of compiler!
6969
""", '\n' => ' '))
70-
@warn(msg)
70+
@warn(msg, platform=triplet(platform))
7171
return false
7272
end
7373
return true
@@ -87,7 +87,7 @@ function check_csl_libs(oh::ObjectHandle, platform::AbstractPlatform; verbose::B
8787
if isa(e, InterruptException)
8888
rethrow(e)
8989
end
90-
@warn "$(path(oh)) could not be scanned for $(lib) dependency!" exception=(e, catch_backtrace())
90+
@warn "$(path(oh)) could not be scanned for $(lib) dependency!" platform=triplet(platform) exception=(e, catch_backtrace())
9191
return true
9292
end
9393

@@ -140,7 +140,7 @@ function check_libstdcxx_version(oh::ObjectHandle, platform::AbstractPlatform; v
140140
if isa(e, InterruptException)
141141
rethrow(e)
142142
end
143-
@warn "$(path(oh)) could not be scanned for libstdcxx dependency!" exception=(e, catch_backtrace())
143+
@warn "$(path(oh)) could not be scanned for libstdcxx dependency!" platform=triplet(platform) exception=(e, catch_backtrace())
144144
return true
145145
end
146146

@@ -216,7 +216,7 @@ function detect_cxxstring_abi(oh::ObjectHandle, platform::AbstractPlatform)
216216
if isa(e, InterruptException)
217217
rethrow(e)
218218
end
219-
@warn "$(path(oh)) could not be scanned for cxx11 ABI!" exception=(e, catch_backtrace())
219+
@warn "$(path(oh)) could not be scanned for cxx11 ABI!" platform=triplet(platform) exception=(e, catch_backtrace())
220220
end
221221
return nothing
222222
end
@@ -244,7 +244,7 @@ function check_cxxstring_abi(oh::ObjectHandle, platform::AbstractPlatform; io::I
244244
definition in your `build_tarballs.jl` file, add the line:
245245
""", '\n' => ' '))
246246
msg *= "\n\n platforms = expand_cxxstring_abis(platforms)"
247-
@warn(msg)
247+
@warn(msg, platform=triplet(platform))
248248
return false
249249
end
250250

@@ -255,7 +255,7 @@ function check_cxxstring_abi(oh::ObjectHandle, platform::AbstractPlatform; io::I
255255
indicates that the build system is somehow ignoring our choice of compiler, as we manually
256256
insert the correct compiler flags for this ABI choice!
257257
""", '\n' => ' '))
258-
@warn(msg)
258+
@warn(msg, platform=triplet(platform))
259259
return false
260260
end
261261
return true

src/auditor/extra_checks.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function check_os_abi(oh::ObjectHandle, p::AbstractPlatform, rest...; verbose::B
1313
$(basename(path(oh))) has an ELF header OS/ABI value that is not set to FreeBSD
1414
($(ELF.ELFOSABI_FREEBSD)), this may be an issue at link time
1515
""", '\n' => ' ')
16-
@warn(strip(msg))
16+
@warn(strip(msg), platform=triplet(p))
1717
end
1818
return false
1919
end
@@ -24,7 +24,7 @@ function check_os_abi(oh::ObjectHandle, p::AbstractPlatform, rest...; verbose::B
2424
# means "no specific float ABI", `0x400` == EF_ARM_ABI_FLOAT_HARD.
2525
if header(oh).e_flags & 0xF00 (0x000, 0x400)
2626
if verbose
27-
@error("$(basename(path(oh))) does not match the hard-float ABI")
27+
@error("$(basename(path(oh))) does not match the hard-float ABI", platform=triplet(p))
2828
end
2929
return false
3030
end

src/auditor/filesystems.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
function check_case_sensitivity(prefix::Prefix)
1+
function check_case_sensitivity(prefix::Prefix, platform::AbstractPlatform)
22
all_ok = true
33

44
function check_set(root, list)
55
lowered = Set()
66
for f in list
77
lf = lowercase(f)
88
if lf in lowered
9-
@warn("$(relpath(joinpath(root, f), prefix.path)) causes a case-sensitivity ambiguity!")
9+
@warn("$(relpath(joinpath(root, f), prefix.path)) causes a case-sensitivity ambiguity!", platform=triplet(platform))
1010
all_ok = false
1111
end
1212
push!(lowered, lf)
@@ -22,7 +22,7 @@ function check_case_sensitivity(prefix::Prefix)
2222
end
2323

2424

25-
function check_absolute_paths(prefix::Prefix, all_files::Vector; silent::Bool = false)
25+
function check_absolute_paths(prefix::Prefix, platform::AbstractPlatform, all_files::Vector; silent::Bool = false)
2626
# Finally, check for absolute paths in any files. This is not a "fatal"
2727
# offense, as many files have absolute paths. We want to know about it
2828
# though, so we'll still warn the user.
@@ -31,20 +31,20 @@ function check_absolute_paths(prefix::Prefix, all_files::Vector; silent::Bool =
3131
file_contents = String(read(f))
3232
if occursin(prefix.path, file_contents)
3333
if !silent
34-
@warn("$(relpath(f, prefix.path)) contains an absolute path")
34+
@warn("$(relpath(f, prefix.path)) contains an absolute path", platform=triplet(platform))
3535
end
3636
end
3737
catch
3838
if !silent
39-
@warn("Skipping abspath scanning of $(f), as we can't open it")
39+
@warn("Skipping abspath scanning of $(f), as we can't open it", platform=triplet(platform))
4040
end
4141
end
4242
end
4343

4444
return true
4545
end
4646

47-
function ensure_executability(oh::ObjectHandle; verbose::Bool=false, silent::Bool=false)
47+
function ensure_executability(oh::ObjectHandle, platform::AbstractPlatform; verbose::Bool=false, silent::Bool=false)
4848
old_mode = filemode(path(oh))
4949
# Execution permissions only for users who can read the file
5050
read_mask = (old_mode & 0o444) >> 2
@@ -61,7 +61,7 @@ function ensure_executability(oh::ObjectHandle; verbose::Bool=false, silent::Boo
6161
rethrow(e)
6262
end
6363
if !silent
64-
@warn "$(path(oh)) could not be made executable!" exception=(e, catch_backtrace())
64+
@warn "$(path(oh)) could not be made executable!" platform=triplet(platform) exception=(e, catch_backtrace())
6565
end
6666
end
6767
end

src/auditor/instruction_set.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function analyze_instruction_set(oh::ObjectHandle, platform::AbstractPlatform; v
160160
the proper instruction set internally. Would have chosen
161161
$(min_march), instead choosing $(generic_march(platform)).
162162
""", '\n' => ' ')
163-
@warn(strip(msg))
163+
@warn(strip(msg), platform=triplet(platform))
164164
end
165165
return generic_march(platform)
166166
end

src/auditor/soname_matching.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
get_soname(oh::ObjectHandle) = nothing
33

44
# Auto-open a path into an ObjectHandle
5-
function get_soname(path::AbstractString)
5+
function get_soname(path::AbstractString, platform::AbstractPlatform)
66
try
77
readmeta(get_soname, path)
88
catch e
9-
@warn "Could not probe $(path) for an SONAME!" exception=(e, catch_backtrace())
9+
@warn "Could not probe $(path) for an SONAME!" platform=triplet(platform) exception=(e, catch_backtrace())
1010
return nothing
1111
end
1212
end
@@ -47,7 +47,7 @@ function ensure_soname(prefix::Prefix, path::AbstractString, platform::AbstractP
4747

4848
# Skip if this file already contains an SONAME
4949
rel_path = relpath(realpath(path), realpath(prefix.path))
50-
soname = get_soname(path)
50+
soname = get_soname(path, platform)
5151
if soname != nothing
5252
if verbose
5353
@info("$(rel_path) already has SONAME \"$(soname)\"")
@@ -80,14 +80,14 @@ function ensure_soname(prefix::Prefix, path::AbstractString, platform::AbstractP
8080
end
8181

8282
if !retval
83-
@warn("Unable to set SONAME on $(rel_path)")
83+
@warn("Unable to set SONAME on $(rel_path)", platform=triplet(platform))
8484
return false
8585
end
8686

8787
# Read the SONAME back in and ensure it's set properly
88-
new_soname = get_soname(path)
88+
new_soname = get_soname(path, platform)
8989
if new_soname != soname
90-
@warn("Set SONAME on $(rel_path) to $(soname), but read back $(string(new_soname))!")
90+
@warn("Set SONAME on $(rel_path) to $(soname), but read back $(string(new_soname))!", platform=triplet(platform))
9191
return false
9292
end
9393

@@ -99,16 +99,16 @@ function ensure_soname(prefix::Prefix, path::AbstractString, platform::AbstractP
9999
end
100100

101101
"""
102-
symlink_soname_lib(path::AbstractString)
102+
symlink_soname_lib(path::AbstractString, platform::AbstractPlatform)
103103
104104
We require that all shared libraries are accessible on disk through their
105105
SONAME (if it exists). While this is almost always true in practice, it
106106
doesn't hurt to make doubly sure.
107107
"""
108-
function symlink_soname_lib(path::AbstractString; verbose::Bool = false,
109-
autofix::Bool = false)
108+
function symlink_soname_lib(path::AbstractString, platform::AbstractPlatform;
109+
verbose::Bool = false, autofix::Bool = false)
110110
# If this library doesn't have an SONAME, then just quit out immediately
111-
soname = get_soname(path)
111+
soname = get_soname(path, platform)
112112
if soname === nothing
113113
return true
114114
end

src/auditor/symlink_translator.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ function translate_symlinks(root::AbstractString; verbose::Bool=false)
2020
end
2121

2222
"""
23-
warn_deadlinks(root::AbstractString)
23+
warn_deadlinks(root::AbstractString, platform::AbstractPlatform)
2424
2525
Walks through the given `root` directory, finding broken symlinks and warning
2626
the user about them. This is used to catch instances such as a build recipe
2727
copying a symlink that points to a dependency; by doing so, it implicitly
2828
breaks relocatability.
2929
"""
30-
function warn_deadlinks(root::AbstractString)
30+
function warn_deadlinks(root::AbstractString, platform::AbstractPlatform)
3131
for f in collect_files(root, islink; exclude_externalities=false)
3232
link_target = readlink(f)
3333
if !startswith(link_target, "/")
@@ -39,7 +39,7 @@ function warn_deadlinks(root::AbstractString)
3939
link_target = joinpath(dirname(f), link_target)
4040
end
4141
if !ispath(link_target)
42-
@warn("Broken symlink: $(relpath(f, root))")
42+
@warn("Broken symlink: $(relpath(f, root))", platform=triplet(platform))
4343
end
4444
end
4545
end

test/auditing.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ end
459459

460460
# Test that `audit()` warns about broken symlinks
461461
@test_logs (:warn, r"Broken symlink: bin/libzmq.dll.a") match_mode=:any begin
462-
Auditor.warn_deadlinks(build_path)
462+
Auditor.warn_deadlinks(build_path, HostPlatform())
463463
end
464464
end
465465
end

0 commit comments

Comments
 (0)