1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00
Files
postgres/src/backend/jit/llvm/meson.build
Thomas Munro 74d19ec096 jit: Support opaque pointers in LLVM 16.
Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com
2023-10-18 22:53:56 +13:00

86 lines
2.1 KiB
Meson

# 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