Skip to content

Commit b0e599d

Browse files
authored
Cleanup auditing a bit (#642)
* Use newer `RegistryTools` for Julia 1.4+ * Clean up audit passes a bit * Only check for dynamic things if the object being tested is actually dynamic * Make FreeBSD OS/ABI error message blend in a bit more * Eliminate testing print * Catch more warnings with `@test_logs` * Simplify `dll` moving a bit
1 parent 2983c33 commit b0e599d

File tree

4 files changed

+67
-56
lines changed

4 files changed

+67
-56
lines changed

src/Auditor.jl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,22 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
7373
else
7474
# Check that the ISA isn't too high
7575
all_ok &= check_isa(oh, platform, prefix; verbose=verbose, silent=silent)
76-
# Check that the libgfortran version matches
77-
all_ok &= check_libgfortran_version(oh, platform; verbose=verbose)
78-
# Check that the libstdcxx string ABI matches
79-
all_ok &= check_cxxstring_abi(oh, platform; verbose=verbose)
80-
# Check that this binary file's dynamic linkage works properly. Note to always
81-
# DO THIS ONE LAST as it can actually mutate the file, which causes the previous
82-
# checks to freak out a little bit.
83-
all_ok &= check_dynamic_linkage(oh, prefix, bin_files;
84-
platform=platform, silent=silent,
85-
verbose=verbose, autofix=autofix)
76+
# Check that the OS ABI is set correctly (often indicates the wrong linker was used)
8677
all_ok &= check_os_abi(oh, platform, verbose = verbose)
78+
79+
# If this is a dynamic object, do the dynamic checks
80+
if isdynamic(oh)
81+
# Check that the libgfortran version matches
82+
all_ok &= check_libgfortran_version(oh, platform; verbose=verbose)
83+
# Check that the libstdcxx string ABI matches
84+
all_ok &= check_cxxstring_abi(oh, platform; verbose=verbose)
85+
# Check that this binary file's dynamic linkage works properly. Note to always
86+
# DO THIS ONE LAST as it can actually mutate the file, which causes the previous
87+
# checks to freak out a little bit.
88+
all_ok &= check_dynamic_linkage(oh, prefix, bin_files;
89+
platform=platform, silent=silent,
90+
verbose=verbose, autofix=autofix)
91+
end
8792
end
8893
end
8994
catch e

src/AutoBuild.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ function autobuild(dir::AbstractString,
614614
if src_version.build != ()
615615
error("Will not build with a `src_version` that has a build number already specified!")
616616
end
617-
@show src_version
618617

619618
# We must prepare our sources. Download them, hash them, etc...
620619
sources = download_sources(sources; verbose=verbose)

src/auditor/extra_checks.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
check_os_abi(::ObjectHandle, ::Platform, rest...; verbose::Bool = false, kwargs...) = true
55

66
function check_os_abi(oh::ELFHandle, ::FreeBSD, rest...; verbose::Bool = false, kwargs...)
7-
if oh.ei.osabi != 0x09
7+
if oh.ei.osabi != ELF.ELFOSABI_FREEBSD
88
# The dynamic loader should not have problems in this case, but the
99
# linker may not appreciate. Let the user know about this.
1010
if verbose
11-
@warn "OS/ABI is not set to FreeBSD (0x09) in the file header, this may be an issue at linking time"
11+
msg = replace("""
12+
$(basename(path(oh))) has an ELF header OS/ABI value that is not set to FreeBSD
13+
($(ELF.ELFOSABI_FREEBSD)), this may be an issue at link time"
14+
""", '\n' => ' ')
15+
@warn(strip(msg))
1216
end
1317
return false
1418
end

test/auditing.jl

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,29 @@ end
2525
ExecutableProduct("main_avx2", :main_avx2),
2626
]
2727

28-
build_output_meta = autobuild(
29-
build_path,
30-
"isa_tests",
31-
v"1.0.0",
32-
[build_tests_dir],
33-
# Build the test suite, install the binaries into our prefix's `bin`
34-
raw"""
35-
cd ${WORKSPACE}/srcdir/isa_tests
36-
make -j${nproc} install
37-
install_license /usr/include/ltdl.h
38-
""",
39-
# Build for our platform
40-
[platform],
41-
# Ensure our executable products are built
42-
products,
43-
# No dependencies
44-
[];
45-
# We need to build with very recent GCC so that we can emit AVX2
46-
preferred_gcc_version=v"8",
47-
)
28+
build_output_meta = nothing
29+
@test_logs (:warn, r"sandybridge") (:warn, r"haswell") match_mode=:any begin
30+
build_output_meta = autobuild(
31+
build_path,
32+
"isa_tests",
33+
v"1.0.0",
34+
[build_tests_dir],
35+
# Build the test suite, install the binaries into our prefix's `bin`
36+
raw"""
37+
cd ${WORKSPACE}/srcdir/isa_tests
38+
make -j${nproc} install
39+
install_license /usr/include/ltdl.h
40+
""",
41+
# Build for our platform
42+
[platform],
43+
# Ensure our executable products are built
44+
products,
45+
# No dependencies
46+
[];
47+
# We need to build with very recent GCC so that we can emit AVX2
48+
preferred_gcc_version=v"8",
49+
)
50+
end
4851

4952
# Extract our platform's build
5053
@test haskey(build_output_meta, platform)
@@ -121,37 +124,37 @@ end
121124

122125

123126
@testset "Auditor - .dll moving" begin
124-
for platform in [Linux(:x86_64), Windows(:x86_64)]
127+
for platform in [Windows(:x86_64)]
125128
mktempdir() do build_path
126-
build_output_meta = autobuild(
127-
build_path,
128-
"dll_moving",
129-
v"1.0.0",
130-
[],
131-
# Intsall a .dll into lib
132-
raw"""
133-
mkdir -p ${prefix}/lib
134-
cc -o ${prefix}/lib/libfoo.${dlext} -shared /usr/share/testsuite/c/dyn_link/libfoo/libfoo.c
135-
install_license /usr/include/ltdl.h
136-
""",
137-
# Build for our platform
138-
[platform],
139-
# Ensure our executable products are built
140-
Product[LibraryProduct("libfoo", :libfoo)],
141-
# No dependencies
142-
[];
143-
# We need to build with very recent GCC so that we can emit AVX2
144-
preferred_gcc_version=v"8",
145-
)
129+
build_output_meta = nothing
130+
@test_logs (:warn, r"lib/libfoo.dll should be in `bin`") (:warn, r"Simple buildsystem detected") match_mode=:any begin
131+
build_output_meta = autobuild(
132+
build_path,
133+
"dll_moving",
134+
v"1.0.0",
135+
[],
136+
# Install a .dll into lib
137+
raw"""
138+
mkdir -p ${prefix}/lib
139+
cc -o ${prefix}/lib/libfoo.${dlext} -shared /usr/share/testsuite/c/dyn_link/libfoo/libfoo.c
140+
install_license /usr/include/ltdl.h
141+
""",
142+
# Build for our platform
143+
[platform],
144+
# Ensure our executable products are built
145+
Product[LibraryProduct("libfoo", :libfoo)],
146+
# No dependencies
147+
[]
148+
)
149+
end
146150

147151
@test haskey(build_output_meta, platform)
148152
tarball_path, tarball_hash = build_output_meta[platform][1:2]
149153
@test isfile(tarball_path)
150154

151155
# Test that `libfoo.dll` gets moved to `bin` if it's a windows
152156
contents = list_tarball_files(tarball_path)
153-
dir = isa(platform, Windows) ? "bin" : "lib"
154-
@test "$(dir)/libfoo.$(dlext(platform))" in contents
157+
@test "bin/libfoo.$(dlext(platform))" in contents
155158
end
156159
end
157160
end

0 commit comments

Comments
 (0)