envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Compilation fails with clang + libstdc++-12

Open yaroslavros opened this issue 1 year ago • 2 comments

Title: Compilation fails with clang + libstdc++-12. libstdc++-11 works fine

Description: Compiling envoy tag 1.30.1 on gentoo/arm64. Combination of libstdc++-12 with any recent version of clang results in compilation failure in com_google_cel_cpp Here is the relevant snippet:

[9,700 / 13,567] 4 actions running
ERROR: /home/yaroslav/.cache/bazel/_bazel_yaroslav/f8b126161c56ca08134e8bc8d73f573f/external/com_google_cel_cpp/eval/public/structs/BUILD:19:11: Compiling eval/public/structs/cel_proto_wrapper.cc failed: (Exit 1): clang-16 failed: error executing command (from target @com_google_cel_cpp//eval/public/structs:cel_proto_wrapper)
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/type_traits:1364:23: error: incomplete type 'cel::JsonObject' used in type trait expression
                    __bool_constant<__has_trivial_destructor(_Tp)>>
                                    ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/type_traits:3241:5: note: in instantiation of template class 'std::is_trivially_destructible<cel::JsonObject>' requested here
    is_trivially_destructible<_Tp>::value;
    ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/variant:341:5: note: in instantiation of variable template specialization 'std::is_trivially_destructible_v<cel::JsonObject>' requested here
          (is_trivially_destructible_v<_Types> && ...);
           ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/variant:350:4: note: in instantiation of static data member 'std::__detail::__variant::_Traits<cel::JsonNull, bool, double, absl::Cord, cel::JsonArray, cel::JsonObject>::_S_trivial_dtor' requested here
          _S_trivial_dtor && _S_trivial_move_ctor
          ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/variant:732:45: note: in instantiation of static data member 'std::__detail::__variant::_Traits<cel::JsonNull, bool, double, absl::Cord, cel::JsonArray, cel::JsonObject>::_S_trivial_move_assign' requested here
      _Move_assign_base<_Traits<_Types...>::_S_trivial_move_assign, _Types...>;
                                            ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/variant:735:28: note: in instantiation of template type alias '_Move_assign_alias' requested here
    struct _Variant_base : _Move_assign_alias<_Types...>
                           ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/variant:1337:15: note: in instantiation of template class 'std::__detail::__variant::_Variant_base<cel::JsonNull, bool, double, absl::Cord, cel::JsonArray, cel::JsonObject>' requested here
    : private __detail::__variant::_Variant_base<_Types...>,
              ^
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/bits/stl_vector.h:1084:24: note: in instantiation of template class 'std::variant<cel::JsonNull, bool, double, absl::Cord, cel::JsonArray, cel::JsonObject>' requested here
      { return begin() == end(); }
                       ^
external/com_google_cel_cpp/common/json.h:126:43: note: in instantiation of member function 'std::vector<std::variant<cel::JsonNull, bool, double, absl::Cord, cel::JsonArray, cel::JsonObject>>::empty' requested here
  bool empty() const { return impl_.get().empty(); }
                                          ^
external/com_google_cel_cpp/common/json.h:73:34: note: forward declaration of 'cel::JsonObject'
class ABSL_ATTRIBUTE_TRIVIAL_ABI JsonObject;
                                 ^
In file included from external/com_google_cel_cpp/eval/public/structs/cel_proto_wrapper.cc:15:
In file included from external/com_google_cel_cpp/eval/public/structs/cel_proto_wrapper.h:4:
In file included from bazel-out/aarch64-opt/bin/external/com_google_protobuf/src/google/protobuf/_virtual_includes/duration_proto/google/protobuf/duration.pb.h:8:
In file included from /usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/string:40:
In file included from /usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/bits/char_traits.h:42:
/usr/lib/gcc/aarch64-unknown-linux-gnu/12/include/g++-v12/type_traits:1366:7: error: static assertion failed due to requirement 'std::__is_complete_or_unbounded(std::__type_identity<cel::JsonObject>{})': template argument must be a complete class or an unbounded array
      static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Issue happens with both clang-16 and clang-17. Downgrading gcc/libstdc++ to v11 resolves it and compilation completes successfully.

Repro steps: Attempt to compile with clang-16 or clang-17 with libstdc++-12 (reported gcc version is 12.3.1 20240209) results in this issue. Switching to libstdc++-11 (reported gcc version is 11.4.1 20240111) resolves it.

yaroslavros avatar May 26 '24 10:05 yaroslavros

@yaroslavros the currently supported llvm version is 14 - we are trying to update this but there are a bunch of issues that will need to be addressed before we can.

the easiest/supported way to build is to use the build container - or at least to replicate the versions that it has installed. That said, any PRs to resolve issues with newer llvm/libc++/libstdc++ versions would be gratefully received

phlax avatar May 29 '24 10:05 phlax

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 29 '24 00:06 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar Jul 06 '24 04:07 github-actions[bot]

Facing this same error, tried to build using clang-14 + libstdc++ 11, but still getting the same compilation issues.

Any idea how to fix this..? @yaroslavros @phlax

learnsomethingtoday avatar Oct 10 '24 14:10 learnsomethingtoday

I belive that this particular issue was addressed in cel-cpp recently (see https://github.com/google/cel-cpp/commit/18cf5685e93fb8c07c807d913fabe9d1b54db87f). I was able to build Envoy with clang 18 with a very similar fix (I found out that it was fixed when I tried to send a PR to cel folks).

krinkinmu avatar Dec 12 '24 18:12 krinkinmu