Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w77Tr-004yqS-1e for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 07:56:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w77Tp-001zZ3-0D for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 07:56:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w77To-001zYv-20 for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 07:56:13 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w77Ti-00000001lnC-3BJI for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 07:56:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1774857362; bh=Ho6llsvOSJrDPxIkVgCLaQ5ae2fr2emlVbmgOtHkWTs=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=OickjAibnRMeNJ2Dh6X/UhpaBCFE3gc5g+vjgM9d+P+eK0NYvyKiBDj+fC+sM0yWj 0uBa0v4FiVF8ns3rcQTNc1FXKT0qNwASOyi2T1cVmdx5y5NJtdlvMskVo5yOpBxLdp 4zgFbOlzpG2xV2R4gGOXZ7/GVkWLee+XCg1nGRErOWrtAJiD2dQYuWLgrTBDyQlWL9 O49+r7wd4fnWFMzKhCqWftuz+Q7wMF//XHYIAhGWEFQblYaj7GKuXxKn6o/+wRsxmu vLNVvu7PfrCOr2QtHDa2KUp14PW4Q0nxpEOh98N0wa476AT1p/2bqrHzcsIkO+xLYP 5frKNz3yReGMg== Received: from [172.30.51.130] (debian11-template.l.postgrespro.ru [192.168.2.254]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: m.melnikov@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 525D65FFA2; Mon, 30 Mar 2026 10:56:02 +0300 (MSK) Content-Type: multipart/mixed; boundary="------------sJgux6tB0M0HDhUkgc5LMhGH" Message-ID: Date: Mon, 30 Mar 2026 10:56:02 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix race with LLVM and bison. To: Andres Freund Cc: pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: "Maksim.Melnikov" In-Reply-To: X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2026/03/30 05:24:00 #28352470 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------sJgux6tB0M0HDhUkgc5LMhGH Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi On 3/27/26 21:56, Andres Freund wrote: > 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 Thanks for attentions, I see your patch is better. Few additional thoughts 1. Now I see that we have two different places to configure backend and extensions, maybe we should apply your patch to some common place, for example src/Makefile.global.in, because it seems common build logic. How do you think? 2. If you have some doubts about backpatch, I suggest to apply fix-llvm-contrib-pgxs-deps.diff on master and patch v2-0001-Fix-race-with-LLVM-compilation-and-bison-code-gen.patch as backpatch, because this one correct it only for problematic contribs. How do you think? Greetings, Maksim Melnikov --------------sJgux6tB0M0HDhUkgc5LMhGH Content-Type: text/x-patch; charset=UTF-8; name="v2-0001-Fix-race-with-LLVM-compilation-and-bison-code-gen.patch" Content-Disposition: attachment; filename*0="v2-0001-Fix-race-with-LLVM-compilation-and-bison-code-gen.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSAwZjcyMjM5Njg0NjI3NzM4N2M4ODYwNmFkZGJhYTgxNjBmM2VlZTllIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBNYWtzaW0gTWVsbmlrb3YgPG0ubWVs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