|
571 | 571 | end
|
572 | 572 | end
|
573 | 573 |
|
| 574 | +@testset "Auditor - rpaths" begin |
| 575 | + @testset "$platform" for platform in (Platform("x86_64", "linux"; libc="glibc"), Platform("x86_64", "macos")) |
| 576 | + mktempdir() do build_path |
| 577 | + build_output_meta = nothing |
| 578 | + @test_logs (:info, "Building for $(triplet(platform))") match_mode=:any begin |
| 579 | + build_output_meta = autobuild( |
| 580 | + build_path, |
| 581 | + "rpaths", |
| 582 | + v"1.0.0", |
| 583 | + # No sources |
| 584 | + FileSource[], |
| 585 | + # Build two libraries, `libbar` in `${libdir}/qux/` and `libfoo` in |
| 586 | + # `${libdir}`, with the latter linking to the former. |
| 587 | + raw""" |
| 588 | + mkdir -p ${libdir}/qux |
| 589 | + echo "int bar(){return 38;}" | gcc -x c -shared -fPIC - -o ${libdir}/qux/libbar.${dlext} |
| 590 | + echo "extern int bar(); int foo(){return bar() + 4;}" | gcc -x c -shared -fPIC - -o ${libdir}/libfoo.${dlext} -L${libdir}/qux -lbar -Wl,-rpath,${libdir}/qux |
| 591 | + """, |
| 592 | + [platform], |
| 593 | + # Ensure our library products are built |
| 594 | + [LibraryProduct("libbar", :libbar, "\$libdir/qux"), LibraryProduct("libfoo", :libfoo)], |
| 595 | + # No dependencies |
| 596 | + Dependency[]; |
| 597 | + require_license = false |
| 598 | + ) |
| 599 | + end |
| 600 | + # Extract our platform's build |
| 601 | + @test haskey(build_output_meta, platform) |
| 602 | + tarball_path, tarball_hash = build_output_meta[platform][1:2] |
| 603 | + # Ensure the build products were created |
| 604 | + @test isfile(tarball_path) |
| 605 | + |
| 606 | + # Unpack it somewhere else |
| 607 | + @test verify(tarball_path, tarball_hash) |
| 608 | + testdir = joinpath(build_path, "testdir") |
| 609 | + mkdir(testdir) |
| 610 | + unpack(tarball_path, testdir) |
| 611 | + # Make sure rpath of libbar is empty |
| 612 | + @test Auditor._rpaths(joinpath(testdir, "lib", "qux", "libbar.$(platform_dlext(platform))")) == [] |
| 613 | + # Make sure the rpath of libfoo contains only `$ORIGIN/qux`, with the relative |
| 614 | + # path handled correctly. |
| 615 | + libfoo_rpaths = Auditor._rpaths(joinpath(testdir, "lib", "libfoo.$(platform_dlext(platform))")) |
| 616 | + @test (Sys.isapple(platform) ? "@loader_path" : "\$ORIGIN") * "/qux" in libfoo_rpaths |
| 617 | + # Currently we don't filter out absolute rpaths for macOS libraries, no good. |
| 618 | + @test length(libfoo_rpaths) == 1 broken=Sys.isapple(platform) |
| 619 | + end |
| 620 | + end |
| 621 | +end |
| 622 | + |
574 | 623 | @testset "Auditor - execution permission" begin
|
575 | 624 | mktempdir() do build_path
|
576 | 625 | build_output_meta = nothing
|
|
0 commit comments