Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qUBlE-00Bxbh-Op for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Aug 2023 19:55:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qUBlC-000WQ4-2Z for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Aug 2023 19:55:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qUBbX-000TK1-EF for pgsql-hackers@lists.postgresql.org; Thu, 10 Aug 2023 19:45:55 +0000 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qUBbV-001fnc-7N for pgsql-hackers@postgresql.org; Thu, 10 Aug 2023 19:45:54 +0000 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6bc9c01e154so1512002a34.0 for ; Thu, 10 Aug 2023 12:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691696752; x=1692301552; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UpGayKwf7Y50jwGGE4SbnbvYx3zm/bX7IjqwLDgTNi0=; b=UeOJed9CdNmctzJQX2CUU6qWyOf//GbOGZzTJV2QJJeH6v4KlMDWJ+xKVNYR+Wz5tH S7VD04oR82pv3YEbjxyDMm8AcvarXfqKSceD+oRnU65E8Reu3WSSAX9WqblZ8yZaFPrO gLMCcB+FWimT5k71XKrW0+Zi96NGXZsrqzExu/kqZzjTFwS93qgS+o27G7obdWCAmUct 1qjcEFm22M3mH19lI6iSg9oQkPMkWUesEZpY7+9f1NM37/hO2XJG4h7FGrIMY230rn+a 2I1ShOtMHcb5VQlrM8qC+jsFkMttOjw7HxFc47iuSnMM+0BKF241ALUIcj2O7ChGDOQf UXPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691696752; x=1692301552; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UpGayKwf7Y50jwGGE4SbnbvYx3zm/bX7IjqwLDgTNi0=; b=cg+RdlgQ0Gk1L317K5kiwviswC128b6fBaceAslTqL9r4Cuz4Tr5k6hoHG2lD1mgWl TMOBbU94uQlO4M06aGi+m5Xo7paAeutLCrGFgTl7fMp00GHnZrfwWJYP9BmwirdSI8m1 SPi51mREp/65HEz7b6jV8Q4Vjua6fmxHTbf1mLk3kjV1K4AdjaNCiQCxiyCa8x0H3gWV XG/5dOVhT7zPSNAbFGZ3XyMS0nQsqh4zaIZbVMbWFnRS2hv9iyo8QQupg9VMz9zCXEPI yJTxoxnFdX4PXlu2UtQgEASy9XeLhwKLfPW4F6WlJnyioLK8J0iYNKEEh4D9m1XE88Yn MuYQ== X-Gm-Message-State: AOJu0YxTxg2feNfp/DRkA5gY0sRVkGFWEtN14jEFae6lcIRhuhp334B/ E30qD8t/qI7TbKVDUF/8alw1QRifcBY/ZQ== X-Google-Smtp-Source: AGHT+IFHm4DuO5EPX4fKbOV5+Y0BNwEZ+ouMgfqk4vTrEJznTD19c655JKKMYnii/Vf+Z/DLARRcQg== X-Received: by 2002:a05:6870:a686:b0:1bb:7f1d:10f5 with SMTP id i6-20020a056870a68600b001bb7f1d10f5mr2331739oam.20.1691696752504; Thu, 10 Aug 2023 12:45:52 -0700 (PDT) Received: from localhost.localdomain (r74-192-157-194.gtwncmta01.grtntx.tl.dh.suddenlink.net. [74.192.157.194]) by smtp.googlemail.com with ESMTPSA id e4-20020a056870c34400b001bb7a3ab484sm1124722oak.16.2023.08.10.12.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 12:45:51 -0700 (PDT) From: Marcelo Juchem To: pgsql-hackers@postgresql.org Cc: Marcelo Juchem Subject: [PATCH] Support static linking against LLVM Date: Thu, 10 Aug 2023 14:45:47 -0500 Message-Id: <20230810194547.3579673-1-juchem@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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