Re: Fix race with LLVM and bison.

From: Andres Freund <andres(at)anarazel(dot)de>
To: "Maksim(dot)Melnikov" <m(dot)melnikov(at)postgrespro(dot)ru>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fix race with LLVM and bison.
Date: 2026-03-27 18:56:16
Message-ID: v67jke2iv6kaywjnvwhxc3u5x3ttvrz555k5ngcxu2qwu435rl@5wpsxnrsz23k
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-03-27 14:31:52 +0300, Maksim.Melnikov wrote:
> I've found build error in configuration --with-llvm
>
> CPPFLAGS="-O2" ./configure --enable-debug --enable-cassert
> --enable-tap-tests --with-openssl --with-icu  --with-llvm
>
> ....
>
> make world-bin -j3
>
> ....
>
> cubescan.c:9:10: fatal error: 'cubeparse.h' file not found
>     9 | #include "cubeparse.h"  /* must be after cubedata.h for YYSTYPE and
> NDBOX */
>
> ....
> segscan.c:9:10: fatal error: 'segparse.h' file not found
>     9 | #include "segparse.h"   /* must be after segdata.h for SEG */
>
>
> The reason is race, that exist between LLVM compilation and bison source
> code generation and compilation can occur first.
>
> Ideally LLVM compilation target should depend on header files targets.
>
> The error is difficult to reproduce and I've done simple patch to have
> stable reproducing. Fix patch is also attached.

You don't need a sleep to show there's a problem, you can just do
make -C contrib/cube cubescan.bc

We don't have the same issue in the backend, as for backend code each .bc file
depends on the .o file:

src/backend/common.mk:

ifeq ($(with_llvm), yes)
objfiles.txt: $(patsubst %.o,%.bc, $(OBJS))
$(patsubst %.o,%.bc, $(OBJS)): $(OBJS)
endif

But for some reason I didn't add the same logic to pgxs.mk.

I think we need something like the attached to make the dependencies work.

I'm a bit worried about breaking some extensions if were to backpatch this. So
I'm somewhat inclined to just fix this in master.

Greetings,

Andres Freund

Attachment Content-Type Size
fix-llvm-contrib-pgxs-deps.diff text/x-diff 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-03-27 18:56:18 Re: add function argument name to substring and substr
Previous Message KAZAR Ayoub 2026-03-27 18:48:38 Re: Speed up COPY TO text/CSV parsing using SIMD