pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: pgsql: Fix for globals.c- c.h must come first
9+ messages / 3 participants
[nested] [flat]
* Re: pgsql: Fix for globals.c- c.h must come first
@ 2018-06-19 17:58 Bruce Momjian <bruce@momjian.us>
2018-06-19 18:03 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 9+ messages in thread
From: Bruce Momjian @ 2018-06-19 17:58 UTC (permalink / raw)
To: Stephen Frost <sfrost@snowman.net>; +Cc: pgsql-committers@lists.postgresql.org
On Sat, May 19, 2018 at 01:20:47AM +0000, Stephen Frost wrote:
> Fix for globals.c- c.h must come first
>
> Commit da9b580 mistakenly put a system header before postgres.h (which
> includes c.h). That can cause portability issues and broke (at least)
> builds with older Windows compilers.
I assume there is no way to add defined and checks to globals.c and c.h
to cause a compile error when this happens.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
@ 2018-06-19 18:03 ` Andres Freund <andres@anarazel.de>
1 sibling, 0 replies; 9+ messages in thread
From: Andres Freund @ 2018-06-19 18:03 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
On 2018-06-19 13:58:34 -0400, Bruce Momjian wrote:
> On Sat, May 19, 2018 at 01:20:47AM +0000, Stephen Frost wrote:
> > Fix for globals.c- c.h must come first
> >
> > Commit da9b580 mistakenly put a system header before postgres.h (which
> > includes c.h). That can cause portability issues and broke (at least)
> > builds with older Windows compilers.
>
> I assume there is no way to add defined and checks to globals.c and c.h
> to cause a compile error when this happens.
I don't see how to do so in a form that's even halfway portable.
Just to be clear: There's nothing globals.c specific about the rule to
always include postgres.h first.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
@ 2018-06-19 18:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
1 sibling, 1 reply; 9+ messages in thread
From: Tom Lane @ 2018-06-19 18:09 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
Bruce Momjian <bruce@momjian.us> writes:
> On Sat, May 19, 2018 at 01:20:47AM +0000, Stephen Frost wrote:
>> Commit da9b580 mistakenly put a system header before postgres.h (which
>> includes c.h). That can cause portability issues and broke (at least)
>> builds with older Windows compilers.
> I assume there is no way to add defined and checks to globals.c and c.h
> to cause a compile error when this happens.
Hm. You could imagine adding something like
#ifdef some-relevant-macro
#error include ordering problem, c.h must come before system headers
#endif
near the head of c.h. But I'm not sure how we'd get full coverage.
The case presumably would only occur for off-the-beaten-path headers
(this particular mistake was <sys/stat.h>), and there are lots of those.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-06-19 18:15 ` Andres Freund <andres@anarazel.de>
2018-06-19 18:19 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 9+ messages in thread
From: Andres Freund @ 2018-06-19 18:15 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bruce Momjian <bruce@momjian.us>; Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
On 2018-06-19 14:09:15 -0400, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > On Sat, May 19, 2018 at 01:20:47AM +0000, Stephen Frost wrote:
> >> Commit da9b580 mistakenly put a system header before postgres.h (which
> >> includes c.h). That can cause portability issues and broke (at least)
> >> builds with older Windows compilers.
>
> > I assume there is no way to add defined and checks to globals.c and c.h
> > to cause a compile error when this happens.
>
> Hm. You could imagine adding something like
>
> #ifdef some-relevant-macro
> #error include ordering problem, c.h must come before system headers
> #endif
>
> near the head of c.h. But I'm not sure how we'd get full coverage.
> The case presumably would only occur for off-the-beaten-path headers
> (this particular mistake was <sys/stat.h>), and there are lots of those.
If we were ok with doing this in a very platform specific manner, we
probably could make the dependency fairly generic. I.e. glibc IIRC will
pretty much always end up including features.h, so we could check for
that (#ifdef _FEATURES_H). I'd suspect other C libraries have similar
things.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
@ 2018-06-19 18:19 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:22 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:30 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
0 siblings, 2 replies; 9+ messages in thread
From: Tom Lane @ 2018-06-19 18:19 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Bruce Momjian <bruce@momjian.us>; Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
Andres Freund <andres@anarazel.de> writes:
> On 2018-06-19 14:09:15 -0400, Tom Lane wrote:
>> Hm. You could imagine adding something like
>>
>> #ifdef some-relevant-macro
>> #error include ordering problem, c.h must come before system headers
>> #endif
>>
>> near the head of c.h. But I'm not sure how we'd get full coverage.
>> The case presumably would only occur for off-the-beaten-path headers
>> (this particular mistake was <sys/stat.h>), and there are lots of those.
> If we were ok with doing this in a very platform specific manner, we
> probably could make the dependency fairly generic. I.e. glibc IIRC will
> pretty much always end up including features.h, so we could check for
> that (#ifdef _FEATURES_H). I'd suspect other C libraries have similar
> things.
It'd probably be good enough if the error detection worked with glibc's
headers. Even if nobody noticed before a particular patch went in,
the buildfarm would surely find it.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
2018-06-19 18:19 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-06-19 18:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 21:05 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
1 sibling, 1 reply; 9+ messages in thread
From: Tom Lane @ 2018-06-19 18:22 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Bruce Momjian <bruce@momjian.us>; Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
I wrote:
> It'd probably be good enough if the error detection worked with glibc's
> headers. Even if nobody noticed before a particular patch went in,
> the buildfarm would surely find it.
On second thought, we'd also need a solution for Windows, because we
have some files that only get compiled for Windows. But even two
separate tests of this sort seems reasonable.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
2018-06-19 18:19 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:22 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-06-19 21:05 ` Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 9+ messages in thread
From: Andres Freund @ 2018-06-19 21:05 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Amit Kapila <amit.kapila16@gmail.com>; Michael Paquier <michael.paquier@gmail.com>; +Cc: Bruce Momjian <bruce@momjian.us>; Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
Hi,
On 2018-06-19 14:22:25 -0400, Tom Lane wrote:
> I wrote:
> > It'd probably be good enough if the error detection worked with glibc's
> > headers. Even if nobody noticed before a particular patch went in,
> > the buildfarm would surely find it.
>
> On second thought, we'd also need a solution for Windows, because we
> have some files that only get compiled for Windows. But even two
> separate tests of this sort seems reasonable.
Could anybody working on windows (Amit, Michael?) check whether there's
an equivalent to my _FEATURES_H trick?
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
2018-06-19 18:19 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-06-19 18:30 ` Andres Freund <andres@anarazel.de>
2018-06-19 19:21 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 9+ messages in thread
From: Andres Freund @ 2018-06-19 18:30 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Bruce Momjian <bruce@momjian.us>; Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
Hi,
On 2018-06-19 14:19:56 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > On 2018-06-19 14:09:15 -0400, Tom Lane wrote:
> >> Hm. You could imagine adding something like
> >>
> >> #ifdef some-relevant-macro
> >> #error include ordering problem, c.h must come before system headers
> >> #endif
> >>
> >> near the head of c.h. But I'm not sure how we'd get full coverage.
> >> The case presumably would only occur for off-the-beaten-path headers
> >> (this particular mistake was <sys/stat.h>), and there are lots of those.
>
> > If we were ok with doing this in a very platform specific manner, we
> > probably could make the dependency fairly generic. I.e. glibc IIRC will
> > pretty much always end up including features.h, so we could check for
> > that (#ifdef _FEATURES_H). I'd suspect other C libraries have similar
> > things.
>
> It'd probably be good enough if the error detection worked with glibc's
> headers. Even if nobody noticed before a particular patch went in,
> the buildfarm would surely find it.
Then the _FEATURES_H check would work - just tested it locally, and it
triggers appropriately. Does tie us a bit to specific glibc versions,
but... Obvoiusly would need some comments explaining it
Are there arguments for doing this in postgres.h rather than c.h? I
can't immediately think of a case where it'd be ok for postgres_fe.h or
such to be included later. libpq-fe would be different, but that
doesn't include backend headers.
I think we shouldn't do this for v11, as it seems likely that some
extensions would be broken. While not hard to fix, that seems
unnecessary after beta1? Seems unlikely we'll introduce further cases
before new features are merged.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: pgsql: Fix for globals.c- c.h must come first
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:09 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
2018-06-19 18:19 ` Re: pgsql: Fix for globals.c- c.h must come first Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:30 ` Re: pgsql: Fix for globals.c- c.h must come first Andres Freund <andres@anarazel.de>
@ 2018-06-19 19:21 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 9+ messages in thread
From: Tom Lane @ 2018-06-19 19:21 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Bruce Momjian <bruce@momjian.us>; Stephen Frost <sfrost@snowman.net>; pgsql-committers@lists.postgresql.org
Andres Freund <andres@anarazel.de> writes:
> Are there arguments for doing this in postgres.h rather than c.h?
No, c.h is the correct place. The core problem is that we have to include
pg_config.h before <stdio.h> et al in order to have consistent libc APIs
(on platforms where this matters), and c.h is what does that.
> I think we shouldn't do this for v11, as it seems likely that some
> extensions would be broken. While not hard to fix, that seems
> unnecessary after beta1? Seems unlikely we'll introduce further cases
> before new features are merged.
Yeah, waiting for v12 seems fine.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2018-06-19 21:05 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19 17:58 Re: pgsql: Fix for globals.c- c.h must come first Bruce Momjian <bruce@momjian.us>
2018-06-19 18:03 ` Andres Freund <andres@anarazel.de>
2018-06-19 18:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:15 ` Andres Freund <andres@anarazel.de>
2018-06-19 18:19 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 18:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-06-19 21:05 ` Andres Freund <andres@anarazel.de>
2018-06-19 18:30 ` Andres Freund <andres@anarazel.de>
2018-06-19 19:21 ` 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