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

From: Palle Girgensohn <girgen(at)FreeBSD(dot)org>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: OK to build LLVM (*.bc) with CLANG but rest of postgresql with CC (other compiler)?
Date: 2023-06-13 09:19:48
Message-ID: 4B330B98-333D-4622-A42B-AB3EAF64DE88@FreeBSD.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

TL;DR:

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?

--

Slightly longer version:

I'm packaging postgresql for FreeBSD and as you probably know, in that OS clang is the default compiler.

At present, depending on OS version, it is clang version 13, 14 or even 16. That version of cc (clang) is always present.

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 version of llvm.

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?

Cheers,
Palle

Browse pgsql-hackers by date

  From Date Subject
Next Message Palle Girgensohn 2023-06-13 09:20:52 OK to build LLVM (*.bc) with CLANG but rest of postgresql with CC (other compiler)?
Previous Message Amit Kapila 2023-06-13 08:59:05 Re: Non-superuser subscription owners