On FreeBSD 12.0, NetBSD 9.0, OpenBSD 6.5, "make check" reports a couple of skipped tests:
no-ctx.sh: skipped test: $CC -shared ... failed to build a shared lib r-root.sh: skipped test: $CC -shared ... failed to build a shared lib rm-readdir-fail.sh: skipped test: $CC -shared ... failed to build a shared lib csplit-io-err.sh: skipped test: $CC -shared ... failed to build a shared lib nfs-removal-race.sh: skipped test: $CC -shared ... failed to build a shared lib no-mtab-status.sh: skipped test: $CC -shared ... failed to build a shared lib skip-duplicates.sh: skipped test: $CC -shared ... failed to build a shared lib getxattr-speedup.sh: skipped test: $CC -shared ... failed to build a shared lib The prereq check tests not only whether a shared library can be built, but also whether linking it with -ldl works. However, on the following platforms, the dlopen() etc. functions exist in libc, and a libdl does not exist: macOS, FreeBSD, NetBSD, OpenBSD, IRIX, OSF/1, Cygwin, Haiku. The attached patch removes the requirement of a libdl. It enables 4 more tests to be executed on FreeBSD, and produces no additional test failures on FreeBSD, NetBSD, OpenBSD. Output on FreeBSD 12.0: no-ctx.sh: skipped test: this system lacks SELinux support SKIP: tests/cp/no-ctx.sh PASS: tests/rm/r-root.sh PASS: tests/rm/rm-readdir-fail.sh PASS: tests/misc/csplit-io-err.sh nfs-removal-race.sh: skipped test: LD_PRELOAD was ineffective? SKIP: tests/cp/nfs-removal-race.sh no-mtab-status.sh: skipped test: no mntent.h available to confirm the interface SKIP: tests/df/no-mtab-status.sh skip-duplicates.sh: skipped test: no mntent.h available to confirm the interface SKIP: tests/df/skip-duplicates.sh PASS: tests/ls/getxattr-speedup.sh Output on NetBSD 9.0: no-ctx.sh: skipped test: this system lacks SELinux support SKIP: tests/cp/no-ctx.sh r-root.sh: skipped test: internal test failure: maybe LD_PRELOAD or gdb doesn't work? SKIP: tests/rm/r-root.sh rm-readdir-fail.sh: skipped test: internal test failure: maybe LD_PRELOAD doesn't work? SKIP: tests/rm/rm-readdir-fail.sh csplit-io-err.sh: skipped test: LD_PRELOAD interception failed SKIP: tests/misc/csplit-io-err.sh nfs-removal-race.sh: skipped test: LD_PRELOAD was ineffective? SKIP: tests/cp/nfs-removal-race.sh no-mtab-status.sh: skipped test: no mntent.h available to confirm the interface SKIP: tests/df/no-mtab-status.sh skip-duplicates.sh: skipped test: no mntent.h available to confirm the interface SKIP: tests/df/skip-duplicates.sh getxattr-speedup.sh: skipped test: internal test failure: maybe LD_PRELOAD doesn't work? SKIP: tests/ls/getxattr-speedup.sh Output on OpenBSD 6.5: no-ctx.sh: skipped test: this system lacks SELinux support SKIP: tests/cp/no-ctx.sh r-root.sh: skipped test: internal test failure: maybe LD_PRELOAD or gdb doesn't work? SKIP: tests/rm/r-root.sh rm-readdir-fail.sh: skipped test: internal test failure: maybe LD_PRELOAD doesn't work? SKIP: tests/rm/rm-readdir-fail.sh csplit-io-err.sh: skipped test: /dev/full is required SKIP: tests/misc/csplit-io-err.sh nfs-removal-race.sh: skipped test: LD_PRELOAD was ineffective? SKIP: tests/cp/nfs-removal-race.sh no-mtab-status.sh: skipped test: no mntent.h available to confirm the interface SKIP: tests/df/no-mtab-status.sh skip-duplicates.sh: skipped test: no mntent.h available to confirm the interface SKIP: tests/df/skip-duplicates.sh getxattr-speedup.sh: skipped test: internal test failure: maybe LD_PRELOAD doesn't work? SKIP: tests/ls/getxattr-speedup.sh
>From 5b53ffc9abc5153ffa4889614ee41ce3ce26c868 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Sun, 1 Mar 2020 03:03:59 +0100 Subject: [PATCH] tests: Enable 4 more tests to be executed on FreeBSD. * init.cfg (gcc_shared_libs_): New variable. (gcc_shared_): Use it, instead of hardcoding -ldl. (require_gcc_shared_): Determine the suitable value for gcc_shared_libs_. --- init.cfg | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/init.cfg b/init.cfg index f7a3fab..2009e29 100644 --- a/init.cfg +++ b/init.cfg @@ -576,6 +576,9 @@ require_sparse_support_() fi } +# Libraries needed when we compile a shared library. +gcc_shared_libs_= + # Compile a shared lib using the GCC options for doing so. # Pass input and output file as parameters respectively. # Any other optional parmeters are passed to $CC. @@ -585,7 +588,7 @@ gcc_shared_() local out=$2 shift 2 || return 1 - $CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" -ldl + $CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" $gcc_shared_libs_ } # There are a myriad of ways to build shared libs, @@ -593,8 +596,18 @@ gcc_shared_() # on platforms that support building them as follows. require_gcc_shared_() { - gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1 \ - || skip_ '$CC -shared ... failed to build a shared lib' + # Try two different values for gcc_shared_libs_. + gcc_shared_libs_='-ldl' + if gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1; then + : + else + gcc_shared_libs_= + if gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1; then + : + else + skip_ '$CC -shared ... failed to build a shared lib' + fi + fi rm -f d.so } -- 2.7.4
