Re: [RFC] building postgres with meson - v12

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, samay sharma <smilingsamay(at)gmail(dot)com>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Subject: Re: [RFC] building postgres with meson - v12
Date: 2022-09-13 01:06:23
Message-ID: 20220913010623.dpivpzsgy3oc427w@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2022-09-07 07:00:17 +0200, Peter Eisentraut wrote:
> On 31.08.22 20:11, Andres Freund wrote:
> > > src/port/win32ver.rc.in: This is redundant with src/port/win32ver.rc.
> > > (Note that the latter is also used as an input file for text
> > > substitution. So having another file named *.in next to it would be
> > > super confusing.)
> > Yea, this stuff isn't great. I think the better solution, both for meson and
> > for configure, would be to move to do all the substitution to the C
> > preprocessor.
>
> Yeah, I think if we can get rid of the evil date-based versioning, then
> this could be done like

> -win32ver.o: win32ver.rc
> - $(WINDRES) -i $< -o $@ --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir)
> +win32ver.o: $(top_srcdir)/src/port/win32ver.rc
> + $(WINDRES) -i $< -o $@ --include-dir=$(top_builddir)/src/include --include-dir=$(srcdir) -D FILEDESC=$(PGFILEDESC) -D VFT_APP=$(PGFTYPE) -D_ICO_=$(PGICOSTR) -D_INTERNAL_NAME_=$(if $(shlib),s;_INTERNAL_NAME_;"$(basename $(shlib))";,d) -D_ORIGINAL_NAME_=$(if $(shlib),s;_ORIGINAL_NAME_;"$(shlib)";,d)

It tried this and while it works for some places, it doesn't work for all. It
looks like windres uses broken quoting when internally invoking cpp. It
escapes e.g. whitespaces, but it doesn't escape at least < and >. Which
doesn't work well with descriptions like

PGFILEDESC = "cyrillic <-> mic text conversions"

resulting in this:

strace --string-limit=2000 -f -e execve \
x86_64-w64-mingw32-windres -DPGFILEDESC="cyrillic <-> mic text conversions" -DPGFTYPE=VFT_DLL -DPGNAME=cyrillic_and_mic -DPGFILEENDING=dll -I../../../../../../src/include -I/home/andres/src/postgresql/src/include -I/home/andres/src/postgresql/src/include/port/win32 "-I/home/andres/src/postgresql/src/include/port/win32" -DWIN32_STACK_RLIMIT=4194304 -i /home/andres/src/postgresql/src/port/win32ver.rc -o win32ver.o
...
[pid 1788987] execve("/bin/sh", ["sh", "-c", "x86_64-w64-mingw32-gcc -E -xc -DRC_INVOKED -DPGFILEDESC=cyrillic\\ <->\\ mic\\ text\\ conversions -DPGFTYPE=VFT_DLL -DPGNAME=cyrillic_and_mic -DPGFILEENDING=dll -I../../../../../../src/include -I/home/andres/src/postgresql/src/include -I/home/andres/src/postgresql/src/include/port/win32 -I/home/andres/src/postgresql/src/include/port/win32 -DWIN32_STACK_RLIMIT=4194304 /home/andres/src/postgresql/src/port/win32ver.rc"], 0x7ffd47edc790 /* 67 vars */) = 0
sh: 1: cannot open -: No such file
[pid 1788987] +++ exited with 2 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1788987, si_uid=1000, si_status=2, si_utime=0, si_stime=0} ---
x86_64-w64-mingw32-windres: preprocessing failed.

given this shoddy quoting, I think it's probably not wise to go down this
path?

We could invoke the preprocessor ourselves, but that requires feeding the
compiler via stdin (otherwise it'll just warn "linker input file unused
because linking not done") and defining -DRC_INVOKED (otherwise there'll be
syntax errors). That feels like too much magic?

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2022-09-13 01:30:42 Re: Error "initial slot snapshot too large" in create replication slot
Previous Message Justin Pryzby 2022-09-13 00:43:03 Re: fix stats_fetch_consistency value in postgresql.conf.sample