Skip to content

Commit e4cb123

Browse files
committed
Add bitcode generation support on meson for contrib modules
Added a new variable in root meson.build for tracking the list of source files in contrib for further bitcode generation: `llvm_contrib_sources`. This list is used for non generated sources, which share common compilation flags for contrib modules. For contrib modules that require specific compilation flags, a separate variable was added on root meson.build: `bc_gen_custom_contrib`. It must be noted that there is no standard way of reusing meson dependency (`dep`) objects for custom target / generator as a mean of getting proper compilation flags, those must be included manually. As an example, for generating bitcode for contrib/hstore_plpython, we can't reuse the `python3_dep` object in the generator, so one way to get proper include directory was querying the `python3_inst` object like this: pyinc = python3_inst.get_variable('INCLUDEPY'), which extracts the variable name using python sysinfo.
1 parent 3eb9ffe commit e4cb123

File tree

64 files changed

+455
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+455
-68
lines changed

contrib/amcheck/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ amcheck = shared_module('amcheck',
1515
amcheck_sources,
1616
kwargs: contrib_mod_args,
1717
)
18-
contrib_targets += amcheck
18+
19+
if llvm.found()
20+
contrib_targets += amcheck
21+
llvm_contrib_sources += amcheck_sources
22+
endif
1923

