[PATCH] meson: Update meson to enable building postgres as a subproject
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t52198psql -h localhost -U postgresBuilt from patchset v4 (message #4), July 27, 2026 at 05:12 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t52198_4 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t52198_4 && git checkout t52198_4Patchset v4 (message #4) is on t52198_4
Hello all,
While working on another project which needed libpq, I tried building postgres
as a subproject to consume a recent version of libpq, and noticed it failed.
I've put together a small patch that updates build files to not use
the global source root, which allows postgres to be built as a meson subproject.
Regards,
Elliot Haisley
Attachments:
0001-meson-subproject.patchapplication/octet-stream; name=0001-meson-subproject.patchDownload+7-7
Hi,
On 2025-08-30 04:18:05 +0000, Elliot Haisley wrote:
While working on another project which needed libpq, I tried building postgres
as a subproject to consume a recent version of libpq, and noticed it failed.
I've put together a small patch that updates build files to not use
the global source root, which allows postgres to be built as a meson subproject.
That makes sense. I however can't apply it just now, the PG 18 code is frozen
until mid of the next week due to the release of 18rc1, and I think this
should be backpatched.
Greetings,
Andres Freund
On Sat Aug 30, 2025 at 9:55 AM CDT, Andres Freund wrote:
Hi,
On 2025-08-30 04:18:05 +0000, Elliot Haisley wrote:
While working on another project which needed libpq, I tried building postgres
as a subproject to consume a recent version of libpq, and noticed it failed.
I've put together a small patch that updates build files to not use
the global source root, which allows postgres to be built as a meson subproject.That makes sense. I however can't apply it just now, the PG 18 code is frozen
until mid of the next week due to the release of 18rc1, and I think this
should be backpatched.
I also was working on a project that wanted to use libpq as a subproject
and came up with this independent but similar patch. I chose to develop
it against master.
I think that if we aim to support this workflow that we should add
a test in the tree somewhere. I am happy to develop one if someone
can direct me to a place where they would like it to live. In theory,
the test could even live as a meson test() in the source tree.
--
Tristan Partin
Databricks (https://databricks.com)
Attachments:
v1-0001-Add-subproject-support-to-the-meson-build.patchtext/x-patch; charset=utf-8; name=v1-0001-Add-subproject-support-to-the-meson-build.patchDownload+16-16
I also made a similar patch here /messages/by-id/F28283CF-AC9C-4930-9D84-56CD9E105504@gmail.com. I pretty much did the same thing but I also added postgres_inc to dependency because it cannot find postgres headers inside libpq’s headers. After looking at your patch i have few questions. Is meson.override_dependency(‘libpq’, libpq) really needed? It looks like it does nothing. In flex cmd args you removed —build-dir and —source-dir, was that necessary?
Also when I was testing ur patch I couldn’t build libpq because of the problem with include directories of dependency that I mentioned. I attach the result patch with fix which only adds postgres_inc to libpq dependency include_directories to your patch.
On Mon Jan 5, 2026 at 5:50 PM CST, Niyaz Hazigaleyev wrote:
I also made a similar patch here
/messages/by-id/F28283CF-AC9C-4930-9D84-56CD9E105504@gmail.com.
I pretty much did the same thing but I also added postgres_inc to
dependency because it cannot find postgres headers inside libpq’s
headers. After looking at your patch i have few questions. Is
meson.override_dependency(‘libpq’, libpq) really needed? It looks like
it does nothing. In flex cmd args you removed —build-dir and
—source-dir, was that necessary? Also when I was testing ur patch
I couldn’t build libpq because of the problem with include directories
of dependency that I mentioned. I attach the result patch with fix
which only adds postgres_inc to libpq dependency include_directories
to your patch.
I didn't have any problems with include directories, but it's possible
that my system corrupted my tests, as in my system includes supplemented
the missing subproject includes.
I removed the args from pgflex because they aren't used.
--
Tristan Partin
Databricks (https://databricks.com)
Import Notes
Reply to msg id not found: CF04FCAD-54E5-42B1-B777-FF433E779E4E@gmail.com