pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Don't put library-supplied -L/-I switches before user-supplied o
7+ messages / 1 participants
[nested] [flat]

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4300d8b6a79d61abb5ca9f901df7bde7a49322b6

Modified Files
--------------
config/llvm.m4                      |  4 ++--
config/programs.m4                  |  4 ++--
configure                           | 24 ++++++++++++------------
configure.ac                        | 18 +++++++++---------
src/Makefile.global.in              |  2 +-
src/backend/jit/llvm/Makefile       |  2 +-
src/bin/initdb/Makefile             |  2 +-
src/common/Makefile                 |  2 +-
src/interfaces/libpq-oauth/Makefile |  2 +-
src/interfaces/libpq/Makefile       |  2 +-
src/pl/plpython/Makefile            |  2 +-
src/pl/tcl/Makefile                 |  2 +-
12 files changed, 33 insertions(+), 33 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8e5e3ff5564104b5e1c3c459d626967a702ad9fb

Modified Files
--------------
config/llvm.m4                      |  4 ++--
config/programs.m4                  |  4 ++--
configure                           | 24 ++++++++++++------------
configure.ac                        | 18 +++++++++---------
src/Makefile.global.in              |  2 +-
src/backend/jit/llvm/Makefile       |  2 +-
src/bin/initdb/Makefile             |  2 +-
src/common/Makefile                 |  2 +-
src/interfaces/libpq-oauth/Makefile |  2 +-
src/interfaces/libpq/Makefile       |  2 +-
src/pl/plpython/Makefile            |  2 +-
src/pl/tcl/Makefile                 |  2 +-
12 files changed, 33 insertions(+), 33 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a644f5fc66a36ff7c630b8480901b6057243da2c

Modified Files
--------------
config/llvm.m4                |  4 ++--
configure                     | 20 ++++++++++----------
configure.ac                  | 18 +++++++++---------
src/Makefile.global.in        |  2 +-
src/backend/jit/llvm/Makefile |  2 +-
src/bin/initdb/Makefile       |  2 +-
src/interfaces/libpq/Makefile |  2 +-
src/pl/plpython/Makefile      |  2 +-
src/pl/tcl/Makefile           |  2 +-
9 files changed, 27 insertions(+), 27 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bbc20c8a9ffdefcabd70ea0c325827fe2b8f5960

Modified Files
--------------
config/llvm.m4                |  4 ++--
configure                     | 20 ++++++++++----------
configure.ac                  | 18 +++++++++---------
src/Makefile.global.in        |  2 +-
src/backend/jit/llvm/Makefile |  2 +-
src/bin/initdb/Makefile       |  2 +-
src/interfaces/libpq/Makefile |  2 +-
src/pl/plpython/Makefile      |  2 +-
src/pl/tcl/Makefile           |  2 +-
9 files changed, 27 insertions(+), 27 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/19857437b07353908c7daac8e9aac86eda35051b

Modified Files
--------------
config/llvm.m4                |  4 ++--
configure                     | 20 ++++++++++----------
configure.ac                  | 18 +++++++++---------
src/Makefile.global.in        |  2 +-
src/backend/jit/llvm/Makefile |  2 +-
src/interfaces/libpq/Makefile |  2 +-
src/pl/plpython/Makefile      |  2 +-
src/pl/tcl/Makefile           |  2 +-
8 files changed, 26 insertions(+), 26 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2dee95bd0cf18d99e4d4778f18a794160a8dcaba

Modified Files
--------------
config/llvm.m4                |  4 ++--
configure                     | 16 ++++++++--------
configure.ac                  | 14 +++++++-------
src/Makefile.global.in        |  2 +-
src/backend/jit/llvm/Makefile |  2 +-
src/interfaces/libpq/Makefile |  2 +-
src/pl/plpython/Makefile      |  2 +-
src/pl/tcl/Makefile           |  2 +-
8 files changed, 22 insertions(+), 22 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Don't put library-supplied -L/-I switches before user-supplied o
@ 2025-07-29 19:18 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2025-07-29 19:18 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't put library-supplied -L/-I switches before user-supplied ones.

For many optional libraries, we extract the -L and -l switches needed
to link the library from a helper program such as llvm-config.  In
some cases we put the resulting -L switches into LDFLAGS ahead of
-L switches specified via --with-libraries.  That risks breaking
the user's intention for --with-libraries.

It's not such a problem if the library's -L switch points to a
directory containing only that library, but on some platforms a
library helper may "helpfully" offer a switch such as -L/usr/lib
that points to a directory holding all standard libraries.  If the
user specified --with-libraries in hopes of overriding the standard
build of some library, the -L/usr/lib switch prevents that from
happening since it will come before the user-specified directory.

To fix, avoid inserting these switches directly into LDFLAGS during
configure, instead adding them to LIBDIRS or SHLIB_LINK.  They will
still eventually get added to LDFLAGS, but only after the switches
coming from --with-libraries.

The same problem exists for -I switches: those coming from
--with-includes should appear before any coming from helper programs
such as llvm-config.  We have not heard field complaints about this
case, but it seems certain that a user attempting to override a
standard library could have issues.

The changes for this go well beyond configure itself, however,
because many Makefiles have occasion to manipulate CPPFLAGS to
insert locally-desirable -I switches, and some of them got it wrong.
The correct ordering is any -I switches pointing at within-the-
source-tree-or-build-tree directories, then those from the tree-wide
CPPFLAGS, then those from helper programs.  There were several places
that risked pulling in a system-supplied copy of libpq headers, for
example, instead of the in-tree files.  (Commit cb36f8ec2 fixed one
instance of that a few months ago, but this exercise found more.)

The Meson build scripts may or may not have any comparable problems,
but I'll leave it to someone else to investigate that.

Reported-by: Charles Samborski <demurgos@demurgos.net>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/70f2155f-27ca-4534-b33d-7750e20633d7@demurgos.net
Backpatch-through: 13

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c5bd803e58162e39e3dcd22f1e8039139c32c1ab

Modified Files
--------------
config/llvm.m4                |  4 ++--
configure                     | 12 ++++++------
configure.in                  | 10 +++++-----
src/Makefile.global.in        |  2 +-
src/backend/jit/llvm/Makefile |  2 +-
src/interfaces/libpq/Makefile |  2 +-
src/pl/plpython/Makefile      |  2 +-
src/pl/tcl/Makefile           |  2 +-
8 files changed, 18 insertions(+), 18 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2025-07-29 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>
2025-07-29 19:18 pgsql: Don't put library-supplied -L/-I switches before user-supplied o Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox