public inbox for [email protected]
help / color / mirror / Atom feedFrom: Niyaz Hazigaleyev <[email protected]>
To: Tristan Partin <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Elliot Haisley <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [PATCH] meson: Update meson to enable building postgres as a subproject
Date: Tue, 6 Jan 2026 02:50:30 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <PH0PR84MB1954C7D61C4882403B8258708605A@PH0PR84MB1954.NAMPRD84.PROD.OUTLOOK.COM>
<acokwgv7kjwievq3l5or7rb44sqwdo4xan53nuff4ogwyqasll@s4nk6dyyrpas>
<[email protected]>
I also made a similar patch here https://www.postgresql.org/message-id/F28283CF-AC9C-4930-9D84-56CD9E105504%40gmail.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.
> 3 янв. 2026 г., в 07:35, Tristan Partin <[email protected]> написал(а):
>
> 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)
> <v1-0001-Add-subproject-support-to-the-meson-build.patch>
Attachments:
[application/octet-stream] libpq.patch (6.4K, ../[email protected]/2-libpq.patch)
download | inline diff:
diff --git a/meson.build b/meson.build
index d7c5193..9898ba9 100644
--- a/meson.build
+++ b/meson.build
@@ -375,8 +375,6 @@ if flex.found()
endif
flex_wrapper = files('src/tools/pgflex')
flex_cmd = [python, flex_wrapper,
- '--builddir', '@BUILD_ROOT@',
- '--srcdir', '@SOURCE_ROOT@',
'--privatedir', '@PRIVATE_DIR@',
'--flex', flex, '--perl', perl,
'-i', '@INPUT@', '-o', '@OUTPUT0@',
@@ -3157,7 +3155,7 @@ catalog_pm = files('src/backend/catalog/Catalog.pm')
perfect_hash_pm = files('src/tools/PerfectHash.pm')
gen_kwlist_deps = [perfect_hash_pm]
gen_kwlist_cmd = [
- perl, '-I', '@SOURCE_ROOT@/src/tools',
+ perl, '-I', '@0@/src/tools'.format(meson.project_source_root()),
files('src/tools/gen_keywordlist.pl'),
'--output', '@OUTDIR@', '@INPUT@']
@@ -3872,7 +3870,7 @@ pg_git_revision = get_option('PG_GIT_REVISION')
tar_gz = custom_target('tar.gz',
build_always_stale: true,
- command: [git, '-C', '@SOURCE_ROOT@',
+ command: [git, '-C', meson.project_source_root(),
'-c', 'core.autocrlf=false',
'archive',
'--format', 'tar.gz',
@@ -3886,7 +3884,7 @@ tar_gz = custom_target('tar.gz',
if bzip2.found()
tar_bz2 = custom_target('tar.bz2',
build_always_stale: true,
- command: [git, '-C', '@SOURCE_ROOT@',
+ command: [git, '-C', meson.project_source_root(),
'-c', 'core.autocrlf=false',
'-c', 'tar.tar.bz2.command="@0@" -c'.format(bzip2.full_path()),
'archive',
diff --git a/src/backend/jit/llvm/meson.build b/src/backend/jit/llvm/meson.build
index 805fbd6..3d22083 100644
--- a/src/backend/jit/llvm/meson.build
+++ b/src/backend/jit/llvm/meson.build
@@ -65,9 +65,9 @@ bitcode_cflags += get_option('c_args')
bitcode_cflags += cppflags
# XXX: Worth improving on the logic to find directories here
-bitcode_cflags += '-I@BUILD_ROOT@/src/include'
-bitcode_cflags += '-I@BUILD_ROOT@/src/backend/utils/misc'
-bitcode_cflags += '-I@SOURCE_ROOT@/src/include'
+bitcode_cflags += '-I@0@src/include'.format(meson.project_build_root())
+bitcode_cflags += '-I@0@src/backend/utils/misc'.format(meson.project_build_root())
+bitcode_cflags += '-I@0@src/include'.format(meson.project_source_root())
# Note this is intentionally not installed to bitcodedir, as it's not for
diff --git a/src/bin/psql/meson.build b/src/bin/psql/meson.build
index d344053..90dbd62 100644
--- a/src/bin/psql/meson.build
+++ b/src/bin/psql/meson.build
@@ -39,7 +39,7 @@ sql_help = custom_target('psql_help',
depfile: 'sql_help.dep',
command: [
perl, files('create_help.pl'),
- '--docdir', '@SOURCE_ROOT@/doc/src/sgml/ref',
+ '--docdir', join_paths(meson.project_source_root(), 'doc/src/sgml/ref'),
'--depfile', '@DEPFILE@',
'--outdir', '@OUTDIR@',
'--basename', 'sql_help',
diff --git a/src/common/unicode/meson.build b/src/common/unicode/meson.build
index c6a4715..491d2ec 100644
--- a/src/common/unicode/meson.build
+++ b/src/common/unicode/meson.build
@@ -174,7 +174,7 @@ update_unicode = custom_target('update-unicode',
depends: update_unicode_dep,
output: ['dont-exist'],
input: update_unicode_targets,
- command: [cp, '@INPUT@', '@SOURCE_ROOT@/src/include/common/'],
+ command: [cp, '@INPUT@', join_paths(meson.project_source_root(), 'src/include/common/')],
build_by_default: false,
build_always_stale: true,
)
diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build
index ec1cf46..17314b1 100644
--- a/src/include/catalog/meson.build
+++ b/src/include/catalog/meson.build
@@ -136,7 +136,7 @@ generated_catalog_headers = custom_target('generated_catalog_headers',
command: [
perl,
files('../../backend/catalog/genbki.pl'),
- '--include-path=@SOURCE_ROOT@/src/include',
+ '--include-path=@0@/src/include'.format(meson.project_source_root()),
'--set-version=' + pg_version_major.to_string(),
'--output=@OUTDIR@', '@INPUT@'
],
diff --git a/src/include/utils/meson.build b/src/include/utils/meson.build
index 0a2ea8f..27775ae 100644
--- a/src/include/utils/meson.build
+++ b/src/include/utils/meson.build
@@ -69,7 +69,10 @@ fmgrtab_target = custom_target('fmgrtab',
input: '../catalog/pg_proc.dat',
output : fmgrtab_output,
depend_files: catalog_pm,
- command: [perl, '-I', '@SOURCE_ROOT@/src/backend/catalog/', files('../../backend/utils/Gen_fmgrtab.pl'), '--include-path=@SOURCE_ROOT@/src/include', '--output=@OUTDIR@', '@INPUT@'],
+ command: [perl, '-I', '@0@/src/backend/catalog/'.format(meson.project_source_root()),
+ files('../../backend/utils/Gen_fmgrtab.pl'),
+ '--include-path=@0@/src/include'.format(meson.project_source_root()),
+ '--output=@OUTDIR@', '@INPUT@'],
install: true,
install_dir: [dir_include_server / 'utils', dir_include_server / 'utils', false],
)
diff --git a/src/interfaces/ecpg/test/meson.build b/src/interfaces/ecpg/test/meson.build
index 4ccdf9d..c26a91d 100644
--- a/src/interfaces/ecpg/test/meson.build
+++ b/src/interfaces/ecpg/test/meson.build
@@ -47,7 +47,7 @@ ecpg_preproc_test_command_start = [
ecpg_exe,
'--regression',
'-I@CURRENT_SOURCE_DIR@',
- '-I@SOURCE_ROOT@' + '/src/interfaces/ecpg/include/',
+ '-I@0@/src/interfaces/ecpg/include/'.format(meson.project_build_root()),
]
ecpg_preproc_test_command_end = [
'-o', '@OUTPUT@', '@INPUT@'
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index b259c99..33446f3 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -82,9 +82,11 @@ libpq_so = shared_library('libpq',
libpq = declare_dependency(
link_with: [libpq_so],
- include_directories: [include_directories('.')]
+ include_directories: [include_directories('.'), postgres_inc]
)
+meson.override_dependency('libpq', libpq)
+
# Check for functions that libpq must not call. See libpq_check.pl for the
# full set of platform rules. Skip the test when profiling, as gcc may
# insert exit() calls for that.
diff --git a/src/tools/pgflex b/src/tools/pgflex
index b8d9aa0..a1b471e 100755
--- a/src/tools/pgflex
+++ b/src/tools/pgflex
@@ -17,8 +17,6 @@ parser = argparse.ArgumentParser()
parser.add_argument('--flex', type=abspath, required=True)
parser.add_argument('--perl', type=abspath, required=True)
-parser.add_argument('--builddir', type=abspath, required=True)
-parser.add_argument('--srcdir', type=abspath, required=True)
parser.add_argument('--privatedir', type=abspath, required=True,
help='private directory for target')
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [PATCH] meson: Update meson to enable building postgres as a subproject
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox