proxy-wasm-cpp-host icon indicating copy to clipboard operation
proxy-wasm-cpp-host copied to clipboard

build: Compile with C++20

Open mpwarres opened this issue 1 year ago • 8 comments

std=c++20 is used by both v8 and Envoy. Switching to use it overall will reduce build surprises when importing proxy-wasm-cpp-host into Envoy.

mpwarres avatar Aug 18 '24 21:08 mpwarres

Windows and MacOS presubmits fail with:

In file included from external/com_google_googletest/googlemock/include/gmock/gmock.h:59:
external/com_google_googletest/googlemock/include/gmock/gmock-actions.h:819:36: error: no type named 'result_of' in namespace 'std'
  using ReturnType = typename std::result_of<MethodPtr(Class*)>::type;
                     ~~~~~~~~~~~~~~^~~~~~~~~
external/com_google_googletest/googlemock/include/gmock/gmock-actions.h:819:45: error: expected ';' after alias declaration
  using ReturnType = typename std::result_of<MethodPtr(Class*)>::type;

This should be fixable by upgrading to a more recent version of googletest: https://github.com/google/googletest/issues/2914

mpwarres avatar Aug 18 '24 22:08 mpwarres

Repro of g++-specific compile error with variadic templates, which compiles successfully with -std=c++17 but not with -std=c++20: https://godbolt.org/z/TT9a9YPf7

mpwarres avatar Aug 18 '24 22:08 mpwarres

Repro of g++-specific compile error with variadic templates, which compiles successfully with -std=c++17 but not with -std=c++20: https://godbolt.org/z/TT9a9YPf7

Changing this constructor declaration from:

Counter<Tags...>(std::string_view name, MetricTagDescriptor<Tags>... descriptors)

to:

Counter(std::string_view name, MetricTagDescriptor<Tags>... descriptors)

appears to appease gcc-12, and works with clang as well. Hooray for godbolt.

mpwarres avatar Aug 18 '24 23:08 mpwarres

clang-tidy failure may be https://github.com/llvm/llvm-project/issues/56709

mpwarres avatar Aug 19 '24 03:08 mpwarres

Repro of g++-specific compile error with variadic templates, which compiles successfully with -std=c++17 but not with -std=c++20: https://godbolt.org/z/TT9a9YPf7

Changing this constructor declaration [...] appears to appease gcc-12, and works with clang as well. Hooray for godbolt.

Looks like the issue was this. I'll put it in a PR for proxy-wasm-cpp-sdk tomorrow.

mpwarres avatar Aug 19 '24 03:08 mpwarres

Repro of g++-specific compile error with variadic templates, which compiles successfully with -std=c++17 but not with -std=c++20: https://godbolt.org/z/TT9a9YPf7

Changing this constructor declaration from:

Counter<Tags...>(std::string_view name, MetricTagDescriptor<Tags>... descriptors)

to:

Counter(std::string_view name, MetricTagDescriptor<Tags>... descriptors)

appears to appease gcc-12, and works with clang as well. Hooray for godbolt.

I distinctly remember we had to appeal this way in envoy - there might be a patch there already.

kyessenov avatar Aug 19 '24 17:08 kyessenov

I distinctly remember we had to appeal this way in envoy - there might be a patch there already.

Indeed! https://github.com/envoyproxy/envoy/blob/6648db236f64218611f36e91285716c8bec67abb/bazel/proxy_wasm_cpp_sdk.patch

mpwarres avatar Aug 19 '24 17:08 mpwarres

The only remaining CI failure is due to clang-tidy itself crashing, which I hope is transient. So I think this is ready for review, @martijneken and/or @PiotrSikora. Thanks!

mpwarres avatar Aug 19 '24 18:08 mpwarres

This PR is obsoleted by #439.

mpwarres avatar Jul 15 '25 06:07 mpwarres