Re: Lower priority of the configure option --with-libraries causes wrong lib resolution - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Lower priority of the configure option --with-libraries causes wrong lib resolution
Date
Msg-id 388000.1750023697@sss.pgh.pa.us
Whole thread Raw
In response to Lower priority of the configure option --with-libraries causes wrong lib resolution  (Charles Samborski <demurgos@demurgos.net>)
List pgsql-bugs
I wrote:
> I would pin the blame here.  This code should not be messing with
> the global LDFLAGS.

Looking closer, we've made the same mistake elsewhere.
I think we need something like the attached to ensure
that -L switches coming from libraries' configure helpers
don't override user-specified directories.

            regards, tom lane

diff --git a/config/llvm.m4 b/config/llvm.m4
index fa4bedd9370..9d6fe8199e3 100644
--- a/config/llvm.m4
+++ b/config/llvm.m4
@@ -4,7 +4,7 @@
 # -----------------
 #
 # Look for the LLVM installation, check that it's new enough, set the
-# corresponding LLVM_{CFLAGS,CXXFLAGS,BINPATH} and LDFLAGS
+# corresponding LLVM_{CFLAGS,CXXFLAGS,BINPATH,LIBS}
 # variables. Also verify that CLANG is available, to transform C
 # into bitcode.
 #
@@ -55,7 +55,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
 
   for pgac_option in `$LLVM_CONFIG --ldflags`; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
     esac
   done
 
diff --git a/configure b/configure
index 4f15347cc95..09890286e2a 100755
--- a/configure
+++ b/configure
@@ -5194,7 +5194,7 @@ fi
 
   for pgac_option in `$LLVM_CONFIG --ldflags`; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
     esac
   done
 
@@ -9441,7 +9441,7 @@ fi
   done
   for pgac_option in $XML2_LIBS; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LIBDIRS="$LIBDIRS $pgac_option";;
     esac
   done
 fi
@@ -9671,7 +9671,7 @@ fi
   done
   for pgac_option in $LZ4_LIBS; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LIBDIRS="$LIBDIRS $pgac_option";;
     esac
   done
 fi
@@ -9812,7 +9812,7 @@ fi
   done
   for pgac_option in $ZSTD_LIBS; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LIBDIRS="$LIBDIRS $pgac_option";;
     esac
   done
 fi
diff --git a/configure.ac b/configure.ac
index 4b8335dc613..99bb2fb5698 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1108,7 +1108,7 @@ if test "$with_libxml" = yes ; then
   done
   for pgac_option in $XML2_LIBS; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LIBDIRS="$LIBDIRS $pgac_option";;
     esac
   done
 fi
@@ -1157,7 +1157,7 @@ if test "$with_lz4" = yes; then
   done
   for pgac_option in $LZ4_LIBS; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LIBDIRS="$LIBDIRS $pgac_option";;
     esac
   done
 fi
@@ -1182,7 +1182,7 @@ if test "$with_zstd" = yes; then
   done
   for pgac_option in $ZSTD_LIBS; do
     case $pgac_option in
-      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      -L*) LIBDIRS="$LIBDIRS $pgac_option";;
     esac
   done
 fi

pgsql-bugs by date:

Previous
From: Charles Samborski
Date:
Subject: Lower priority of the configure option --with-libraries causes wrong lib resolution
Next
From: John Naylor
Date:
Subject: Re: Invalid control file checksum with AVX-512 during initdb on a clang19 -O0 build