On Fri, Jan 30, 2026 at 01:38:42PM +0900, Michael Paquier wrote:
> While looking at the whole object dependency tree in the builds, I
> have settled down to a reuse of the same logic as guc_tables.inc.c for
> configure/make, by pushing down one level the generation of the three
> wait event files.  These are not anymore saved in
> src/backend/utils/activity/, just src/backend/utils/, including them
> under header-stamp.  Building directly in src/backend/utils/activity/
> also works, with two rules in src/backend/utils/activity/Makefile to
> force a rebuild.  The files are then included as if they were in
> include/utils/, with the generation of links from src/backend/utils/
> to src/include/utils/, just like guc_tables.inc.c.  That's the least
> invasive method I could come up with.
> 
> I have run out of tokens for the CI this month, so I have not been
> able to check it there.  My manual tests across all three build
> methods are working.

Scratch that a bit..  Some grepping is pointing out that
generated_sources_ac would become incorrect in
src/include/utils/meson.build.

Three paths in wait_event_names.txt were also inconsistent.  It is
worth noting that the sgml path is entirely wrong, this is generated
in doc/src/sgml/.  

Comments and thoughts are welcome.
--
Michael
From ac7b085172c054914bd3557bd1330681fadc68ac Mon Sep 17 00:00:00 2001
From: Michael Paquier <[email protected]>
Date: Fri, 30 Jan 2026 13:51:15 +0900
Subject: [PATCH v2] Fix incorrect generation of wait-event files

In a meson build, include/utils was incorrectly listed in the set of
include_directories.  This would conflict with the headers pulled in by
an environment.  This issue has not been an issue in the buildfarm; it
has been noted with AIX and a conflict with float.h.

Combo oversight in fa88928470b5 and 1e68e43d3f0f.

blah, blah..

Discussion: https://postgr.es/m/vua2n6svb6fac3fmz42ahqxndmgbgor7vpxtemis5evasfpzb3@ogs4ewexkpjm
Backpatch-through: 17
---
 src/include/Makefile                            |  1 +
 src/include/utils/.gitignore                    |  2 ++
 src/include/utils/meson.build                   |  4 +---
 src/backend/Makefile                            | 10 +---------
 src/backend/utils/.gitignore                    |  3 +++
 src/backend/utils/Makefile                      | 13 ++++++++++---
 src/backend/utils/activity/.gitignore           |  3 ---
 src/backend/utils/activity/Makefile             | 17 ++++-------------
 src/backend/utils/activity/meson.build          |  1 -
 src/backend/utils/activity/wait_event.c         |  2 +-
 src/backend/utils/activity/wait_event_funcs.c   |  2 +-
 src/backend/utils/activity/wait_event_names.txt |  6 +++---
 12 files changed, 27 insertions(+), 37 deletions(-)
 delete mode 100644 src/backend/utils/activity/.gitignore

diff --git a/src/include/Makefile b/src/include/Makefile
index 4ef060e90503..ac673f4cf17b 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -105,6 +105,7 @@ uninstall:
 
 clean:
 	rm -f utils/fmgroids.h utils/fmgrprotos.h utils/guc_tables.inc.c utils/errcodes.h utils/header-stamp
+	rm -f utils/pgstat_wait_event.c utils/wait_event_funcs_data.c
 	rm -f storage/lwlocknames.h utils/probes.h utils/wait_event_types.h
 	rm -f nodes/nodetags.h nodes/header-stamp
 	$(MAKE) -C catalog clean
diff --git a/src/include/utils/.gitignore b/src/include/utils/.gitignore
index 30f921429c6f..ff6f61cd7ee7 100644
--- a/src/include/utils/.gitignore
+++ b/src/include/utils/.gitignore
@@ -4,4 +4,6 @@
 /probes.h
 /errcodes.h
 /header-stamp
+/pgstat_wait_event.c
+/wait_event_funcs_data.c
 /wait_event_types.h
