Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f2hCD-0005Hw-2N for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Apr 2018 17:55:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f2hCB-0005GJ-T4 for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Apr 2018 17:55:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f2hCB-0005FN-IT for pgsql-hackers@lists.postgresql.org; Sun, 01 Apr 2018 17:55:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f2hC9-000124-3e for pgsql-hackers@lists.postgresql.org; Sun, 01 Apr 2018 17:55:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w31Ht5Y2025882; Sun, 1 Apr 2018 13:55:05 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@lists.postgresql.org Subject: Re: Rethinking -L switch handling and construction of LDFLAGS In-reply-to: <20180401174338.dgwcclz3ljiumaeq@alap3.anarazel.de> References: <25214.1522604295@sss.pgh.pa.us> <20180401174338.dgwcclz3ljiumaeq@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Sun, 01 Apr 2018 10:43:38 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25880.1522605305.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 01 Apr 2018 13:55:05 -0400 Message-ID: <25881.1522605305@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-04-01 13:38:15 -0400, Tom Lane wrote: >> I don't have a concrete patch to propose yet, but the design idea >> I have in mind is to split LDFLAGS into two or more parts, so that >> -L switches for the build tree are supposed to be put in the first >> part and external -L switches in the second. > I'm not sure I like doing this in Makefile.global. We've various files > that extend LDFLAGS in other places, and that's going to be hard if it's > already mushed together again. We end up re-building it from parts in > those files too. Yeah, one of the things I'd like to fix is that some of the makefiles, eg psql's, do override LDFLAGS :=3D -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_p= gport) $(LDFLAGS) which goes *directly* against this commandment in Makefile.global: # We want -L for libpgport.a and libpgcommon.a to be first in LDFLAGS. We # also need LDFLAGS to be a "recursively expanded" variable, else adjustme= nts # to rpathdir don't work right. So we must NOT do LDFLAGS :=3D something, # meaning this has to be done first and elsewhere we must only do LDFLAGS = +=3D # something. It's a bit surprising that rpath works at all for these makefiles. But with what I'm imagining here, I think we could replace that with LDFLAGS_INTERNAL +=3D -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_p= gport) and thereby preserve the recursively-expanded virginity of both LDFLAGS_INTERNAL and LDFLAGS. But I've not tried to test anything yet. > Why don't we change the link commands to reference LDFLAGS_INTERNAL > explicitly? That seems like it'd be cleaner. I'm hesitant to do that because LDFLAGS is a name known to make's default rules, and I don't want to bet that we're not relying on those default rules anywhere. I also disagree with the idea that using "$(LDFLAGS_INTERNAL) $(LDFLAGS)" in every link command we have is better or less error-prone than just "$(LDFLAGS)". Especially not if we end up with more than two parts. regards, tom lane