pgsql: Fix build inconsistency due to the generation of wait-event code - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix build inconsistency due to the generation of wait-event code
Date
Msg-id E1vmgUv-000clb-0D@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix build inconsistency due to the generation of wait-event code

The build generates four files based on the wait event contents stored
in wait_event_names.txt:
- wait_event_types.h
- pgstat_wait_event.c
- wait_event_funcs_data.c
- wait_event_types.sgml

The SGML file is generated as part of a documentation build, with its
data stored in doc/src/sgml/ for meson and configure.  The three others
are handled differently for meson and configure:
- In configure, all the files are created in src/backend/utils/activity/.
A link to wait_event_types.h is created in src/include/utils/.
- In meson, all the files are created in src/include/utils/.

The two C files, pgstat_wait_event.c and wait_event_funcs_data.c, are
then included in respectively wait_event.c and wait_event_funcs.c,
without the "utils/" path.

For configure, this does not present a problem.  For meson, this has to
be combined with a trick in src/backend/utils/activity/meson.build,
where include_directories needs to point to include/utils/ to make the
inclusion of the C files work properly, causing builds to pull in
PostgreSQL headers rather than system headers in some build paths, as
src/include/utils/ would take priority.

In order to fix this issue, this commit reworks the way the C/H files
are generated, becoming consistent with guc_tables.inc.c:
- For meson, basically nothing changes.  The files are still generated
in src/include/utils/.  The trick with include_directories is removed.
- For configure, the files are now generated in src/backend/utils/, with
links in src/include/utils/ pointing to the ones in src/backend/.  This
requires extra rules in src/backend/utils/activity/Makefile so as a
make command in this sub-directory is able to work.
- The three files now fall under header-stamp, which is actually simpler
as guc_tables.inc.c does the same.
- wait_event_funcs_data.c and pgstat_wait_event.c are now included with
"utils/" in their path.

This problem has not been an issue in the buildfarm; it has been noted
with AIX and a conflict with float.h.  This issue could, however, create
conflicts in the buildfarm depending on the environment with unexpected
headers pulled in, so this fix is backpatched down to where the
generation of the wait-event files has been introduced.

While on it, this commit simplifies wait_event_names.txt regarding the
paths of the files generated, to mention just the names of the files
generated.  The paths where the files are generated became incorrect.
The path of the SGML path was wrong.

This change has been tested in the CI, down to v17.  Locally, I have run
tests with configure (with and without VPATH), as well as meson, on the
three branches.

Combo oversight in fa88928470b5 and 1e68e43d3f0f.

Reported-by: Aditya Kamath <aditya.kamath1@ibm.com>
Discussion: https://postgr.es/m/LV8PR15MB64888765A43D229EA5D1CFE6D691A@LV8PR15MB6488.namprd15.prod.outlook.com
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/241803febff453c1b243b48c4a0dfc3ac07fd346

Modified Files
--------------
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 +++---
src/include/Makefile                            |  1 +
src/include/utils/.gitignore                    |  2 ++
src/include/utils/meson.build                   |  4 +---
12 files changed, 27 insertions(+), 37 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Make psql/t/030_pager.pl more robust.
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix error message in RemoveWalSummaryIfOlderThan()