From 386e7db5e6d87e42001803de314d6568105cd8ee Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 15 Jun 2025 06:30:05 -0400 Subject: [PATCH] Use static linking for libarchive by default on MacOS Apparently dlopen() path searching doesn't work or is unreliable on MacOS; it appears to not search LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or DYLD_FALLBACK_LIBRARY_PATH as documented by the dlopen(3) man page. Furthmore setting any of these variables to include /opt/local/lib, which is where MacPort drops libarchive.13.dylib, can cause all manner of warnings when running other dynamically linked programs, such as "grep". What a mess. It appears dlopen(2) support in MacOS is a disaster, and it's not really needed since we don't care about the size of mke2fs on installation media on non-Linux systems. So default to using --with-libarchive=direct for MacOS. Signed-off-by: Theodore Ts'o --- configure | 14 ++++++++++++-- configure.ac | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 859bc11..6518f36 100755 --- a/configure +++ b/configure @@ -13811,9 +13811,19 @@ printf "%s\n" "Testing for libarchive support (with dlopen)" >&6; } fi else $as_nop - try_libarchive="yes" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with dlopen) by default" >&5 + +case "$host_os" in + darwin*) + try_libarchive="direct" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with static linking) by default" >&5 +printf "%s\n" "Try testing for libarchive support (with static linking) by default" >&6; } + ;; + *) + try_libarchive="yes" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with dlopen) by default" >&5 printf "%s\n" "Try testing for libarchive support (with dlopen) by default" >&6; } + ;; +esac fi diff --git a/configure.ac b/configure.ac index 694f07e..7c20035 100644 --- a/configure.ac +++ b/configure.ac @@ -1325,9 +1325,18 @@ else AC_MSG_RESULT([Testing for libarchive support (with dlopen)]) fi] , -try_libarchive="yes" -AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default]) -) +[ +case "$host_os" in + darwin*) + try_libarchive="direct" + AC_MSG_RESULT([Try testing for libarchive support (with static linking) by default]) + ;; + *) + try_libarchive="yes" + AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default]) + ;; +esac +]) ARCHIVE_LIBS= if test -n "$try_libarchive" then -- 1.8.3.1