The libc won't be your problem, but the standard C++ library.
FreeBSD ports include llvm, the latest version is
devel/llvm17 right now, sooner or later a port for llvm18 will be added for sure. LLVM comes with a standard C++ library (
libc++
), but the ports use the one version that's in base. So, whether you can use some "bleeding edge" language feature of C++ with LLVM on FreeBSD depends on whether it needs standard lib (STL) support, in that case it just depends on the libc++ (and STL) delivered with the base system, not on the compiler version.
OTOH, you might also try GCC. The ports of GCC include GCC's version of the standard C++ library (called
libstdc++
there), if I'm not mistaken, this is necessary because LLVM's libc++ isn't compatible with GCC anyways. Note you should add some
rpath
to binaries you build with GCC on FreeBSD, so they reliably find the correct version of that libs. For ports using GCC, this is handled automatically by
https://cgit.freebsd.org/ports/tree/Mk/bsd.gcc.mk