pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ensure link commands list *.o files before LDFLAGS.
Date: Wed, 02 Jan 2019 18:58:09 +0000
Message-ID: <E1geliT-0003Qf-3g@gemulon.postgresql.org> (raw)

Ensure link commands list *.o files before LDFLAGS.

It's important for link commands to list *.o input files before -l
switches for libraries, as library code may not get pulled into the link
unless referenced by an earlier command-line entry.  This is certainly
necessary for static libraries (.a style).  Apparently on some platforms
it is also necessary for shared libraries, as reported by Donald Dong.

We often put -l switches for within-tree libraries into LDFLAGS, meaning
that link commands that list *.o files after LDFLAGS are hazardous.
Most of our link commands got this right, but a few did not.  In
particular, places that relied on gmake's default implicit link rule
failed, because that puts LDFLAGS first.  Fix that by overriding the
built-in rule with our own.  The implicit link rules in
src/makefiles/Makefile.* for single-.o-file shared libraries mostly
got this wrong too, so fix them.  I also changed the link rules for the
backend and a couple of other places for consistency, even though they
are not (currently) at risk because they aren't adding any -l switches
to LDFLAGS.

Arguably, the real problem here is that we're abusing LDFLAGS by
putting -l switches in it and we should stop doing that.  But changing
that would be quite invasive, so I'm not eager to do so.

Perhaps this is a candidate for back-patching, but so far it seems
that problems can only be exhibited in test code we don't normally
build, and at least some of the problems are new in HEAD anyway.
So I'll refrain for now.

Donald Dong and Tom Lane

Discussion: https://postgr.es/m/CAKABAquXn-BF-vBeRZxhzvPyfMqgGuc74p8BmQZyCFDpyROBJQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/69ae9dcb444a667533344562f134444856fb3414

Modified Files
--------------
src/Makefile.global.in                    |  7 +++++++
src/backend/Makefile                      | 12 ++++++------
src/interfaces/ecpg/preproc/Makefile      |  2 +-
src/interfaces/ecpg/test/Makefile         |  2 +-
src/interfaces/ecpg/test/Makefile.regress |  3 ---
src/makefiles/Makefile.aix                |  2 +-
src/makefiles/Makefile.darwin             |  2 +-
src/makefiles/Makefile.freebsd            |  2 +-
src/makefiles/Makefile.hpux               |  4 ++--
src/makefiles/Makefile.linux              |  2 +-
src/makefiles/Makefile.netbsd             |  2 +-
src/makefiles/Makefile.openbsd            |  2 +-
src/makefiles/Makefile.solaris            |  4 ++--
src/test/thread/Makefile                  |  2 +-
14 files changed, 26 insertions(+), 22 deletions(-)



Message-ID: <E1geliT-0003Qf-3g@gemulon.postgresql.org>
Permalink:  ../E1geliT-0003Qf-3g@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1geliT-0003Qf-3g@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Ensure link commands list *.o files before LDFLAGS.
  In-Reply-To: <E1geliT-0003Qf-3g@gemulon.postgresql.org>
  References: <E1geliT-0003Qf-3g@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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