Re: OK to build LLVM (*.bc) with CLANG but rest of postgresql with CC (other compiler)?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Palle Girgensohn <girgen(at)pingpong(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: OK to build LLVM (*.bc) with CLANG but rest of postgresql with CC (other compiler)?
Date: 2023-06-22 19:02:10
Message-ID: 20230622190210.ns5iatr3zahwv6pt@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-06-13 11:20:52 +0200, Palle Girgensohn wrote:
> CLANG is used to compile *.bc files during postgresql build. Is it OK to
> have a different compiler for the rest of the build? gcc, or even another
> version of clang?

Yes.

> LLVM is an optional add-on, a package. The default version is 15, and it also installs the clang15 binary for the corresponding clang version 15.
>
> As I understand, you're "better off" compiling the LLVM stuff in PostgreSQL with the same version clang compiler as the LLVM version you're using. Hence, with LLVM 15, set the environment variable CLANG=/path/to/clang15 when running configure. If the .bc files will get compiled by the base system clang compiler, this can lead to a ThinLTO link error, if the base system compiler is a newer versione of llvm.

Yea, the compatibility matrix for llvm bitcode is complicated.

> The question is if it is a bad idea to use the base compiler, say clang13,
> to build postgresql, but set CLANG=clang15 to match the LLVM version. Am I
> better off using clang15 for everything then?

That should be entirely fine. If you already have the newer clang version, it
might also make sense to just use it from a simplicity perspective
(e.g. compiler warnings being the same etc), but it's not required. It works
just fine to compile the postgres binary with gcc and use clang for the
bitcode after all.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Zhang 2023-06-22 19:08:05 Re: [PATCH] pg_regress.c: Fix "make check" on Mac OS X: Pass DYLD_LIBRARY_PATH
Previous Message Nikolay Samokhvalov 2023-06-22 18:30:20 Re: UUID v7