diff --git a/src/include/utils/meson.build b/src/include/utils/meson.build
index 318a6aec0d06..fd3a2352df5d 100644
--- a/src/include/utils/meson.build
+++ b/src/include/utils/meson.build
@@ -79,8 +79,6 @@ generated_backend_headers += fmgrtab_target[1]
 
 # autoconf generates the file there, ensure we get a conflict
 generated_sources_ac += {
-  'src/backend/utils': fmgrtab_output + ['errcodes.h', 'probes.h', 'fmgr-stamp'],
+  'src/backend/utils': fmgrtab_output + ['errcodes.h', 'wait_event_types.h', 'probes.h', 'fmgr-stamp'],
   'src/include/utils': ['header-stamp'],
 }
-
-generated_sources_ac += {'src/backend/utils/activity': ['wait_event_types.h']}
diff --git a/src/backend/Makefile b/src/backend/Makefile
index baa9b05d0211..05642dc02e39 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -136,9 +136,6 @@ parser/gram.h: parser/gram.y
 storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl ../include/storage/lwlocklist.h utils/activity/wait_event_names.txt
 	$(MAKE) -C storage/lmgr lwlocknames.h
 
-utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl utils/activity/wait_event_names.txt
-	$(MAKE) -C utils/activity wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
-
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-catalog-headers:
 	$(MAKE) -C ../include/catalog generated-headers
@@ -163,18 +160,13 @@ submake-utils-headers:
 
 .PHONY: generated-headers
 
-generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers parser/gram.h
+generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h submake-catalog-headers submake-nodes-headers submake-utils-headers parser/gram.h
 
 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
 	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	  cd '$(dir $@)' && rm -f $(notdir $@) && \
 	  $(LN_S) "$$prereqdir/$(notdir $<)" .
 
