aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Norris <robn@despairlabs.com>2024-04-30 02:35:30 +0000
committerBrian Behlendorf <behlendorf1@llnl.gov>2024-05-01 17:51:14 +0000
commit7ac00d3c26652892e01956af29d087362ab29410 (patch)
tree4ef9ebaec835f031080164252406f0fb46f2c441
parenta6edc0adb293caf4e8bca2948af71b192b26bf58 (diff)
downloadsrc-7ac00d3c26652892e01956af29d087362ab29410.tar.gz
src-7ac00d3c26652892e01956af29d087362ab29410.zip
find_system_library: fix var cleanup when library not found
The "not found" path is attempting to clear SOMELIB_CFLAGS and SOMELIB_LIBS by resetting them in AC_SUBST(). However, the second arg to AC_SUBST is expanded in autoconf with `m4_ifvaln([$2], [[$1]=$2])`, which is defined as "if the first arg is non-empty". The m4 "empty" construction is [], therefore, the existing AC_SUBST calls never modify the variables at all. The effect of this is that leftovers from the library test can leak out. At least, if a library header is found in the first stage, but the library itself is not, -lsomelib is added to SOMELIB_LIBS and further tests done. If that library is not found, SOMELIB_LIBS will not be cleared. For most of our library tests this hasn't been a problem, as they're either always found properly via pkg-config or set directly, or the calling test immediately aborts configure. For an optional dependency however, an apparent "partial" result where the header is found but no corresponding library causes link errors later. I think a complete fix should probably not be setting SOMELIB_xxx until the final result is known, but for now, adjusting the AC_SUBST calls to explictly set the empty shell string (which is not "empty" to m4) at least restores the intent. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Sponsored-by: https://despairlabs.com/sponsor/ Closes #16140
-rw-r--r--config/find_system_library.m44
1 files changed, 2 insertions, 2 deletions
diff --git a/config/find_system_library.m4 b/config/find_system_library.m4
index 310b44112aea..8b98bd67d2ee 100644
--- a/config/find_system_library.m4
+++ b/config/find_system_library.m4
@@ -90,8 +90,8 @@ AC_DEFUN([ZFS_AC_FIND_SYSTEM_LIBRARY], [
AC_DEFINE([HAVE_][$1], [1], [Define if you have [$5]])
$7
],[dnl ELSE
- AC_SUBST([$1]_CFLAGS, [])
- AC_SUBST([$1]_LIBS, [])
+ AC_SUBST([$1]_CFLAGS, [""])
+ AC_SUBST([$1]_LIBS, [""])
AC_MSG_WARN([cannot find [$5] via pkg-config or in the standard locations])
$8
])