Re: Raising our compiler requirements for 9.6

From: Andres Freund <andres(at)anarazel(dot)de>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Raising our compiler requirements for 9.6
Date: 2015-08-16 00:03:01
Message-ID: 20150816000301.GA3522@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-08-15 12:47:09 -0400, Noah Misch wrote:
> Atomics were a miner's canary for pademelon's trouble with post-de6fd1c
> inlining. Expect pademelon to break whenever a frontend-included file gains
> an inline function that calls a backend function. Atomics were the initial
> examples, but this patch adds more:

That's a good point.

> $ make -s PROFILE='-O0 -DPG_FORCE_DISABLE_INLINE=1'
> pg_resetxlog.o: In function `fastgetattr':
> /data/nmisch/src/pg/postgresql/src/bin/pg_resetxlog/../../../src/include/access/htup_details.h:754: undefined reference to `nocachegetattr'
> pg_resetxlog.o: In function `heap_getattr':
> /data/nmisch/src/pg/postgresql/src/bin/pg_resetxlog/../../../src/include/access/htup_details.h:783: undefined reference to `heap_getsysattr'
>
> The htup_details.h case is trickier in a way, because pg_resetxlog has a
> legitimate need for SizeofHeapTupleHeader via TOAST_MAX_CHUNK_SIZE. Expect
> this class of problem to recur as we add more inline functions. Our method to
> handle these first two instances will set a precedent.
>
> That gave me new respect for STATIC_IF_INLINE. While it does add tedious work
> to the task of introducing a new batch of inline functions, the work is
> completely mechanical. Anyone can write it; anyone can review it; there's one
> correct way to write it.

What's the advantage of using STATIC_IF_INLINE over just #ifndef
FRONTEND? That doesn't work well for entire headers in my opinion, but
for individual functions it shouldn't be a problem? In fact we've done
it for years for MemoryContextSwitchTo(). And by the problem definition
such functions cannot be required by frontend code.

STATIC_IF_INLINE is really tedious because to know whether it works you
essentially need to recompile postgres with inlines enabled/disabled.

In fact STATIC_IF_INLINE does *not* even help here unless we also detect
compilers that support inlining but balk when inline functions reference
symbols not available. There was an example of that in the buildfarm as
of 2014, c.f. a9baeb361d63 . We'd have to disable inlining for such
compilers.

> Header surgery like
> 0001-Don-t-include-low-level-locking-code-from-frontend-c.patch
> requires expert design from scratch, and it (trivially) breaks builds
> for a sample of non-core code.

I agree that such surgery isn't always a good idea. In my opinion the
removing proc.h from the number of headers in the above and the followon
WIP patch I posted has value completely independently from fixing
problems.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-08-16 01:20:55 Re: Autonomous Transaction is back
Previous Message Zhaomo Yang 2015-08-15 23:30:30 Re: CREATE POLICY and RETURNING