-$(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
-
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
 
diff --git a/src/backend/utils/.gitignore b/src/backend/utils/.gitignore
index 303c01d05151..fa9cfb39693d 100644
--- a/src/backend/utils/.gitignore
+++ b/src/backend/utils/.gitignore
@@ -5,3 +5,6 @@
 /guc_tables.inc.c
 /probes.h
 /errcodes.h
+/pgstat_wait_event.c
+/wait_event_funcs_data.c
+/wait_event_types.h
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index 6df31504f328..81b4a956bda3 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -43,7 +43,7 @@ generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp submak
 submake-adt-headers:
 	$(MAKE) -C adt jsonpath_gram.h
 
-$(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h guc_tables.inc.c
+$(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h guc_tables.inc.c pgstat_wait_event.c wait_event_funcs_data.c wait_event_types.h
 
 # fmgr-stamp records the last time we ran Gen_fmgrtab.pl.  We don't rely on
 # the timestamps of the individual output files, because the Perl script
@@ -58,6 +58,12 @@ errcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes.pl
 guc_tables.inc.c: $(top_srcdir)/src/backend/utils/misc/guc_parameters.dat $(top_srcdir)/src/backend/utils/misc/gen_guc_tables.pl
 	$(PERL) $(top_srcdir)/src/backend/utils/misc/gen_guc_tables.pl $< $@
 
+pgstat_wait_event.c: wait_event_types.h
+wait_event_funcs_data.c: wait_event_types.h
+
+wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl
+	$(PERL) $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl --code $<
+
 ifeq ($(enable_dtrace), yes)
 probes.h: postprocess_dtrace.sed probes.h.tmp
 	sed -f $^ >$@
@@ -73,8 +79,8 @@ endif
 # These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than fmgr-stamp.
-$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h guc_tables.inc.c
-	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h guc_tables.inc.c; do \
+$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h guc_tables.inc.c pgstat_wait_event.c wait_event_funcs_data.c wait_event_types.h
+	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h guc_tables.inc.c pgstat_wait_event.c wait_event_funcs_data.c wait_event_types.h; do \
 	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
@@ -93,3 +99,4 @@ uninstall-data:
 clean:
 	rm -f probes.h probes.h.tmp
 	rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h guc_tables.inc.c
+	rm -f wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
diff --git a/src/backend/utils/activity/.gitignore b/src/backend/utils/activity/.gitignore
deleted file mode 100644
index bd0c0c777298..000000000000
--- a/src/backend/utils/activity/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/pgstat_wait_event.c
-/wait_event_types.h
-/wait_event_funcs_data.c
diff --git a/src/backend/utils/activity/Makefile b/src/backend/utils/activity/Makefile
index 0eb29ee78aa0..c37bfb350bbc 100644
--- a/src/backend/utils/activity/Makefile
+++ b/src/backend/utils/activity/Makefile
@@ -36,17 +36,8 @@ OBJS = \
 	wait_event.o \
 	wait_event_funcs.o
 
+# Force these dependencies to be known even without dependency info built:
+wait_event.o: wait_event.c $(top_builddir)/src/backend/utils/pgstat_wait_event.c
+wait_event_funcs.o: wait_event_funcs.c $(top_builddir)/src/backend/utils/wait_event_funcs_data.c
+
 include $(top_srcdir)/src/backend/common.mk
-
-wait_event_funcs.o: wait_event_funcs_data.c
-wait_event_funcs_data.c: wait_event_types.h
-
-wait_event.o: pgstat_wait_event.c
-pgstat_wait_event.c: wait_event_types.h
-	touch $@
-
-wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-wait_event_types.pl
-	$(PERL) $(srcdir)/generate-wait_event_types.pl --code $<
-
-clean:
-	rm -f wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
diff --git a/src/backend/utils/activity/meson.build b/src/backend/utils/activity/meson.build
index 9f48d5970e17..53bd5a246cab 100644
--- a/src/backend/utils/activity/meson.build
+++ b/src/backend/utils/activity/meson.build
@@ -30,7 +30,6 @@ waitevent_sources = files(
 wait_event = static_library('wait_event_names',
   waitevent_sources,
   dependencies: [backend_code],
-  include_directories: include_directories('../../../include/utils'),
   kwargs: internal_lib_args,
 )
 
diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c
index e4f2c440257d..aca2c8fc742a 100644
--- a/src/backend/utils/activity/wait_event.c
+++ b/src/backend/utils/activity/wait_event.c
@@ -503,4 +503,4 @@ pgstat_get_wait_event(uint32 wait_event_info)
 	return event_name;
 }
 
-#include "pgstat_wait_event.c"
+#include "utils/pgstat_wait_event.c"
diff --git a/src/backend/utils/activity/wait_event_funcs.c b/src/backend/utils/activity/wait_event_funcs.c
index b62ee83ef73c..fa10a80b0887 100644
--- a/src/backend/utils/activity/wait_event_funcs.c
+++ b/src/backend/utils/activity/wait_event_funcs.c
@@ -31,7 +31,7 @@ static const struct
 
 			waitEventData[] =
 {
-#include "wait_event_funcs_data.c"
+#include "utils/wait_event_funcs_data.c"
 	/* end of list */
 	{NULL, NULL, NULL}
 };
diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt
index 5537a2d25301..efde48e76b72 100644
--- a/src/backend/utils/activity/wait_event_names.txt
+++ b/src/backend/utils/activity/wait_event_names.txt
@@ -14,13 +14,13 @@
 #
 # The files generated from this one are:
 #
-#   src/backend/utils/activity/wait_event_types.h
+#   wait_event_types.h
 #      typedef enum definitions for wait events.
 #
-#   src/backend/utils/activity/pgstat_wait_event.c
+#   pgstat_wait_event.c
 #      C functions to get the wait event name based on the enum.
 #
-#   src/backend/utils/activity/wait_event_types.sgml
+#   wait_event_types.sgml
 #      SGML tables of wait events for inclusion in the documentation.
 #
 # When adding a new wait event, make sure it is placed in the appropriate
-- 
2.51.0

Attachment: signature.asc
Description: PGP signature

Reply via email to