mirror of
https://github.com/postgres/postgres.git
synced 2026-06-09 00:32:10 -04:00
meson: allow disabling building/installation of static libraries.
We now support the common meson option -Ddefault_library, with values 'both' (the default), 'shared' (install only shared libraries), and 'static' (install only static libraries). The 'static' choice doesn't actually work, since psql and other programs insist on linking to the shared version of libpq, but it's there pro-forma. It could be built out if we really wanted, but since we have never supported the equivalent in the autoconf build system, there doesn't appear to be an urgent need. With an eye to re-supporting AIX, the internal implementation distinguishes whether to install libpgport.a and other static-only libraries from whether to build/install the static variant of libraries that we can build both ways. This detail isn't exposed as a meson option, though it could be if there's demand. The Cirrus CI task SanityCheck now uses -Ddefault_library=shared to save a little bit of build time (and to test this option). Author: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/e8aa97db-872b-4087-b073-f296baae948d@eisentraut.org
This commit is contained in:
parent
f33b8793fd
commit
78727dcba3
11 changed files with 64 additions and 1 deletions
|
|
@ -133,6 +133,7 @@ task:
|
|||
meson setup \
|
||||
--buildtype=debug \
|
||||
--auto-features=disabled \
|
||||
-Ddefault_library=shared \
|
||||
-Dtap_tests=enabled \
|
||||
build
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -2807,6 +2807,17 @@ ninja install
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="configure-default-library-meson">
|
||||
<term><option>-Ddefault_library={ both | shared }</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
This option selects whether both shared and static libraries are built
|
||||
(the default), or only shared libraries. (The third variant of only
|
||||
building static libraries is currently not supported.)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="configure-extra-include-dirs-meson">
|
||||
<term><option>-Dextra_include_dirs=<replaceable>DIRECTORIES</replaceable></option></term>
|
||||
<listitem>
|
||||
|
|
|
|||
27
meson.build
27
meson.build
|
|
@ -20,6 +20,7 @@ project('postgresql',
|
|||
'warning_level=1', #-Wall equivalent
|
||||
'b_pch=false',
|
||||
'buildtype=debugoptimized', # -O2 + debug
|
||||
'default_library=both',
|
||||
# For compatibility with the autoconf build, set a default prefix. This
|
||||
# works even on windows, where it's a drive-relative path (i.e. when on
|
||||
# d:/somepath it'll install to d:/usr/local/pgsql)
|
||||
|
|
@ -50,6 +51,32 @@ not_found_dep = dependency('', required: false)
|
|||
thread_dep = dependency('threads')
|
||||
auto_features = get_option('auto_features')
|
||||
|
||||
# Declare variables to disable static or shared libraries. This
|
||||
# makes the 'default_library' option work even though we don't use the
|
||||
# library() function but instead shared_library() and static_library()
|
||||
# separately.
|
||||
#
|
||||
# build_shared_lib/build_static_lib control building/installing the two
|
||||
# versions of libraries that we can build both versions of (e.g., libpq).
|
||||
# There are also libraries that we only build a static version of (e.g.,
|
||||
# libpgport). These are always built, since we need them while building,
|
||||
# but they are installed only if install_internal_static_lib is true.
|
||||
#
|
||||
# Note: at present, -Ddefault_library=static doesn't actually work, because
|
||||
# psql and other programs insist on linking to the shared version of libpq.
|
||||
# This could be fixed if there was interest, but so far there is not.
|
||||
default_library_opt = get_option('default_library')
|
||||
build_shared_lib = true
|
||||
build_static_lib = true
|
||||
install_internal_static_lib = true
|
||||
if default_library_opt == 'shared'
|
||||
build_static_lib = false
|
||||
install_internal_static_lib = false
|
||||
elif default_library_opt == 'static'
|
||||
build_shared_lib = false
|
||||
error('-Ddefault_library=static is not yet supported')
|
||||
endif
|
||||
|
||||
|
||||
|
||||
###############################################################
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ foreach name, opts : pgcommon_variants
|
|||
opts.get('include_directories', []),
|
||||
],
|
||||
'dependencies': opts['dependencies'] + [ssl],
|
||||
'install': install_internal_static_lib and name != '_srv',
|
||||
}
|
||||
)
|
||||
pgcommon += {name: lib}
|
||||
|
|
|
|||
|
|
@ -35,5 +35,7 @@ fe_utils = static_library('libpgfeutils',
|
|||
include_directories: [postgres_inc, libpq_inc],
|
||||
c_args: host_system == 'windows' ? ['-DFD_SETSIZE=1024'] : [],
|
||||
dependencies: frontend_common_code,
|
||||
kwargs: default_lib_args,
|
||||
kwargs: default_lib_args + {
|
||||
'install': install_internal_static_lib,
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ if host_system == 'windows'
|
|||
endif
|
||||
|
||||
# see src/interfaces/libpq/meson.build
|
||||
if build_static_lib
|
||||
ecpg_compat_st = static_library('libecpg_compat',
|
||||
ecpg_compat_sources,
|
||||
include_directories: ecpg_compat_inc,
|
||||
|
|
@ -25,7 +26,9 @@ ecpg_compat_st = static_library('libecpg_compat',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
ecpg_targets += ecpg_compat_st
|
||||
endif
|
||||
|
||||
if build_shared_lib
|
||||
ecpg_compat_so = shared_library('libecpg_compat',
|
||||
ecpg_compat_sources + ecpg_compat_so_sources,
|
||||
include_directories: ecpg_compat_inc,
|
||||
|
|
@ -40,6 +43,7 @@ ecpg_compat_so = shared_library('libecpg_compat',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
ecpg_targets += ecpg_compat_so
|
||||
endif
|
||||
|
||||
pkgconfig.generate(
|
||||
name: 'libecpg_compat',
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ if host_system == 'windows'
|
|||
endif
|
||||
|
||||
# see src/interfaces/libpq/meson.build
|
||||
if build_static_lib
|
||||
ecpglib_st = static_library('libecpg',
|
||||
ecpglib_sources,
|
||||
include_directories: ecpglib_inc,
|
||||
|
|
@ -35,7 +36,9 @@ ecpglib_st = static_library('libecpg',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
ecpg_targets += ecpglib_st
|
||||
endif
|
||||
|
||||
if build_shared_lib
|
||||
ecpglib_so = shared_library('libecpg',
|
||||
ecpglib_sources + ecpglib_so_sources,
|
||||
include_directories: ecpglib_inc,
|
||||
|
|
@ -51,6 +54,7 @@ ecpglib_so = shared_library('libecpg',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
ecpg_targets += ecpglib_so
|
||||
endif
|
||||
|
||||
pkgconfig.generate(
|
||||
name: 'libecpg',
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ if host_system == 'windows'
|
|||
endif
|
||||
|
||||
# see src/interfaces/libpq/meson.build
|
||||
if build_static_lib
|
||||
ecpg_pgtypes_st = static_library('libpgtypes',
|
||||
ecpg_pgtypes_sources,
|
||||
include_directories: ecpg_pgtypes_inc,
|
||||
|
|
@ -30,7 +31,9 @@ ecpg_pgtypes_st = static_library('libpgtypes',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
ecpg_targets += ecpg_pgtypes_st
|
||||
endif
|
||||
|
||||
if build_shared_lib
|
||||
ecpg_pgtypes_so = shared_library('libpgtypes',
|
||||
ecpg_pgtypes_sources + ecpg_pgtypes_so_sources,
|
||||
include_directories: ecpg_pgtypes_inc,
|
||||
|
|
@ -45,6 +48,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
ecpg_targets += ecpg_pgtypes_so
|
||||
endif
|
||||
|
||||
pkgconfig.generate(
|
||||
name: 'libpgtypes',
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export_file = custom_target('libpq-oauth.exports',
|
|||
# port needs to be in include path due to pthread-win32.h
|
||||
libpq_oauth_inc = include_directories('.', '../libpq', '../../port')
|
||||
|
||||
if build_static_lib
|
||||
libpq_oauth_st = static_library('libpq-oauth',
|
||||
libpq_oauth_sources,
|
||||
include_directories: [libpq_oauth_inc, postgres_inc],
|
||||
|
|
@ -33,11 +34,13 @@ libpq_oauth_st = static_library('libpq-oauth',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
libpq_targets += libpq_oauth_st
|
||||
endif
|
||||
|
||||
# This is an internal module; we don't want an SONAME and therefore do not set
|
||||
# SO_MAJOR_VERSION.
|
||||
libpq_oauth_name = 'libpq-oauth-@0@'.format(pg_version_major)
|
||||
|
||||
if build_shared_lib
|
||||
libpq_oauth_so = shared_module(libpq_oauth_name,
|
||||
libpq_oauth_sources + libpq_oauth_so_sources,
|
||||
include_directories: [libpq_oauth_inc, postgres_inc],
|
||||
|
|
@ -49,6 +52,7 @@ libpq_oauth_so = shared_module(libpq_oauth_name,
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
libpq_targets += libpq_oauth_so
|
||||
endif
|
||||
|
||||
libpq_oauth_test_deps = []
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH']
|
|||
# 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).
|
||||
if build_static_lib
|
||||
libpq_st = static_library('libpq',
|
||||
libpq_sources,
|
||||
include_directories: [libpq_inc],
|
||||
|
|
@ -66,7 +67,9 @@ libpq_st = static_library('libpq',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
libpq_targets += libpq_st
|
||||
endif
|
||||
|
||||
if build_shared_lib
|
||||
libpq_so = shared_library('libpq',
|
||||
libpq_sources + libpq_so_sources,
|
||||
include_directories: [libpq_inc, postgres_inc],
|
||||
|
|
@ -81,6 +84,7 @@ libpq_so = shared_library('libpq',
|
|||
kwargs: default_lib_args,
|
||||
)
|
||||
libpq_targets += libpq_so
|
||||
endif
|
||||
|
||||
libpq = declare_dependency(
|
||||
link_with: [libpq_so],
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ foreach name, opts : pgport_variants
|
|||
c_pch: pch_c_h,
|
||||
kwargs: opts + {
|
||||
'dependencies': opts['dependencies'] + [ssl],
|
||||
'install': install_internal_static_lib and name != '_srv',
|
||||
}
|
||||
)
|
||||
pgport += {name: lib}
|
||||
|
|
|
|||
Loading…
Reference in a new issue