1 # Copyright (c) 2022-2025, PostgreSQL Global Development Group
7 # Build LLVM JIT backend module
12 llvmjit_sources += files(
17 'SectionMemoryManager.cpp',
21 llvmjit_sources += files(
26 if host_system == 'windows'
27 llvmjit_sources += rc_lib_gen.process(win32ver_rc, extra_args: [
29 '--FILEDESC', 'llvmjit - JIT using LLVM',])
32 llvmjit = shared_module('llvmjit',
34 kwargs: pg_mod_args + {
35 'dependencies': pg_mod_args['dependencies'] + [llvm],
36 'cpp_args': pg_mod_args['cpp_args'] + llvm.get_variable(configtool: 'cxxflags').split(),
40 backend_targets += llvmjit
43 # Define a few bits and pieces used here and elsewhere to generate bitcode
46 '-c', '-o', '@OUTPUT@', '@INPUT@',
47 '-flto=thin', '-emit-llvm',
48 '-MD', '-MQ', '@OUTPUT@', '-MF', '@DEPFILE@',
50 '-Wno-ignored-attributes',
55 llvm_irgen_command = ccache
56 llvm_irgen_args = [clang.path()] + llvm_irgen_args
58 llvm_irgen_command = clang
62 # XXX: Need to determine proper version of the function cflags for clang
63 bitcode_cflags = ['-fno-strict-aliasing', '-fwrapv']
64 bitcode_cflags += get_option('c_args')
65 bitcode_cflags += cppflags
67 # XXX: Worth improving on the logic to find directories here
68 bitcode_cflags += '-I@BUILD_ROOT@/src/include'
69 bitcode_cflags += '-I@BUILD_ROOT@/src/backend/utils/misc'
70 bitcode_cflags += '-I@SOURCE_ROOT@/src/include'
73 # Note this is intentionally not installed to bitcodedir, as it's not for
75 llvmjit_types = custom_target('llvmjit_types.bc',
76 command: [llvm_irgen_command] + llvm_irgen_args + bitcode_cflags,
77 input: 'llvmjit_types.c',
78 output: 'llvmjit_types.bc',
81 install_dir: dir_lib_pkg,
82 depfile: '@BASENAME@.c.bc.d',
84 backend_targets += llvmjit_types