public inbox for [email protected]
help / color / mirror / Atom feedFrom: Marcelo Juchem <[email protected]>
To: [email protected]
Cc: Marcelo Juchem <[email protected]>
Subject: [PATCH] Support static linking against LLVM
Date: Thu, 10 Aug 2023 14:45:47 -0500
Message-ID: <[email protected]> (raw)
By default, PostgreSQL doesn't explicitly choose whether to link
statically or dynamically against LLVM when LLVM JIT is enabled (e.g.:
`./configure --with-llvm`).
`llvm-config` will choose to dynamically link by default.
In order to statically link, one must pass `--link-static` to
`llvm-config` when listing linker flags (`--ldflags`) and libraries
(`--libs`).
This patch enables custom flags to be passed to `llvm-config` linker
related invocations through the environment variable
`LLVM_CONFIG_LINK_ARGS`.
To statically link against LLVM it suffices, then, to call `configure`
with environment variable `LLVM_CONFIG_LINK_ARGS=--link-static`.
---
config/llvm.m4 | 5 +++--
configure | 6 ++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/config/llvm.m4 b/config/llvm.m4
index 3a75cd8b4d..712bd3de6c 100644
--- a/config/llvm.m4
+++ b/config/llvm.m4
@@ -13,6 +13,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
AC_REQUIRE([AC_PROG_AWK])
AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config command])
+ AC_ARG_VAR(LLVM_CONFIG_LINK_ARGS, [extra arguments for llvm-config linker related flags])
PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-7 llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9)
# no point continuing if llvm wasn't found
@@ -52,7 +53,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
esac
done
- for pgac_option in `$LLVM_CONFIG --ldflags`; do
+ for pgac_option in `$LLVM_CONFIG --ldflags $LLVM_CONFIG_LINK_ARGS`; do
case $pgac_option in
-L*) LDFLAGS="$LDFLAGS $pgac_option";;
esac
@@ -84,7 +85,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
# And then get the libraries that need to be linked in for the
# selected components. They're large libraries, we only want to
# link them into the LLVM using shared library.
- for pgac_option in `$LLVM_CONFIG --libs --system-libs $pgac_components`; do
+ for pgac_option in `$LLVM_CONFIG --libs --system-libs $LLVM_CONFIG_LINK_ARGS $pgac_components`; do
case $pgac_option in
-l*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
esac
diff --git a/configure b/configure
index 86ffccb1ee..974b7f2d4e 100755
--- a/configure
+++ b/configure
@@ -1595,6 +1595,8 @@ Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LLVM_CONFIG path to llvm-config command
+ LLVM_CONFIG_LINK_ARGS
+ extra arguments for llvm-config linker related flags
CLANG path to clang compiler to generate bitcode
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
@@ -5200,7 +5202,7 @@ fi
esac
done
- for pgac_option in `$LLVM_CONFIG --ldflags`; do
+ for pgac_option in `$LLVM_CONFIG --ldflags $LLVM_CONFIG_LINK_ARGS`; do
case $pgac_option in
-L*) LDFLAGS="$LDFLAGS $pgac_option";;
esac
@@ -5232,7 +5234,7 @@ fi
# And then get the libraries that need to be linked in for the
# selected components. They're large libraries, we only want to
# link them into the LLVM using shared library.
- for pgac_option in `$LLVM_CONFIG --libs --system-libs $pgac_components`; do
+ for pgac_option in `$LLVM_CONFIG --libs --system-libs $LLVM_CONFIG_LINK_ARGS $pgac_components`; do
case $pgac_option in
-l*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
esac
--
2.40.1
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH] Support static linking against LLVM
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox