Building LLVM using Gcc 12.2 fails

I have Gcc 12.2.0 on my system. I configured Clang build as follows:

> cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/user/install -DLLVM_ENABLE_PROJECTS=all ../llvm

and ran make. I get the following error:

[ 23%] Building CXX object projects/libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinf.dir/sinf.cpp.o
In file included from /home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/math/generic/sinf.cpp:14:
/home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/__support/FPUtil/except_value_utils.h:34:9: error: declaration of ‘using FPBits = struct __llvm_libc::fputil::FPBits<T>’ changes meaning of ‘FPBits’ [-fpermissive]
   34 |   using FPBits = FPBits<T>;
      |         ^~~~~~
In file included from /home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/__support/FPUtil/BasicOperations.h:12,
                 from /home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/math/generic/sinf.cpp:10:
/home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/__support/FPUtil/FPBits.h:41:30: note: ‘FPBits’ declared here as ‘struct __llvm_libc::fputil::FPBits<T>’
   41 | template <typename T> struct FPBits {
      |                              ^~~~~~
/home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/__support/FPUtil/except_value_utils.h:35:9: error: declaration of ‘using ExceptionalValues = struct __llvm_libc::fputil::ExceptionalValues<T, N>’ changes meaning of ‘ExceptionalValues’ [-fpermissive]
   35 |   using ExceptionalValues = ExceptionalValues<T, N>;
      |         ^~~~~~~~~~~~~~~~~
/home/user/sources/llvm-project-llvmorg-15.0.6/libc/src/__support/FPUtil/except_value_utils.h:19:37: note: ‘ExceptionalValues’ declared here as ‘struct __llvm_libc::fputil::ExceptionalValues<T, N>’
   19 | template <typename T, int N> struct ExceptionalValues {
      |                                     ^~~~~~~~~~~~~~~~~
make[2]: *** [projects/libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinf.dir/build.make:76: projects/libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinf.dir/sinf.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:60827: projects/libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinf.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

I’ve encountered the same issue. Try to build all projects except libc if it fails. It is likely it is not supported. The other projects also require dependencies. https://libc.llvm.org/ also recommend using your system libraries instead of libc.

There are working on making gcc work with libc, but they are not yet done.