mirror of
https://github.com/postgres/postgres.git
synced 2025-12-15 02:22:24 +03:00
This commit refactors the sanity check done by libpq to ensure that
there is no exit() reference in the build, moving the check from a
standalone Makefile rule to a perl script.
Platform-specific checks are now part of the script, avoiding most of
the duplication created by the introduction of this check for meson, but
not all of them:
- Solaris and Windows skipped in the script.
- Whitelist of symbols is in the script.
- nm availability, with its path given as an option of the script. Its
execution is checked in the script.
- Check is disabled if coverage reports are enabled. This part is not
pushed down to the script.
- Check is disabled for static builds of libpq. This part is filtered
out in each build script.
A trick is required for the stamp file, in the shape of an optional
argument that can be given to the script. Meson expects the stamp in
output and uses this argument, generating the stamp file in the script.
Meson is able to handle the removal of the stamp file internally when
libpq needs to be rebuilt and the check done again.
This refactoring piece has come up while discussing the addition of more
items in the symbols considered as acceptable.
This sanity check has never been run by meson since its introduction in
dc227eb82e, so it is possible that this fails in some of the buildfarm
members. At least the CI is happy with it, but let's see how it goes.
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Co-authored-by: VASUKI M <vasukim1992002@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19095-6d8256d0c37d4be2@postgresql.org
168 lines
4.2 KiB
Meson
168 lines
4.2 KiB
Meson
# Copyright (c) 2022-2025, PostgreSQL Global Development Group
|
|
|
|
libpq_sources = files(
|
|
'fe-auth-oauth.c',
|
|
'fe-auth-scram.c',
|
|
'fe-auth.c',
|
|
'fe-cancel.c',
|
|
'fe-connect.c',
|
|
'fe-exec.c',
|
|
'fe-lobj.c',
|
|
'fe-misc.c',
|
|
'fe-print.c',
|
|
'fe-protocol3.c',
|
|
'fe-secure.c',
|
|
'fe-trace.c',
|
|
'legacy-pqsignal.c',
|
|
'libpq-events.c',
|
|
'pqexpbuffer.c',
|
|
)
|
|
libpq_so_sources = [] # for shared lib, in addition to the above
|
|
|
|
if host_system == 'windows'
|
|
libpq_sources += files('pthread-win32.c', 'win32.c')
|
|
libpq_so_sources += rc_lib_gen.process(win32ver_rc, extra_args: [
|
|
'--NAME', 'libpq',
|
|
'--FILEDESC', 'PostgreSQL Access Library',])
|
|
endif
|
|
|
|
if ssl.found()
|
|
libpq_sources += files('fe-secure-common.c')
|
|
libpq_sources += files('fe-secure-openssl.c')
|
|
endif
|
|
|
|
if gssapi.found()
|
|
libpq_sources += files(
|
|
'fe-gssapi-common.c',
|
|
'fe-secure-gssapi.c',
|
|
)
|
|
endif
|
|
|
|
export_file = custom_target('libpq.exports',
|
|
kwargs: gen_export_kwargs,
|
|
)
|
|
|
|
# port needs to be in include path due to pthread-win32.h
|
|
libpq_inc = include_directories('.', '../../port')
|
|
libpq_c_args = ['-DSO_MAJOR_VERSION=5']
|
|
|
|
# The OAuth implementation differs depending on the type of library being built.
|
|
libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH']
|
|
|
|
# Not using both_libraries() here as
|
|
# 1) resource files should only be in the shared library
|
|
# 2) we want the .pc file to include a dependency to {pgport,common}_static for
|
|
# libpq_st, and {pgport,common}_shlib for libpq_sh
|
|
#
|
|
# We could try to avoid building the source files twice, but it probably adds
|
|
# more complexity than its worth (reusing object files requires also linking
|
|
# to the library on windows or breaks precompiled headers).
|
|
libpq_st = static_library('libpq',
|
|
libpq_sources,
|
|
include_directories: [libpq_inc],
|
|
c_args: libpq_c_args,
|
|
c_pch: pch_postgres_fe_h,
|
|
dependencies: [frontend_stlib_code, libpq_deps],
|
|
kwargs: default_lib_args,
|
|
)
|
|
|
|
libpq_so = shared_library('libpq',
|
|
libpq_sources + libpq_so_sources,
|
|
include_directories: [libpq_inc, postgres_inc],
|
|
c_args: libpq_c_args + libpq_so_c_args,
|
|
c_pch: pch_postgres_fe_h,
|
|
version: '5.' + pg_version_major.to_string(),
|
|
soversion: host_system != 'windows' ? '5' : '',
|
|
darwin_versions: ['5', '5.' + pg_version_major.to_string()],
|
|
dependencies: [frontend_shlib_code, libpq_deps],
|
|
link_depends: export_file,
|
|
link_args: export_fmt.format(export_file.full_path()),
|
|
kwargs: default_lib_args,
|
|
)
|
|
|
|
libpq = declare_dependency(
|
|
link_with: [libpq_so],
|
|
include_directories: [include_directories('.')]
|
|
)
|
|
|
|
# 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.
|
|
if nm.found() and not get_option('b_coverage')
|
|
custom_target(
|
|
'libpq_check',
|
|
input: libpq_so,
|
|
output: 'libpq-refs-stamp',
|
|
command: [
|
|
perl, files('libpq_check.pl'),
|
|
'--input_file', '@INPUT@',
|
|
'--stamp_file', '@OUTPUT@',
|
|
'--nm', nm.full_path(),
|
|
],
|
|
build_by_default: true,
|
|
)
|
|
endif
|
|
|
|
private_deps = [
|
|
frontend_stlib_code,
|
|
libpq_deps,
|
|
]
|
|
|
|
if oauth_flow_supported
|
|
# libpq.so doesn't link against libcurl, but libpq.a needs libpq-oauth, and
|
|
# libpq-oauth needs libcurl. Put both into *.private.
|
|
private_deps += [
|
|
libpq_oauth_deps,
|
|
'-lpq-oauth',
|
|
]
|
|
endif
|
|
|
|
pkgconfig.generate(
|
|
name: 'libpq',
|
|
description: 'PostgreSQL libpq library',
|
|
url: pg_url,
|
|
libraries: libpq,
|
|
libraries_private: private_deps,
|
|
)
|
|
|
|
install_headers(
|
|
'libpq-fe.h',
|
|
'libpq-events.h',
|
|
)
|
|
|
|
install_headers(
|
|
'libpq-int.h',
|
|
'pqexpbuffer.h',
|
|
'fe-auth-sasl.h',
|
|
install_dir: dir_include_internal,
|
|
)
|
|
install_data('pg_service.conf.sample',
|
|
install_dir: dir_data,
|
|
)
|
|
|
|
subdir('test')
|
|
|
|
tests += {
|
|
'name': 'libpq',
|
|
'sd': meson.current_source_dir(),
|
|
'bd': meson.current_build_dir(),
|
|
'tap': {
|
|
'tests': [
|
|
't/001_uri.pl',
|
|
't/002_api.pl',
|
|
't/003_load_balance_host_list.pl',
|
|
't/004_load_balance_dns.pl',
|
|
't/005_negotiate_encryption.pl',
|
|
't/006_service.pl',
|
|
],
|
|
'env': {
|
|
'with_ssl': ssl_library,
|
|
'with_gssapi': gssapi.found() ? 'yes' : 'no',
|
|
'with_krb_srvnam': 'postgres',
|
|
},
|
|
'deps': libpq_test_deps,
|
|
},
|
|
}
|
|
|
|
subdir('po', if_found: libintl)
|