summaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm/meson.build
blob: a6524c06fe3ef1c7346e1ea94864b4d8dfd46a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright (c) 2022-2023, PostgreSQL Global Development Group

if not llvm.found()
  subdir_done()
endif

# Build LLVM JIT backend module

llvmjit_sources = []

# Infrastructure
llvmjit_sources += files(
  'llvmjit.c',
  'llvmjit_error.cpp',
  'llvmjit_inline.cpp',
  'llvmjit_wrap.cpp',
)

# Code generation
llvmjit_sources += files(
  'llvmjit_deform.c',
  'llvmjit_expr.c',
)

if host_system == 'windows'
  llvmjit_sources += rc_lib_gen.process(win32ver_rc, extra_args: [
    '--NAME', 'llvmjit',
    '--FILEDESC', 'llvmjit - JIT using LLVM',])
endif

llvmjit = shared_module('llvmjit',
  llvmjit_sources,
  kwargs: pg_mod_args + {
    'dependencies': pg_mod_args['dependencies'] + [llvm],
    'cpp_args': pg_mod_args['cpp_args'] + llvm.get_variable(configtool: 'cxxflags').split(),
  }
)

backend_targets += llvmjit


# Define a few bits and pieces used here and elsewhere to generate bitcode

llvm_irgen_args = [
  '-c', '-o', '@OUTPUT@', '@INPUT@',
  '-flto=thin', '-emit-llvm',
  '-MD', '-MQ', '@OUTPUT@', '-MF', '@DEPFILE@',
  '-O2',
  '-Wno-ignored-attributes',
  '-Wno-empty-body',
]

if ccache.found()
  llvm_irgen_command = ccache
  llvm_irgen_args = [clang.path()] + llvm_irgen_args
else
  llvm_irgen_command = clang
endif


# XXX: Need to determine proper version of the function cflags for clang
bitcode_cflags = ['-fno-strict-aliasing', '-fwrapv']
if llvm.version().version_compare('>=15.0')
  bitcode_cflags += ['-Xclang', '-no-opaque-pointers']
endif
bitcode_cflags += cppflags

# XXX: Worth improving on the logic to find directories here
bitcode_cflags += '-I@BUILD_ROOT@/src/include'
bitcode_cflags += '-I@BUILD_ROOT@/src/backend/utils/misc'
bitcode_cflags += '-I@SOURCE_ROOT@/src/include'


# Note this is intentionally not installed to bitcodedir, as it's not for
# inlining
llvmjit_types = custom_target('llvmjit_types.bc',
  command: [llvm_irgen_command] + llvm_irgen_args + bitcode_cflags,
  input: 'llvmjit_types.c',
  output: 'llvmjit_types.bc',
  depends: [postgres],
  install: true,
  install_dir: dir_lib_pkg,
  depfile: '@BASENAME@.c.bc.d',
)
backend_targets += llvmjit_types