Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 089c0bc

Browse files
committed
meson: libpq: Revise static / shared library setup
Improvements: - we don't need -DFRONTEND for libpq anymore since 1d77afe - the .pc file contents for a static libpq were wrong (referencing {pgport, common}_shlib) - incidentally fixes meson not supporting link_whole on AIX yet - added explanatory comments Previously I tried to avoid building libpq's sources twice, once for the static and once for the shared library. We could still do so, but it's not clear that it's worth the complication. Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
1 parent 29668e3 commit 089c0bc

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

meson.build

+18-5
Original file line numberDiff line numberDiff line change
@@ -2619,17 +2619,29 @@ backend_common_code = declare_dependency(
26192619

26202620
subdir('src/common')
26212621

2622-
frontend_shlib_code = declare_dependency(
2623-
compile_args: ['-DFRONTEND'],
2624-
include_directories: [postgres_inc],
2622+
# all shared libraries should depend on shlib_code
2623+
shlib_code = declare_dependency(
26252624
link_args: ldflags_sl,
2626-
link_with: [pgport_shlib, common_shlib],
2625+
)
2626+
2627+
# all static libraries not part of the backend should depend on this
2628+
frontend_stlib_code = declare_dependency(
2629+
include_directories: [postgres_inc],
2630+
link_with: [common_static, pgport_static],
26272631
sources: generated_headers,
26282632
dependencies: [os_deps, libintl],
26292633
)
26302634

2635+
# all shared libraries not part of the backend should depend on this
2636+
frontend_shlib_code = declare_dependency(
2637+
include_directories: [postgres_inc],
2638+
link_with: [common_shlib, pgport_shlib],
2639+
sources: generated_headers,
2640+
dependencies: [shlib_code, os_deps, libintl],
2641+
)
2642+
2643+
# Dependencies both for static and shared libpq
26312644
libpq_deps += [
2632-
frontend_shlib_code,
26332645
thread_dep,
26342646

26352647
gssapi,
@@ -2642,6 +2654,7 @@ subdir('src/interfaces/libpq')
26422654
# fe_utils depends on libpq
26432655
subdir('src/fe_utils')
26442656

2657+
# for frontend binaries
26452658
frontend_code = declare_dependency(
26462659
include_directories: [postgres_inc],
26472660
link_with: [fe_utils, common_static, pgport_static],

src/interfaces/libpq/meson.build

+18-10
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,33 @@ export_file = custom_target('libpq.exports',
3939

4040
# port needs to be in include path due to pthread-win32.h
4141
libpq_inc = include_directories('.', '../../port')
42+
libpq_c_args = ['-DSO_MAJOR_VERSION=5']
4243

44+
# Not using both_libraries() here as
45+
# 1) resource files should only be in the shared library
46+
# 2) we want the .pc file to include a dependency to {pgport,common}_static for
47+
# libpq_st, and {pgport,common}_shlib for libpq_sh
48+
#
49+
# We could try to avoid building the source files twice, but it probably adds
50+
# more complexity than its worth (AIX doesn't support link_whole yet, reusing
51+
# object files requires also linking to the library on windows or breaks
52+
# precompiled headers).
4353
libpq_st = static_library('libpq',
4454
libpq_sources,
45-
pic: true,
46-
include_directories: [libpq_inc, postgres_inc],
47-
c_args: ['-DSO_MAJOR_VERSION=5'],
48-
dependencies: libpq_deps,
55+
include_directories: [libpq_inc],
56+
c_args: libpq_c_args,
57+
dependencies: [frontend_stlib_code, libpq_deps],
4958
kwargs: default_lib_args,
5059
)
5160

52-
# not using both_libraries here, causes problems with precompiled headers and
53-
# resource files with msbuild
5461
libpq_so = shared_library('libpq',
55-
dependencies: libpq_deps,
62+
libpq_sources,
5663
include_directories: [libpq_inc, postgres_inc],
57-
c_args: ['-DSO_MAJOR_VERSION=5'],
58-
link_whole: libpq_st,
64+
c_args: libpq_c_args,
5965
version: '5.' + pg_version_major.to_string(),
6066
soversion: host_system != 'windows' ? '5' : '',
6167
darwin_versions: ['5', '5.' + pg_version_major.to_string()],
68+
dependencies: [frontend_shlib_code, libpq_deps],
6269
link_depends: export_file,
6370
link_args: export_fmt.format(export_file.full_path()),
6471
kwargs: default_lib_args,
@@ -70,10 +77,11 @@ libpq = declare_dependency(
7077
)
7178

7279
pkgconfig.generate(
73-
libpq_so,
7480
name: 'libpq',
7581
description: 'PostgreSQL libpq library',
7682
url: pg_url,
83+
libraries: libpq,
84+
libraries_private: [frontend_stlib_code, libpq_deps],
7785
)
7886

7987
install_headers(

0 commit comments

Comments
 (0)