2024
install_data(
2125
'amcheck.control',

contrib/auth_delay/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ auth_delay = shared_module('auth_delay',
1414
auth_delay_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += auth_delay
17+
18+
if llvm.found()
19+
contrib_targets += auth_delay
20+
llvm_contrib_sources += auth_delay_sources
21+
endif

contrib/auto_explain/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ auto_explain = shared_module('auto_explain',
1414
auto_explain_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += auto_explain
17+
18+
if llvm.found()
19+
contrib_targets += auto_explain
20+
llvm_contrib_sources += auto_explain_sources
21+
endif
1822

1923
tests += {
2024
'name': 'auto_explain',

contrib/basebackup_to_shell/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ basebackup_to_shell = shared_module('basebackup_to_shell',
1414
basebackup_to_shell_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += basebackup_to_shell
17+
18+
if llvm.found()
19+
contrib_targets += basebackup_to_shell
20+
llvm_contrib_sources += basebackup_to_shell_sources
21+
endif
1822

1923
tests += {
2024
'name': 'basebackup_to_shell',

contrib/basic_archive/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ basic_archive = shared_module('basic_archive',
1414
basic_archive_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += basic_archive
17+
18+
if llvm.found()
19+
contrib_targets += basic_archive
20+
llvm_contrib_sources += basic_archive_sources
21+
endif
1822

1923
tests += {
2024
'name': 'basic_archive',

contrib/bloom/meson.build

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ bloom = shared_module('bloom',
2020
c_pch: pch_postgres_h,
2121
kwargs: contrib_mod_args,
2222
)
23-
contrib_targets += bloom
23+
24+
if llvm.found()
25+
contrib_targets += bloom
26+
llvm_contrib_sources += bloom_sources
27+
endif
28+
2429

2530
install_data(
2631
'bloom.control',

contrib/bool_plperl/meson.build

+19-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if host_system == 'windows'
1414
'--FILEDESC', 'bool_plperl - bool transform for plperl',])
1515
endif
1616

17-
bool_plperl = shared_module('bool_plperl',
17+
bool_plperl= shared_module('bool_plperl',
1818
bool_plperl_sources,
1919
include_directories: [plperl_inc, include_directories('.')],
2020
kwargs: contrib_mod_args + {
@@ -23,7 +23,24 @@ bool_plperl = shared_module('bool_plperl',
2323
'build_rpath': '@0@/CORE'.format(archlibexp),
2424
},
2525
)
26-
contrib_targets += bool_plperl
26+
27+
if llvm.found()
28+
llvm_contrib_bool_plperl_cflags = [
29+
'-I@BUILD_ROOT@/contrib/bool_plperl',
30+
'-I@SOURCE_ROOT@/contrib/bool_plperl',
31+
'-I@BUILD_ROOT@/src/pl/plperl',
32+
'-I@SOURCE_ROOT@/src/pl/plperl',
33+
]
34+
35+
llvm_gen_contrib_bool_plperl = generator(llvm_irgen_command,
36+
arguments: llvm_irgen_args + bitcode_cflags + pg_mod_c_args + llvm_contrib_bool_plperl_cflags + perl_ccflags,
37+
depends: bool_plperl,
38+
depfile: '@[email protected]',
39+
output: '@[email protected]',
40+
)
41+
42+
bc_gen_custom_contrib += llvm_gen_contrib_bool_plperl.process(bool_plperl_sources)
43+
endif
2744

2845
install_data(
2946
'bool_plperl.control',

contrib/btree_gin/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ btree_gin = shared_module('btree_gin',
1414
btree_gin_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += btree_gin
17+
18+
if llvm.found()
19+
contrib_targets += btree_gin
20+
llvm_contrib_sources += btree_gin_sources
21+
endif
1822

1923
install_data(
2024
'btree_gin.control',

contrib/btree_gist/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ btree_gist = shared_module('btree_gist',
3838
c_pch: pch_postgres_h,
3939
kwargs: contrib_mod_args,
4040
)
41-
contrib_targets += btree_gist
41+
42+
if llvm.found()
43+
contrib_targets += btree_gist
44+
llvm_contrib_sources += btree_gist_sources
45+
endif
4246

4347
install_data(
4448
'btree_gist.control',

contrib/citext/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ citext = shared_module('citext',
1414
citext_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += citext
17+
18+
if llvm.found()
19+
contrib_targets += citext
20+
llvm_contrib_sources += citext_sources
21+
endif
1822

1923
install_data(
2024
'citext.control',

contrib/cube/meson.build

+18-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ cube_scan = custom_target('cubescan',
1111
)
1212
generated_sources += cube_scan
1313
cube_sources += cube_scan
14+
bc_cube_sources = cube_sources
1415

1516
cube_parse = custom_target('cubeparse',
1617
input: 'cubeparse.y',
1718
kwargs: bison_kw,
1819
)
1920
generated_sources += cube_parse.to_list()
2021
cube_sources += cube_parse
22+
bc_cube_sources += cube_parse[0]
2123

2224
if host_system == 'windows'
2325
cube_sources += rc_lib_gen.process(win32ver_rc, extra_args: [
@@ -30,7 +32,22 @@ cube = shared_module('cube',
3032
include_directories: include_directories('.'),
3133
kwargs: contrib_mod_args,
3234
)
33-
contrib_targets += cube
35+
36+
if llvm.found()
37+
llvm_contrib_cube_cflags = [
38+
'-I@BUILD_ROOT@/contrib/cube',
39+
'-I@SOURCE_ROOT@/contrib/cube',
40+
]
41+
42+
llvm_gen_contrib_cube = generator(llvm_irgen_command,
43+
arguments: llvm_irgen_args + bitcode_cflags + pg_mod_c_args + llvm_contrib_cube_cflags,
44+
depends: cube,
45+
depfile: '@[email protected]',
46+
output: '@[email protected]',
47+
)
48+
49+
bc_gen_custom_contrib += llvm_gen_contrib_cube.process(bc_cube_sources)
50+
endif
3451

3552
install_data(
3653
'cube.control',

contrib/dblink/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ dblink = shared_module('dblink',
1818
)
1919
contrib_targets += dblink
2020

21+
# if llvm.found()
22+
# llvm_contrib_sources += dblink_sources
23+
# endif
24+
2125
install_data(
2226
'dblink.control',
2327
'dblink--1.0--1.1.sql',

contrib/dict_int/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ dict_int = shared_module('dict_int',
1414
dict_int_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += dict_int
17+
18+
if llvm.found()
19+
contrib_targets += dict_int
20+
llvm_contrib_sources += dict_int_sources
21+
endif
1822

1923
install_data(
2024
'dict_int.control',

contrib/dict_xsyn/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ dict_xsyn = shared_module('dict_xsyn',
1414
dict_xsyn_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += dict_xsyn
17+
18+
if llvm.found()
19+
contrib_targets += dict_xsyn
20+
llvm_contrib_sources += dict_xsyn_sources
21+
endif
1822

1923
install_data(
2024
'dict_xsyn.control',

contrib/earthdistance/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ earthdistance = shared_module('earthdistance',
1414
earthdistance_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += earthdistance
17+
18+
if llvm.found()
19+
contrib_targets += earthdistance
20+
llvm_contrib_sources += earthdistance_sources
21+
endif
1822

1923
install_data(
2024
'earthdistance.control',

contrib/file_fdw/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ file_fdw = shared_module('file_fdw',
1414
file_fdw_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += file_fdw
17+
18+
if llvm.found()
19+
contrib_targets += file_fdw
20+
llvm_contrib_sources += file_fdw_sources
21+
endif
1822

1923
install_data(
2024
'file_fdw.control',

contrib/fuzzystrmatch/meson.build

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ fuzzystrmatch_sources = files(
66
'fuzzystrmatch.c',
77
)
88

9+
bc_fuzzystrmatch_sources = fuzzystrmatch_sources
10+
911
daitch_mokotoff_h = custom_target('daitch_mokotoff',
1012
input: 'daitch_mokotoff_header.pl',
1113
output: 'daitch_mokotoff.h',
@@ -27,6 +29,21 @@ fuzzystrmatch = shared_module('fuzzystrmatch',
2729
)
2830
contrib_targets += fuzzystrmatch
2931

32+
if llvm.found()
33+
llvm_contrib_fuzzystrmatch_cflags = [
34+
'-I@BUILD_ROOT@/contrib/fuzzystrmatch',
35+
'-I@SOURCE_ROOT@/contrib/fuzzystrmatch',
36+
]
37+
38+
llvm_gen_contrib_fuzzystrmatch = generator(llvm_irgen_command,
39+
arguments: llvm_irgen_args + bitcode_cflags + pg_mod_c_args + llvm_contrib_fuzzystrmatch_cflags,
40+
depends: daitch_mokotoff_h,
41+
depfile: '@[email protected]',
42+
output: '@[email protected]',
43+
)
44+
45+
bc_gen_custom_contrib += llvm_gen_contrib_fuzzystrmatch.process(bc_fuzzystrmatch_sources)
46+
endif
3047
install_data(
3148
'fuzzystrmatch.control',
3249
'fuzzystrmatch--1.0--1.1.sql',

contrib/hstore/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ hstore = shared_module('hstore',
2323
c_pch: pch_postgres_h,
2424
kwargs: contrib_mod_args,
2525
)
26-
contrib_targets += hstore
26+
27+
if llvm.found()
28+
contrib_targets += hstore
29+
llvm_contrib_sources += hstore_sources
30+
endif
2731

2832
install_data(
2933
'hstore.control',

contrib/hstore_plperl/meson.build

+18-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,24 @@ hstore_plperl = shared_module('hstore_plperl',
2323
'build_rpath': '@0@/CORE'.format(archlibexp),
2424
},
2525
)
26-
contrib_targets += hstore_plperl
26+
27+
if llvm.found()
28+
llvm_contrib_hstore_plperl_cflags = [
29+
'-I@BUILD_ROOT@/src/pl/plperl',
30+
'-I@SOURCE_ROOT@/src/pl/plperl',
31+
'-I@SOURCE_ROOT@/contrib',
32+
'-I@SOURCE_ROOT@/contrib/hstore',
33+
]
34+
35+
llvm_gen_contrib_hstore_plperl = generator(llvm_irgen_command,
36+
arguments: llvm_irgen_args + bitcode_cflags + pg_mod_c_args + llvm_contrib_hstore_plperl_cflags + perl_ccflags,
37+
depends: hstore_plperl,
38+
depfile: '@[email protected]',
39+
output: '@[email protected]',
40+
)
41+
42+
bc_gen_custom_contrib += llvm_gen_contrib_hstore_plperl.process(hstore_plperl_sources)
43+
endif
2744

2845
install_data(
2946
'hstore_plperl.control',

contrib/hstore_plpython/meson.build

+21-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,27 @@ hstore_plpython = shared_module('hstore_plpython3',
2222
'dependencies': [python3_dep, contrib_mod_args['dependencies']],
2323
},
2424
)
25-
contrib_targets += hstore_plpython
25+
26+
if llvm.found()
27+
pyinc = python3_inst.get_variable('INCLUDEPY')
28+
llvm_contrib_hstore_plpython_cflags = [
29+
'-I@SOURCE_ROOT@/src/pl/plpython',
30+
'-I@SOURCE_ROOT@/contrib',
31+
'-I@SOURCE_ROOT@/contrib/hstore',
32+
'-DPLPYTHON_LIBNAME="plpython3"',
33+
'-I@0@'.format(pyinc),
34+
]
35+
36+
llvm_gen_contrib_hstore_plpython = generator(llvm_irgen_command,
37+
arguments: llvm_irgen_args + bitcode_cflags + pg_mod_c_args + llvm_contrib_hstore_plpython_cflags,
38+
depends: hstore_plpython,
39+
depfile: '@[email protected]',
40+
output: '@[email protected]',
41+
)
42+
43+
bc_gen_custom_contrib += llvm_gen_contrib_hstore_plpython.process(hstore_plpython_sources)
44+
endif
45+
2646

2747
install_data(
2848
'hstore_plpython3u--1.0.sql',

contrib/intarray/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ intarray = shared_module('_int',
2020
intarray_sources,
2121
kwargs: contrib_mod_args,
2222
)
23-
contrib_targets += intarray
23+
24+
if llvm.found()
25+
contrib_targets += intarray
26+
llvm_contrib_sources += intarray_sources
27+
endif
2428

2529
install_data(
2630
'intarray.control',

contrib/isn/meson.build

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ isn = shared_module('isn',
1414
isn_sources,
1515
kwargs: contrib_mod_args,
1616
)
17-
contrib_targets += isn
17+
18+
if llvm.found()
19+
contrib_targets += isn
20+
llvm_contrib_sources += isn_sources
21+
endif
1822

1923
install_data(
2024
'isn.control',

0 commit comments

Comments
 (0)