On 3/31/26 01:37, Zsolt Parragi wrote:
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.
pg_plan_advice also seems to be affected and is missing from the
original patch, a generic fix like this handles that too and all
future cases.

Yes, It will be okay with Andres fix.

I've noticed that Andres patch wasn't moved to CF, so I feel free to add Andres patch to commitfest [0], I apologize if it isn't good.

Best regards

Maksim Melnikov

[0]: https://commitfest.postgresql.org/patch/7206
From b64c21f7eb3a8b844ec4c827275dc17590d653fa Mon Sep 17 00:00:00 2001
From: Maksim Melnikov <[email protected]>
Date: Thu, 27 Aug 2026 13:17:20 +0300
Subject: [PATCH v3] Fix race with LLVM and bison.

Ensure that each .bc files for MODULES depends on the corresponding .o file,
to ensure the dependencies required for it to be built are present.

Author: Andres Freund <[email protected]>
Discussion: https://www.postgresql.org/message-id/f070a61e-1dd3-4fd9-bbc9-18d100b6722a%40postgrespro.ru
---
 src/backend/common.mk | 3 +++
 src/makefiles/pgxs.mk | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/src/backend/common.mk b/src/backend/common.mk
index 61861f5c7eb..85bb4ee2527 100644
--- a/src/backend/common.mk
+++ b/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
 
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 039cee3dfe5..d7732024b15 100644
--- a/src/makefiles/pgxs.mk
+++ b/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
-- 
2.43.0

Reply via email to