diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index 6df31504f32..24a679a94c8 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -38,7 +38,7 @@ all: probes.h generated-header-symlinks
 
 .PHONY: generated-header-symlinks submake-adt-headers
 
-generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp submake-adt-headers
+generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/wait_event-stamp submake-adt-headers
 
 submake-adt-headers:
 	$(MAKE) -C adt jsonpath_gram.h
@@ -78,6 +78,12 @@ $(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h g
 	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
+# Symlink activity/wait_event_funcs_data.c into src/include/utils/.
+# We use wait-event-stamp to ensure the symlink exists and doesn't get regenerated unnecessarily.
+$(top_builddir)/src/include/utils/wait_event-stamp: $(top_srcdir)/src/backend/utils/activity/wait_event_funcs_data.c
+	cd '$(dir $@)' && rm -f wait_event_funcs_data.c && \
+	$(LN_S) "$(top_builddir)/$(subdir)/activity/wait_event_funcs_data.c" .
+		touch $@
 
 .PHONY: install-data
 install-data: errcodes.txt installdirs
