Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPSY5-0003nn-Nt for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Nov 2018 13:28:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gPSY3-0004Fi-8L for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Nov 2018 13:28:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPSY2-0004Fa-U3 for pgsql-hackers@lists.postgresql.org; Wed, 21 Nov 2018 13:28:07 +0000 Received: from gauss.credativ.com ([93.94.130.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPSXz-0002fb-NV for pgsql-hackers@postgresql.org; Wed, 21 Nov 2018 13:28:05 +0000 Received: from gauss.credativ.com (localhost [127.0.0.1]) by gauss.credativ.com (Postfix) with ESMTP id 525551E3B23; Wed, 21 Nov 2018 14:28:01 +0100 (CET) Received: from msg.credativ.de (fw-front.credativ.com [62.154.226.94]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cbe@gauss.credativ.com) by gauss.credativ.com (Postfix) with ESMTPSA id 3739F1E3B22; Wed, 21 Nov 2018 14:28:01 +0100 (CET) Date: Wed, 21 Nov 2018 14:28:01 +0100 From: Christoph Berg To: Andres Freund Cc: Tom Lane , PostgreSQL Hackers Subject: Re: [PATCH] Pass COPT and PROFILE to CXXFLAGS as well Message-ID: <20181121132801.GH15795@msg.credativ.de> Mail-Followup-To: Christoph Berg , Andres Freund , Tom Lane , PostgreSQL Hackers References: <20181113104005.GA32154@msg.credativ.de> <20181113215716.qsdhsg54dmg6kvdl@alap3.anarazel.de> <22230.1542148037@sss.pgh.pa.us> <20181113223330.2ql7tg33hhh6husf@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181113223330.2ql7tg33hhh6husf@alap3.anarazel.de> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk (Sorry for the delayed response here.) Re: Andres Freund 2018-11-13 <20181113223330.2ql7tg33hhh6husf@alap3.anarazel.de> > > >> While working on making extension modules built reproducibly, I > > >> noticed that extra flags passed via COPT (notably -ffile-prefix-map) > > >> do not get added to CXXFLAGS. > > > > > PROFILE I can see, but COPT I'm less sure. The name suggests it's about > > > C not C++. How about adding CXXOPT? Any of that would work, I was adding it to both because both were the same so far. > > > Secondary question: Why aren't you using CFLAGS/CXXFLAGS for this? The context here is that we want to use the *FLAGS from pg_config for compiling PG extension packages, but add additional *FLAGS from the extension build environment. Merging the pg_config CFLAGS with the environment CFLAGS seemed hard/weird/error-prone, so what we are doing now is https://salsa.debian.org/postgresql/postgresql-common/blob/master/pg_buildext#L53-55 if [ "${CFLAGS:-}" ]; then export COPT="$CFLAGS" fi Which works nicely. > > COPT (and PROFILE) are handy for injecting additional flags manually; > > they're even documented for that (cf installation.sgml, around line > > 1550). > > > I agree that CXXOPT would be a better idea than COPT for this. > > Yea, I agree that we want CXX equivalent of the feature, especially for > -Werror. I'm just not sure that's the best fit for the debian build > issue Christoph ran into. I guess the goal is to *not* include the > -ffile-prefix-map in the CFLAGS for extensions, unless those are also > built via debian machinery? -ffile-prefix-map (or actually still -fdebug-prefix-map, -ffile-p-m is WIP) is the reason for the extra flags, yes. We can't use pg_config's version here because the build path for PG is not the build path for the extension module. > > Not sure about PROFILE. But we could inject the latter into both > > flag sets and then document that if that's not what you want, use > > COPT. > > That seems reasonable to me too. Updated patch: diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 956fd274cd..42bdf9f75c 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -674,8 +674,14 @@ ifdef COPT LDFLAGS += $(COPT) endif +ifdef CXXOPT + CXXFLAGS += $(CXXOPT) + LDFLAGS += $(CXXOPT) +endif + ifdef PROFILE CFLAGS += $(PROFILE) + CXXFLAGS += $(PROFILE) LDFLAGS += $(PROFILE) endif I didn't patch the documentation yet because I wasn't sure if the LDFLAGS handling with CXXOPT makes sense. Christoph -- Senior Berater, Tel.: +49 2166 9901 187 credativ GmbH, HRB Mönchengladbach 12080, USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz