Skip to content

Commit a94b041

Browse files
nbyavuzCommitfest Bot
authored andcommitted
meson: Add LLVM bitcode emission for backend sources
Since generated backend sources may have their own compilation flags and must also be included in the postgres.index.bc, the way to make it work with current code was to create a new variable, called `bc_generated_backend_sources`, which is a list of dictionaries, each one having an optional 'additional_flags' and a `srclist` pointing to the list of custom_target generated sources. An example of a possible structure of bitcode_modules which is processed by the main meson llvm bitcode emission file src/backend/jit/llvm/bitcode/meson.build: ``` bitcode_modules = [ { 'name': 'postgres', 'target': postgres_lib, 'src_file': backend_sources, 'gen_srcfiles': [ { 'additional_flags': [ '-I/path/postgresl/src/backend/parser', '-I/path/postgresl/build/src/backend/parser', ], 'srcfiles': [ <custom_target for scan.c>, <custom_target for gram.c> ] } ] } ] ``` Author: Diego Fronza <[email protected]> Author: Nazir Bilal Yavuz <[email protected]> Discussion: https://postgr.es/m/206b001d-1884-4081-bd02-bed5c92f02ba%40eisentraut.org
1 parent 6a4a8ea commit a94b041

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

src/backend/bootstrap/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ bootscanner = custom_target('bootscanner',
1313
)
1414
generated_sources += bootscanner
1515
boot_parser_sources += bootscanner
16+
bc_generated_backend_sources += {'srcfiles': [bootscanner]}
1617

1718
bootparse = custom_target('bootparse',
1819
input: 'bootparse.y',
1920
kwargs: bison_kw,
2021
)
2122
generated_sources += bootparse.to_list()
2223
boot_parser_sources += bootparse
24+
bc_generated_backend_sources += {'srcfiles': [bootparse[0]]}
2325

2426
boot_parser = static_library('boot_parser',
2527
boot_parser_sources,

src/backend/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ backend_sources = []
55
backend_link_with = [pgport_srv, common_srv]
66

77
generated_backend_sources = []
8+
bc_generated_backend_sources = []
89
post_export_backend_sources = []
910

1011
subdir('access')
@@ -144,6 +145,7 @@ bitcode_modules += {
144145
'name': 'postgres',
145146
'target': postgres_lib,
146147
'srcfiles': backend_sources,
148+
'gen_sources': bc_generated_backend_sources,
147149
}
148150

149151
pg_mod_c_args = cflags_mod

src/backend/parser/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ backend_parser = custom_target('gram',
4242
generated_sources += backend_parser.to_list()
4343
parser_sources += backend_parser
4444

45+
bc_generated_backend_sources += {
46+
'additional_flags': [
47+
'-I@0@'.format(meson.current_build_dir()),
48+
'-I@0@'.format(meson.current_source_dir()),
49+
],
50+
'srcfiles': [backend_scanner, backend_parser[0]],
51+
}
52+
4553
parser = static_library('parser',
4654
parser_sources,
4755
dependencies: [backend_code],

src/backend/replication/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ repl_scanner = custom_target('repl_scanner',
1919
)
2020
generated_sources += repl_scanner
2121
repl_parser_sources += repl_scanner
22+
bc_generated_backend_sources += {'srcfiles': [repl_scanner]}
2223

2324
repl_gram = custom_target('repl_gram',
2425
input: 'repl_gram.y',
2526
kwargs: bison_kw,
2627
)
2728
generated_sources += repl_gram.to_list()
2829
repl_parser_sources += repl_gram
30+
bc_generated_backend_sources += {'srcfiles': [repl_gram[0]]}
2931

3032
syncrep_scanner = custom_target('syncrep_scanner',
3133
input: 'syncrep_scanner.l',
@@ -34,13 +36,15 @@ syncrep_scanner = custom_target('syncrep_scanner',
3436
)
3537
generated_sources += syncrep_scanner
3638
repl_parser_sources += syncrep_scanner
39+
bc_generated_backend_sources += {'srcfiles': [syncrep_scanner]}
3740

3841
syncrep_gram = custom_target('syncrep_gram',
3942
input: 'syncrep_gram.y',
4043
kwargs: bison_kw,
4144
)
4245
generated_sources += syncrep_gram.to_list()
4346
repl_parser_sources += syncrep_gram
47+
bc_generated_backend_sources += {'srcfiles': [syncrep_gram[0]]}
4448

4549
repl_parser = static_library('repl_parser',
4650
repl_parser_sources,

src/backend/utils/fmgr/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ backend_sources += files(
88

99
# fmgrtab.c
1010
generated_backend_sources += fmgrtab_target[2]
11+
bc_generated_backend_sources += {'srcfiles': [fmgrtab_target[2]]}

0 commit comments

Comments
 (0)