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 1w6CM6-0043BB-1o for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 18:56:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6CM4-00BSkD-07 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 18:56:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w6CM3-00BSk4-06 for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 18:56:24 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w6CLz-00000001X2F-37WG for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 18:56:23 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id C4D2DEC01B8; Fri, 27 Mar 2026 14:56:17 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 27 Mar 2026 14:56:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1774637777; x=1774724177; bh=eO9fulIYYH1dej9dLSLtzCKNDxGTxY8TtDCMhqv/ZnA=; b= K/3XtvfeVrOoXvcZtN0TwQS8CKgRY/dNmOqVeIimKfmVHNTE127bk91jEAVSd2vN Q34wNRCpEjYkpVH5rDtd01lJ9xII34ZSQMsivM8dZVsb9n7zvB3G3/huRdp29bej gPuz0JZtIVXVQHtzIzNJGf8B1HmWWSH2WFeRCuirvH9ztDSxgefWKRqz0JrYL94b OYGH1SjyAqpNDz5P/uExUdyAvkDfesAG+ifdS6fJAIpXEYVMYuSMp+7Q4C2ytGl0 BYKnmY8wGNaJ+gbDr9m+g+zJLcPSpsWHG3BNyuVty8tjpMJ5KiMJu8muwTqjG2KE 6O5YgiNlKkLWMh6KUTXBbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1774637777; x= 1774724177; bh=eO9fulIYYH1dej9dLSLtzCKNDxGTxY8TtDCMhqv/ZnA=; b=t iGjJQLDeccwUrPzDWbVpgYw8vQVmF3cLNrDekaSKvZcNhylRnwKEaE/dRALmUYf3 j+nFb5rZSQtB8Ijl45692lgxiYtTKEHORvCFSGmN3HGcgOdt4FAOEeNlYhqqtuc0 FxHZUy1nE4bCjZBrv8g6QmX0kmOCF73/0TKFp9edkb+YVRnnOUds6ZWAXGZFKxOa 7KNmZk9ObuwHu3QWSOml/7BL0Sx1GNlsFjEU0d8/KvZ8qyqt9xA0JBH5tq9cgKLp tOdgctiovGZj2OcRLYChzZ3gC+kNGocWVJyehWURSbOgGmU+BYXURGTW3/o4TX8E 44fcAbKpXn9H1RYYILxJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeffedutdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehmkefsredttddunecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvvefhueehhfegteehveektdekgedthedvveevgffglefhffevueetueet heevjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepvddpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtsh drphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepmhdrmhgvlhhnihhkohhvsehp ohhsthhgrhgvshhprhhordhruh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Mar 2026 14:56:16 -0400 (EDT) Date: Fri, 27 Mar 2026 14:56:16 -0400 From: Andres Freund To: "Maksim.Melnikov" Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Fix race with LLVM and bison. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="emtl7nvumnww5eic" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --emtl7nvumnww5eic Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 --emtl7nvumnww5eic Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fix-llvm-contrib-pgxs-deps.diff" diff --git i/src/makefiles/pgxs.mk w/src/makefiles/pgxs.mk index 039cee3dfe5..d7732024b15 100644 --- i/src/makefiles/pgxs.mk +++ w/src/makefiles/pgxs.mk @@ -219,7 +219,12 @@ endef all: $(PROGRAM) $(DATA_built) $(HEADER_allbuilt) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION)) ifeq ($(with_llvm), yes) +# Ensure that .bc files for MODULES and OBJS get built with all all: $(addsuffix .bc, $(MODULES)) $(patsubst %.o,%.bc, $(OBJS)) +# Ensure that each .bc file depends on the corresponding .o file, to ensure +# the dependencies required for it to be built are present. +$(patsubst %.o,%.bc, $(OBJS)): $(OBJS) +$(addsuffix .bc, $(MODULES)): $(addsuffix .o, $(MODULES)) endif ifdef MODULE_big diff --git i/src/backend/common.mk w/src/backend/common.mk index 61861f5c7eb..85bb4ee2527 100644 --- i/src/backend/common.mk +++ w/src/backend/common.mk @@ -22,7 +22,10 @@ objfiles.txt: Makefile $(SUBDIROBJS) $(OBJS) $(if $(filter-out $(OBJS),$?),( $(if $(SUBDIROBJS),cat $(SUBDIROBJS); )echo $(addprefix $(subdir)/,$(OBJS)) ) >$@,touch $@) ifeq ($(with_llvm), yes) +# Ensure that .bc files get built when building .o files objfiles.txt: $(patsubst %.o,%.bc, $(OBJS)) +# Ensure that each .bc file depends on the corresponding .o file, to ensure +# the dependencies required for it to be built are present. $(patsubst %.o,%.bc, $(OBJS)): $(OBJS) endif --emtl7nvumnww5eic--