c++libc++

Building libc++ on Ubuntu


I am trying to build libc++ on my Ubuntu machine and following the steps mentioned in the default build section of https://libcxx.llvm.org//BuildingLibcxx.html#getting-started

Following the steps lead to the errors

                 from ~/projects/libcxx/llvm-project/libcxxabi/src/stdlib_exception.cpp:9:
~/projects/libcxx/llvm-project/build/include/c++/v1/__type_traits/is_trivially_destructible.h:36:4: error: #error is_trivially_destructible is not implemented
   36 | #  error is_trivially_destructible is not implemented
      |    ^~~~~
In file included from ~/projects/libcxx/llvm-project/build/include/c++/v1/new:95,
                 from ~/projects/libcxx/llvm-project/libcxxabi/src/stdlib_exception.cpp:9:
~/projects/libcxx/llvm-project/build/include/c++/v1/__type_traits/is_same.h:22:53: error: there are no arguments to ‘__is_same’ that depend on a template parameter, so a declaration of ‘__is_same’ must be available [-fpermissive]
   22 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};
      |                                                     ^~~~~~~~~
~/projects/libcxx/llvm-project/build/include/c++/v1/__type_traits/is_same.h:22:53: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
~/projects/libcxx/llvm-project/build/include/c++/v1/__type_traits/is_same.h:22:72: error: template argument 1 is invalid
   22 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};
      |                                                                        ^
~/projects/libcxx/llvm-project/build/include/c++/v1/__type_traits/is_same.h:26:48: error: expected primary-expression before ‘,’ token
   26 | inline constexpr bool is_same_v = __is_same(_Tp, _Up);
      |                                                ^
~/projects/libcxx/llvm-project/build/include/c++/v1/__type_traits/is_same.h:26:53: error: expected primary-expression before ‘)’ token
   26 | inline constexpr bool is_same_v = __is_same(_Tp, _Up);

Could someone please help with this?


Solution

  • Looks like GCC 10 is required to compile this code: https://godbolt.org/z/6Yq66ahYs

    Libc++ 16 requires GCC 12: https://releases.llvm.org/16.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support

    You'll need to go back to version 12 to get support for compilers before GCC 11: https://releases.llvm.org/12.0.0/projects/libcxx/docs/index.html#platform-and-compiler-support

    Either downgrade to an older libc++ version, update to a newer GCC version or supported clang version.