Ubuntu20.04 gcc 9.4 on llvm 3.4.2

In ubuntu 20.04 I want to use default g++ 9.4 to compile llvm-3.4.2

cmake -G “Unix Makefiles” …
and make got such error:

 51%] Building CXX object projects/libcxx/lib/CMakeFiles/cxx.dir/__/src/system_error.cpp.o
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/system_error:221,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:11:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/__config:412:11: note: you may use an inline namespace instead
  412 | namespace _LIBCPP_NAMESPACE {
      |           ^~~~~~~~~~~~~~~~~
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/system_error:223,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:11:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:1991:8: error: expected identifier before ‘__is_constructible’
 1991 | struct __is_constructible // false, _Tp is not a scalar
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:1991:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2001:8: error: expected identifier before ‘__is_constructible’
 2001 | struct __is_constructible<false, _Rp(_A1...), _A2...>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2001:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2010:8: error: expected identifier before ‘__is_constructible’
 2010 | struct __is_constructible<true, _Tp>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2010:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2025:8: error: expected identifier before ‘__is_constructible’
 2025 | struct __is_constructible<true, _Tp, _A0>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2025:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2035:8: error: expected identifier before ‘__is_constructible’
 2035 | struct __is_constructible<true, _Tp, _A0, _Args...>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2035:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2043:14: error: expected class-name before ‘__is_constructible’
 2043 |     : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
      |              ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2043:14: error: expected ‘{’ before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2078:8: error: expected identifier before ‘__is_constructible’
 2078 | struct __is_constructible<false, _Ap[_Np]>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2078:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2085:8: error: expected identifier before ‘__is_constructible’
 2085 | struct __is_constructible<false, _Ap[_Np], _Args...>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2085:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2092:8: error: expected identifier before ‘__is_constructible’
 2092 | struct __is_constructible<false, _Ap[], _Args...>
      |        ^~~~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2092:8: error: expected unqualified-id before ‘__is_constructible’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits: In instantiation of ‘struct std::__1::is_constructible<std::__1::__shared_weak_count*, std::__1::__shared_weak_count*&&>’:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2296:30:   required from ‘struct std::__1::is_move_constructible<std::__1::__shared_weak_count*>’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:3166:39:   required by substitution of ‘template<class _Tp> typename std::__1::enable_if<(std::__1::is_move_constructible<_Tp>::value && std::__1::is_move_assignable<_Tp>::value)>::type std::__1::swap(_Tp&, _Tp&) [with _Tp = std::__1::__shared_weak_count*]’
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39:   required from here
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2068:30: error: invalid use of incomplete type ‘struct std::__1::__is_constructible_void_check<false, std::__1::__shared_weak_count*, std::__1::__shared_weak_count*&&>’
 2068 | struct _LIBCPP_TYPE_VIS_ONLY is_constructible
      |                              ^~~~~~~~~~~~~~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:2042:8: note: declaration of ‘struct std::__1::__is_constructible_void_check<false, std::__1::__shared_weak_count*, std::__1::__shared_weak_count*&&>’
 2042 | struct __is_constructible_void_check
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory: In member function ‘void std::__1::shared_ptr<_Tp>::swap(std::__1::shared_ptr<_Tp>&)’:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: error: no matching function for call to ‘swap(std::__1::__shared_weak_count*&, std::__1::__shared_weak_count*&)’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/system_error:223,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:11:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:3172:1: note: candidate: ‘template<class _Tp> typename std::__1::enable_if<(std::__1::is_move_constructible<_Tp>::value && std::__1::is_move_assignable<_Tp>::value)>::type std::__1::swap(_Tp&, _Tp&)’
 3172 | swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:3172:1: note:   substitution of deduced template arguments resulted in errors seen above
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:626,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/utility:218:1: note: candidate: ‘template<class _Tp, long unsigned int _Np> void std::__1::swap(_Tp (&)[_Np], _Tp (&)[_Np])’
  218 | swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/utility:218:1: note:   template argument deduction/substitution failed:
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: note:   mismatched types ‘_Tp [_Np]’ and ‘std::__1::__shared_weak_count*’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:626,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/utility:456:1: note: candidate: ‘template<class _T1, class _T2> typename std::__1::enable_if<(std::__1::__is_swappable<_Tp>::value && std::__1::__is_swappable<_T2>::value), void>::type std::__1::swap(std::__1::pair<_T1, _T2>&, std::__1::pair<_T1, _T2>&)’
  456 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/utility:456:1: note:   template argument deduction/substitution failed:
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: note:   mismatched types ‘std::__1::pair<_T1, _T2>’ and ‘std::__1::__shared_weak_count*’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:603,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/tuple:166:6: note: candidate: ‘template<long unsigned int _Ip, class _Hp, bool _Ep> void std::__1::swap(std::__1::__tuple_leaf<_Ip, _Hp, _Ep>&, std::__1::__tuple_leaf<_Ip, _Hp, _Ep>&)’
  166 | void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
      |      ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/tuple:166:6: note:   template argument deduction/substitution failed:
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: note:   mismatched types ‘std::__1::__tuple_leaf<_Ip, _Hp, _Ep>’ and ‘std::__1::__shared_weak_count*’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:603,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/tuple:704:1: note: candidate: ‘template<class ... _Tp> typename std::__1::enable_if<std::__1::__all<std::__1::__is_swappable<_Tp>::value ...>::value, void>::type std::__1::swap(std::__1::tuple<_Tp ...>&, std::__1::tuple<_Tp ...>&)’
  704 | swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/tuple:704:1: note:   template argument deduction/substitution failed:
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/algorithm:627,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/string:439,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:12:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: note:   mismatched types ‘std::__1::tuple<_Tp ...>’ and ‘std::__1::__shared_weak_count*’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:2381:1: note: candidate: ‘template<class _T1, class _T2> void std::__1::swap(std::__1::__compressed_pair<_T1, _T2>&, std::__1::__compressed_pair<_T1, _T2>&)’
 2381 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:2381:1: note:   template argument deduction/substitution failed:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: note:   mismatched types ‘std::__1::__compressed_pair<_T1, _T2>’ and ‘std::__1::__shared_weak_count*’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:2871:1: note: candidate: ‘template<class _Tp, class _Dp> void std::__1::swap(std::__1::unique_ptr<_Tp, _Dp>&, std::__1::unique_ptr<_Tp, _Dp>&)’
 2871 | swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:2871:1: note:   template argument deduction/substitution failed:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:4569:39: note:   mismatched types ‘std::__1::unique_ptr<_Tp, _Dp>’ and ‘std::__1::__shared_weak_count*’
 4569 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory: In member function ‘void std::__1::weak_ptr<_Tp>::swap(std::__1::weak_ptr<_Tp>&)’:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:5144:39: error: no matching function for call to ‘swap(std::__1::__shared_weak_count*&, std::__1::__shared_weak_count*&)’
 5144 |     _VSTD::swap(__cntrl_, __r.__cntrl_);
      |                                       ^
In file included from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/system_error:223,
                 from /home/engine/bin/llvm-3.4.2.src/projects/libcxx/src/system_error.cpp:11:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:3172:1: note: candidate: ‘template<class _Tp> typename std::__1::enable_if<(std::__1::is_move_constructible<_Tp>::value && std::__1::is_move_assignable<_Tp>::value)>::type std::__1::swap(_Tp&, _Tp&)’
 3172 | swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
      | ^~~~
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:3172:1: note:   template argument deduction/substitution failed:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits: In substitution of ‘template<class _Tp> typename std::__1::enable_if<(std::__1::is_move_constructible<_Tp>::value && std::__1::is_move_assignable<_Tp>::value)>::type std::__1::swap(_Tp&, _Tp&) [with _Tp = std::__1::__shared_weak_count*]’:
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/memory:5144:39:   required from here
/home/engine/bin/llvm-3.4.2.src/projects/libcxx/include/type_traits:3166:39: error: ‘value’ is not a member of ‘std::__1::is_move_constructible<std::__1::__shared_weak_count*>’
 3166 |     is_move_constructible<_Tp>::value &&
      |                                 ~~~~~~^~
 3167 |     is_move_assignable<_Tp>::value

LLVM 3.4.2 was release back in 2014. Why do you need to compile such old version? Likely you’d need to either use previous versions of system compiler or use newer LLVM.

I upgrade my system for some reason. and the old code need maintains. May be a more reasonable way is to upgrade my old application with newer llvm version.

Any way. I may think this can be solved by passed some parameter.