Re: [PATCH] Support static linking against LLVM - Mailing list pgsql-hackers

From Marcelo Juchem
Subject Re: [PATCH] Support static linking against LLVM
Date
Msg-id CAK0nC2XCbZM-C=pdbiMAq2kiADE9CQonrNiFZt2oOS6fKSvY7Q@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Support static linking against LLVM  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
In my case, my product has a very controlled environment.
We build all our infrastructure from source and we avoid dynamic linking by design, except where technically not viable (e.g.: pgsql extensions).

LLVM is one of the libraries we're specifically required to statically link.
Unfortunately I can't share the specifics of why that's the case.

Without static link support by PostgreSQL we can't enable LLVM JIT.


On a side note, I'd like to take this opportunity to ask you if there's any work being done towards migrating away from deprecated LLVM APIs.
If there's no work being done on that front, I might take a stab at it if there's any interest from the PostgreSQL community in that contribution.

More specifically, there are some deprecated C APIs that are used in PostgreSQL (more details in https://llvm.org/docs/OpaquePointers.html#frontends).
For that reason, PostgreSQL LLVM JIT support will fail to build starting with the next version of LLVM (version 17).

Migrating to the new APIs will have PostgreSQL require at the minimum version 8 of LLVM (released in March 2019).

Regards,

-mj


On Fri, Aug 11, 2023 at 12:43 PM Andres Freund <andres@anarazel.de> wrote:
Hi,

On 2023-08-10 14:45:47 -0500, Marcelo Juchem wrote:
> 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`.

I'm not opposed to it, but I'm not sure I see much need for it either. Do you
have a specific use case for this?

Greetings,

Andres Freund

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: AssertLog instead of Assert in some places
Next
From: Andres Freund
Date:
Subject: Re: LLVM 16 (opaque pointers)