Re: failing to build preproc.c on solaris with sun studio

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, John Naylor <john(dot)naylor(at)enterprisedb(dot)com>, Michael Meskes <meskes(at)postgresql(dot)org>, Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: failing to build preproc.c on solaris with sun studio
Date: 2022-09-15 04:53:09
Message-ID: CA+hUKGJJc1czzsNBNbBCbn7v_6s2ua9k73Zs7ZYg1tk9zFL_=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 14, 2022 at 4:34 PM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:
> On Wed, Sep 14, 2022 at 03:08:06PM +1200, Thomas Munro wrote:
> > On Wed, Sep 14, 2022 at 10:23 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > > Given the simplicity of this case, though, I suppose we could
> > > have a little not-very-general shell/python/whatever wrapper script --
> > > just compute a checksum of the input and keep the output files around.
> >
> > Something as dumb as this perhaps...
>
> > if [ -z "$c_file" ] ; then
> > c_file="(echo "$y_file" | sed 's/\.y/.tab.c/')"
> > fi
>
> This looks wrong. I guess you mean to use $() and missing "$" ?

Yeah, but your %.y style is much nicer. Fixed that way. (I was
trying to avoid what I thought were non-standard extensions but I see
that's in POSIX sh. Cool.)

> It could be:
> [ -z "$c_file" ] &&
> c_file=${y_file%.y}.tab.c

Meh.

> > if [ -z "$SIMPLE_BISON_CACHE_PATH" ] ; then
> > SIMPLE_BISON_CACHE_PATH="/tmp/simple-bison-cache"
> > fi
>
> Should this default to CCACHE_DIR? Then it would work under cirrusci...

Not sure it's OK to put random junk in ccache's directory, and in any
case we'd certainly want to teach it to trim itself before doing that
on CI... On the other hand, adding another registered cache dir would
likely add several seconds to CI, more than what can be saved with
this trick! The amount of time we can save is only a few seconds, or
less on a fast machine.

So... I guess the target audience of this script is extremely
impatient people working locally, since with Meson our clean builds
are cleaner, and will lead to re-execution this step. I just tried
Andres's current meson branch on my fast-ish 16 core desktop, and
then, after priming caches, "ninja clean && time ninja" tells me:

real 0m3.133s

After doing 'meson configure
-DBISON="/path/to/simple-bison-cache.sh"', I get it down to:

real 0m2.440s

However, in doing that I realised that you need an executable name,
not a hairy shell command fragment, so you can't use
"simple-bison-cache.sh bison", so I had to modify the script to be a
wrapper that knows how to find bison. Bleugh.

> > h_file="$(echo $c_file | sed 's/\.c/.h/')"
>
> Could be ${c_file%.c}.h

Much nicer.

> > if [ ! -e "$cached_c_file" -o ! -e "$cached_h_file" ] ; then
>
> You could write the easy case first (I forget whether it's considered to
> be more portable to write && outside of []).

Agreed, it's nicer that way around.

> I can't see what part of this would fail to handle filenames with spaces> (?)

Yeah, seems OK. I also fixed the uncertainty about -d, and made a
small tweak after testing on Debian, MacOS and FreeBSD. BTW this
isn't a proposal for src/tools yet, I'm just sharing for curiosity...
I suppose a version good enough to live in src/tools would need to
trim the cache, and I don't enjoy writing code that deletes files in
shell script, so maybe this'd need to be written in Python...

Attachment Content-Type Size
simple-bison-cache.sh application/x-shellscript 1.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-09-15 04:58:12 Re: Switching XLog source from archive to streaming when primary available
Previous Message houzj.fnst@fujitsu.com 2022-09-15 02:48:20 RE: why can't a table be part of the same publication as its schema