Skip to content

Commit 6d0e293

Browse files
authored
[Auditor] Do not skip GCC libraries when updating linkage (#1240)
* [Auditor] Do not skip GCC libraries when updating linkage * Fix expected SHAs of reproducible builds in tests * Adapt other auditor tests
1 parent 23847ac commit 6d0e293

File tree

3 files changed

+75
-48
lines changed

3 files changed

+75
-48
lines changed

src/auditor/dynamic_linkage.jl

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,9 @@ function should_ignore_lib(lib, ::ELFHandle, platform::AbstractPlatform)
173173
"libstdc++.so.6",
174174
"libc++.so.1",
175175
"libcxxrt.so.1",
176-
# GCC libraries
176+
# libc libraries
177177
"libdl.so.2",
178178
"librt.so.1",
179-
"libgcc_s.1.so",
180-
"libgcc_s.so.1",
181179
"libm.so.5",
182180
"libm.so.6",
183181
"libthr.so.3",
@@ -313,31 +311,6 @@ end
313311
# Determine whether a library is a "default" library or not, if it is we need
314312
# to map it to `@rpath/$libname` on OSX or `\$ORIGIN/$libname` on Linux/FreeBSD
315313
is_default_lib(lib, oh) = false
316-
function is_default_lib(lib, ::MachOHandle)
317-
default_libs = [
318-
"libgcc_s.1.dylib",
319-
"libgfortran.3.dylib",
320-
"libgfortran.4.dylib",
321-
"libgfortran.5.dylib",
322-
"libquadmath.0.dylib",
323-
"libgomp.1.dylib",
324-
"libstdc++.6.dylib",
325-
]
326-
return lowercase(basename(lib)) in default_libs
327-
end
328-
function is_default_lib(lib, ::ELFHandle)
329-
default_libs = [
330-
"libgcc_s.so.1",
331-
"libgfortran.so.3",
332-
"libgfortran.so.4",
333-
"libgfortran.so.5",
334-
"libquadmath.so.0",
335-
"libgomp.so.1",
336-
"libstdc++.so.6",
337-
"libc++.so.1",
338-
]
339-
return lowercase(basename(lib)) in default_libs
340-
end
341314

342315
function valid_library_path(f::AbstractString, p::AbstractPlatform)
343316
if Sys.iswindows(p)

test/auditing.jl

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ end
229229
make install
230230
install_license /usr/share/licenses/libuv/LICENSE
231231
"""
232-
build_output_meta = do_build(build_path, script, platform, gcc_version)
232+
build_output_meta = @test_logs (:info, "Building for $(triplet(platform))") (:warn, r"Linked library libgcc_s.so.1") match_mode=:any do_build(build_path, script, platform, gcc_version)
233233
# Extract our platform's build
234234
@test haskey(build_output_meta, platform)
235235
tarball_path, tarball_hash = build_output_meta[platform][1:2]
@@ -470,7 +470,7 @@ end
470470

471471
mktempdir() do build_path
472472
hello_world = ExecutableProduct("hello_world_fortran", :hello_world_fortran)
473-
build_output_meta = @test_logs (:warn, r"CompilerSupportLibraries_jll") match_mode=:any begin
473+
build_output_meta = @test_logs (:warn, r"CompilerSupportLibraries_jll") (:warn, r"Linked library libgfortran.so.5") (:warn, r"Linked library libquadmath.so.0") (:warn, r"Linked library libgcc_s.so.1") match_mode=:any begin
474474
autobuild(
475475
build_path,
476476
"hello_fortran",
@@ -488,7 +488,9 @@ end
488488
[platform],
489489
#
490490
Product[hello_world],
491-
# No dependencies
491+
# Note: we purposefully don't require CompilerSupportLibraries, even if we
492+
# should, but the `@test_logs` above makes sure the audit warns us about
493+
# this problem.
492494
Dependency[];
493495
)
494496
end
@@ -518,14 +520,20 @@ end
518520
@test_logs (:warn, r"links to libgfortran!") match_mode=:any begin
519521
@test !Auditor.audit(Prefix(testdir); platform=BinaryBuilderBase.abi_agnostic(platform), autofix=false)
520522
# Make sure audit is otherwise happy with the executable
521-
@test Auditor.audit(Prefix(testdir); platform=platform, autofix=false)
523+
# Note by Mosè: this test was introduced before
524+
# https://github.com/JuliaPackaging/BinaryBuilder.jl/pull/1240 and relied on the
525+
# fact audit was ok with not depending on CSL for packages needing GCC
526+
# libraries, but that was a fallacious expectation. At the moment I don't know
527+
# how to meaningfully use this test, leaving here as broken until we come up
528+
# with better ideas (just remove the test?).
529+
@test Auditor.audit(Prefix(testdir); platform=platform, autofix=false) broken=true
522530
end
523531

524532
# Let's pretend that we're building for a different libgfortran version:
525533
# audit should warn us.
526534
libgfortran_versions = (3, 4, 5)
527535
other_libgfortran_version = libgfortran_versions[findfirst(v -> v != our_libgfortran_version.major, libgfortran_versions)]
528-
@test_logs (:warn, Regex("but we are supposedly building for libgfortran$(other_libgfortran_version)")) readmeta(hello_world_path) do oh
536+
@test_logs (:warn, Regex("but we are supposedly building for libgfortran$(other_libgfortran_version)")) (:warn, r"Linked library libgfortran.so.5") (:warn, r"Linked library libquadmath.so.0") (:warn, r"Linked library libgcc_s.so.1") readmeta(hello_world_path) do oh
529537
p = deepcopy(platform)
530538
p["libgfortran_version"] = "$(other_libgfortran_version).0.0"
531539
@test !Auditor.audit(Prefix(testdir); platform=p, autofix=false)
@@ -624,6 +632,52 @@ end
624632
@test length(libfoo_rpaths) == 1 broken=Sys.isapple(platform)
625633
end
626634
end
635+
636+
@testset "GCC libraries" begin
637+
platform = Platform("x86_64", "linux"; libc="glibc", libgfortran_version=v"5")
638+
mktempdir() do build_path
639+
build_output_meta = nothing
640+
@test_logs (:info, "Building for $(triplet(platform))") match_mode=:any begin
641+
build_output_meta = autobuild(
642+
build_path,
643+
"rpaths",
644+
v"2.0.0",
645+
# No sources
646+
FileSource[],
647+
# Build two libraries, `libbar` in `${libdir}/qux/` and `libfoo` in
648+
# `${libdir}`, with the latter linking to the former.
649+
raw"""
650+
# Build fortran hello world
651+
make -j${nproc} -sC /usr/share/testsuite/fortran/hello_world install
652+
# Install fake license just to silence the warning
653+
install_license /usr/share/licenses/libuv/LICENSE
654+
""",
655+
[platform],
656+
# Ensure our library products are built
657+
[ExecutableProduct("hello_world_fortran", :hello_world_fortran)],
658+
# Dependencies: add CSL
659+
[Dependency("CompilerSupportLibraries_jll")];
660+
autofix=true,
661+
)
662+
end
663+
# Extract our platform's build
664+
@test haskey(build_output_meta, platform)
665+
tarball_path, tarball_hash = build_output_meta[platform][1:2]
666+
# Ensure the build products were created
667+
@test isfile(tarball_path)
668+
# Ensure reproducibility of build
669+
@test build_output_meta[platform][3] == Base.SHA1("06ddfbeb9914a534ed3f21795b5da5b536d33c16")
670+
671+
# Unpack it somewhere else
672+
@test verify(tarball_path, tarball_hash)
673+
testdir = joinpath(build_path, "testdir")
674+
mkdir(testdir)
675+
unpack(tarball_path, testdir)
676+
# Make sure auditor set the rpath of `hello_world`, even if it links only to
677+
# libgfortran.
678+
@test Auditor._rpaths(joinpath(testdir, "bin", "hello_world_fortran")) == ["\$ORIGIN/../lib"]
679+
end
680+
end
627681
end
628682

629683
@testset "Auditor - execution permission" begin

test/building.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,27 +196,27 @@ end
196196
]
197197
expected_git_shas = Dict(
198198
v"4" => Dict(
199-
x86_64_linux => Base.SHA1("6b705c0ff5760e236ab414fb9a366193f36d3e45"),
200-
ppc64le_linux => Base.SHA1("2fa9900c01dc87dad914de469e662cacd9c48e01"),
201-
armv7l_linux => Base.SHA1("192f05a64cc969cde17c026517166f98048ce27a"),
202-
aarch64_linux => Base.SHA1("fb501d0fb03bbf8f034cff50d8d8a1b2956cdf1a"),
203-
x86_64_macos => Base.SHA1("5a927c7c1b0c7813564bf47ec7ff287071ed5aae"),
199+
x86_64_linux => Base.SHA1("fb3897274fe9b293eb6bfb65063895946e655114"),
200+
ppc64le_linux => Base.SHA1("53a4e6c7e7d05bf245a8b794133b963bb1ebb1c2"),
201+
armv7l_linux => Base.SHA1("28fc03c35a4d30da70fbdefc69ecc6b6bf93f2fb"),
202+
aarch64_linux => Base.SHA1("c1c06efddc8bdce7b33fc9d8b6859f3c63e429ea"),
203+
x86_64_macos => Base.SHA1("6d7c6812ed8d0deb69d47ae467ea4fee9f691e34"),
204204
i686_windows => Base.SHA1("f39858ccc34a63a648cf21d33ae236bfdd706d09"),
205205
),
206206
v"5" => Dict(
207-
x86_64_linux => Base.SHA1("ef9653f47abba2895b14c1086ba40ad8c64ac098"),
208-
ppc64le_linux => Base.SHA1("b402ba20da0b800d37f69e1fbfe0e30c3b11a8db"),
209-
armv7l_linux => Base.SHA1("b282db91a2c2a33485718d8e8a743b7f5c384719"),
210-
aarch64_linux => Base.SHA1("ed873d488f47fb8bf5b4b89bb31ed1cad27ee27c"),
211-
x86_64_macos => Base.SHA1("099b6a75d4f417c9f67c4da9218a56327086ec72"),
207+
x86_64_linux => Base.SHA1("b202768af2c23d5ffa76df338eedeba10044c7f9"),
208+
ppc64le_linux => Base.SHA1("b663282a6101647c0aa87043a632b6cdc08f761f"),
209+
armv7l_linux => Base.SHA1("9a3273d5c7a41e7c2a5ab58b6b69db49a8533bc1"),
210+
aarch64_linux => Base.SHA1("4bab3a85aceb3e589989f1a11a2f092c5038a6e0"),
211+
x86_64_macos => Base.SHA1("86d45de929dfc89dd65cb6222287a1c1309f4d08"),
212212
i686_windows => Base.SHA1("9390a3c24a8e274e6d7245c6c977f97b406bc3f5"),
213213
),
214214
v"6" => Dict(
215-
x86_64_linux => Base.SHA1("b3829adf90f6521e4a05f20924506c8358247e06"),
216-
ppc64le_linux => Base.SHA1("a12153a57fc6d8c415dc77161a39ed8ab01b16b2"),
217-
armv7l_linux => Base.SHA1("a5c66513ca6a0348ca7b1e99412524fb1ee75e87"),
218-
aarch64_linux => Base.SHA1("641031469413f4fa776c74310098b1b181796720"),
219-
x86_64_macos => Base.SHA1("c01c6e840c4268123fbbd8703c8a153219752800"),
215+
x86_64_linux => Base.SHA1("8917015bdd43c961da93b003d67ccd9dd5debd54"),
216+
ppc64le_linux => Base.SHA1("97b7e5682b3cadc873644931b17894fa2ff05335"),
217+
armv7l_linux => Base.SHA1("267b443b17b99ca2a14ea93d2afc2cce51cad05e"),
218+
aarch64_linux => Base.SHA1("b396b1d94aba8642a68122a3515b26e4397217a0"),
219+
x86_64_macos => Base.SHA1("b6216a106353f62e611579d88275f244b4923678"),
220220
i686_windows => Base.SHA1("ae50af4ca8651cb3c8f71f34d0b66ca0d8f14a99"),
221221
),
222222
)

0 commit comments

Comments
 (0)