8000 meson: Add support for building with precompiled headers · postgrespro/postgres@e555565 · GitHub
[go: up one dir, main page]

Skip to content 10000

Commit e555565

Browse files
committed
meson: Add support for building with precompiled headers
This substantially speeds up building for windows, due to the vast amount of headers included via windows.h. A cross build from linux targetting mingw goes from 994.11user 136.43system 0:31.58elapsed 3579%CPU to 422.41user 89.05system 0:14.35elapsed 3562%CPU The wins on windows are similar-ish (but I don't have a system at hand just now for actual numbers). Targetting other operating systems the wins are far smaller (tested linux, macOS, FreeBSD). For now precompiled headers are disabled by default, it's not clear how well they work on all platforms. E.g. on FreeBSD gcc doesn't seem to have working support, but clang does. When doing a full build precompiled headers are only beneficial for targets with multiple .c files, as meson builds a separate precompiled header for each target (so that different compilation options take effect). This commit therefore only changes target with at least two .c files to use precompiled headers. Because this commit adds b_pch=false to the default_options new build directories will have precompiled headers disabled by default, however existing build directories will continue use the default value of b_pch, which is true. Note that using precompiled headers with ccache requires setting CCACHE_SLOPPINESS=pch_defines,time_macros to get hits. Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com> Reviewed-by: Justin Pryzby <pryzby@telsasoft.com> Discussion: https://postgr.es/m/CA+hUKG+50eOUbN++ocDc0Qnp9Pvmou23DSXu=ZA6fepOcftKqA@mail.gmail.com Discussion: https://postgr.es/m/c5736f70-bb6d-8d25-e35c-e3d886e4e905@enterprisedb.com Discussion: https://postgr.es/m/20190826054000.GE7005%40paquier.xyz
1 parent e0b0142 commit e555565

File tree

32 files changed

+44
-1
lines changed

32 files changed

+44
-1
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ task:
447447
# Use /DEBUG:FASTLINK to avoid high memory usage during linking
448448
configure_script: |
449449
vcvarsall x64
450-
meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dssl=openssl -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe -DPG_TEST_EXTRA="%PG_TEST_EXTRA%" build
450+
meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Db_pch=true -Dssl=openssl -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe -DPG_TEST_EXTRA="%PG_TEST_EXTRA%" build
451451
452452
build_script: |
453453
vcvarsall x64

contrib/bloom/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ endif
1515

1616
bloom = shared_module('bloom',
1717
bloom_sources,
18+
c_pch: pch_postgres_h,
1819
kwargs: contrib_mod_args,
1920
)
2021
contrib_targets += bloom

contrib/btree_gist/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ endif
3333

3434
btree_gist = shared_module('btree_gist',
3535
btree_gist_sources,
36+
c_pch: pch_postgres_h,
3637
kwargs: contrib_mod_args,
3738
)
3839
contrib_targets += btree_gist

contrib/hstore/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ endif
1818

1919
hstore = shared_module('hstore',
2020
hstore_sources,
21+
c_pch: pch_postgres_h,
2122
kwargs: contrib_mod_args,
2223
)
2324
contrib_targets += hstore

contrib/pg_trgm/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ endif
1313

1414
pg_trgm = shared_module('pg_trgm',
1515
pg_trgm_sources,
16+
c_pch: pch_postgres_h,
1617
kwargs: contrib_mod_args,
1718
)
1819
contrib_targets += pg_trgm

contrib/pgcrypto/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ endif
7878
pgcrypto = shared_module('pgcrypto',
7979
pgcrypto_sources,
8080
link_with: pgcrypto_link_with,
81+
c_pch: pch_postgres_h,
8182
kwargs: contrib_mod_args + {
8283
'dependencies': [pgcrypto_deps, contrib_mod_args['dependencies']]
8384
},

contrib/pgstattuple/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ endif
1212

1313
pgstattuple = shared_module('pgstattuple',
1414
pgstattuple_sources,
15+
c_pch: pch_postgres_h,
1516
kwargs: contrib_mod_args,
1617
)
1718
contrib_targets += pgstattuple

contrib/sepgsql/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ endif
2222

2323
sepgsql = shared_module('sepgsql',
2424
sepgsql_sources,
25+
c_pch: pch_postgres_h,
2526
kwargs: contrib_mod_args + {
2627
'dependencies': [selinux, contrib_mod_args['dependencies']],
2728
}

contrib/xml2/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ endif
1515

1616
xml2 = shared_module('pgxml',
1717
xml2_sources,
18+
c_pch: pch_postgres_h,
1819
kwargs: contrib_mod_args + {
1920
'dependencies': [libxml, libxslt, contrib_mod_args['dependencies']],
2021
},

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ project('postgresql',
1515
meson_version: '>=0.54',
1616
default_options: [
1717
'warning_level=1', #-Wall equivalent
18+
'b_pch=false',
1819
'buildtype=release',
1920
# For compatibility with the autoconf build, set a default prefix. This
2021
# works even on windows, where it's a drive-relative path (i.e. when on

0 commit comments

Comments
 (0)
0