Re: Lower priority of the configure option --with-libraries causes wrong lib resolution

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Charles Samborski <demurgos(at)demurgos(dot)net>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Lower priority of the configure option --with-libraries causes wrong lib resolution
Date: 2025-06-15 20:26:01
Message-ID: 311720.1750019161@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Charles Samborski <demurgos(at)demurgos(dot)net> writes:
> Swapping the two flags so the order is `-L/postgres-deps/lib -L/usr/lib`
> fixes the build. I consider it very surprising that that libraries
> passed with `--with-libraries` have lower priority, I would expect
> explicitly requested libraries to have the highest priority.

Ugh.

> First, `/usr/lib` is added in the clang configuration [1]. It is
> retrieved from `/usr/bin/llvm-config --ldflags`.

I would pin the blame here. This code should not be messing with
the global LDFLAGS. -L switches from llvm-config should probably
go into LLVM_LIBS instead, so that they're only applied while
linking llvmjit.so. (Compare the handling of -L switches from
python or perl: those go into python_libspec or perl_embed_ldflags,
they're not applied globally.)

Can you check whether a change along that line fixes the problem
in your environment?

> My workaround is to update the configure script to instead prepend
> `LIBDIRS` at the start of `LDFLAGS` using `LDFLAGS="$LIBDIRS $LDFLAGS"`.

I don't think we'd accept that: it seems about as likely to break
builds as fix them. Notably, users might've themselves modified
LDFLAGS to contain -L switches. While that's not good practice
IMO, we shouldn't make changes that are more sweeping than
necessary.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-06-15 21:41:37 Re: Lower priority of the configure option --with-libraries causes wrong lib resolution
Previous Message Charles Samborski 2025-06-15 16:20:11 Lower priority of the configure option --with-libraries causes wrong lib resolution