Most posts I could find are about building just the libjit with LLVM/CLANG.
So here's my 5 cents on the subject.
I'll be using [V]irtual[M]achine running Debian [12] Testing, with basic building pakages already installed :
binutils make gcc-12 libtool libss-dev libreadline-dev libxslt1-dev libxml2-dev libpth-dev zlib1g-dev
My usual configure parameters for GCC :
./configure --prefix=/media/pg --with-pam --with-libxml --with-libxslt --with-openssl --with-pgport=5433 --with-llvm LLVM_CONFIG=llvm-config-15 CLANG=clang-15 CFLAGS="-s -O3 -march=native -mtune=native -fno-plt -flto=4" CXXFLAGS="-s -O3 -march=native -mtune=native -fno-plt -flto=4" LDFLAGS="-Wl,-O3,--as-needed,-flto=4"
Packages to add :
libllvm15 lld-15 llvm-15 llvm-15-dev llvm-15-linker-tools llvm-15-runtime llvm-15-tools
clang-15 libclang-common-15-dev libclang-cpp15 libclang1-15
I won't be using https://libcxx.llvm.org since it's not fully baked yet :
C++11 - Complete
C++14 - Complete
C++17 - In Progress
C++20 - In Progress
C++23 - In Progress
C++2c - In Progress
My goal is to check if CLANG can handle Postgres sources ;]
So here's my configure for LLVM :
./configure --prefix=/media/pg13 --with-pam --with-libxml --with-libxslt --with-openssl --with-pgport=5433 --with-llvm LLVM_CONFIG=llvm-config-15 CLANG=clang-15 CC=clang-15 CXX=clang-15 CFLAGS="-fuse-ld=lld-15 -s -O3 -march=native -fno-plt -mtune=native -flto" CXXFLAGS="-fuse-ld=lld-15 -s -O3 -march=native -flto -fno-plt -mtune=native" LD=lld-15 AR=llvm-ar-15 RANLIB=llvm-ranlib-15 STRIP=llvm-strip-15
.. and result
configure: using compiler=Debian clang version 15.0.6 configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-deprecated-non-prototype -fuse-ld=lld -s -O3 -march=native -fno-plt -mtune=native -flto configure: using CPPFLAGS= -D_GNU_SOURCE -I/usr/include/libxml2 configure: using LDFLAGS= -L/usr/lib/llvm-15/lib -Wl,--as-needed configure: using CXX=clang configure: using CXXFLAGS=-Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fuse-ld=lld -s -O3 -march=native -flto -fno-plt -mtune=native configure: using CLANG=clang configure: using BITCODE_CFLAGS= -fno-strict-aliasing -fwrapv -Xclang -no-opaque-pointers -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-deprecated-non-prototype -O2 configure: using BITCODE_CXXFLAGS= -fno-strict-aliasing -fwrapv -Xclang -no-opaque-pointers -O2
Using both "-fuse-ld=lld" and "LD=lld" might be redundant, but without at least one of them - even with setting all the llvm/clang tools - clang will use default linker - ld.
Even running 'make -d V=1' you won't see which linker clang calls in the end, bummer.
I had to run 'make V=1 &>../zbuild.log &' in background and watch processes in htop.
Everything build nicely for me, resulting binaries a tad smaller than those build with GCC-12.
Postgres - I've tested sources vesion 13.10 and 13.11, server runs, so far no errors.
Is it faster ? maybe ;]