envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
25.13k stars 4.82k forks source link

Building envoy 1.26.6 using clang is failing on redhat : error unknown type name 'uint8_t' in external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc and external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.h #31133

Closed ssm6498 closed 10 months ago

ssm6498 commented 1 year ago

Title: Building envoy 1.26.6 using clang is failing on redhat

Description: I am trying to build envoy 1.26.6, I am using clang v15 First I got issues same as mentioned in https://github.com/envoyproxy/envoy/issues/29311 so I applied the patch https://github.com/sitano/envoy/commit/a087d46e0d61092bbb25d7d85fcd47f66966a380

that issue is resolved but now its failing again with errors:

In file included from external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:15: external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.h:28:1: error: unknown type name 'uint8_t' uint8_t CappedDamerauLevenshteinDistance(absl::string_view s1, ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.h:29:64: error: unknown type name 'uint8_t' absl::string_view s2, uint8_t cutoff); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:34:1: error: unknown type name 'uint8_t' uint8_t CappedDamerauLevenshteinDistance(absl::string_view s1, ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:35:64: error: unknown type name 'uint8_t' absl::string_view s2, uint8_t cutoff) { ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:36:9: error: unknown type name 'uint8_t' const uint8_t MAX_SIZE = 100; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:37:9: error: unknown type name 'uint8_t' const uint8_t _cutoff = std::min(MAX_SIZE, cutoff); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:38:9: error: unknown type name 'uint8_t' const uint8_t cutoff_plus_1 = static_cast(_cutoff + 1); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:38:45: error: unknown type name 'uint8_t' const uint8_t cutoff_plus_1 = static_cast(_cutoff + 1); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:45:24: error: unknown type name 'uint8_t' return static_cast(s2.size()); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:48:9: error: unknown type name 'uint8_t' const uint8_t lower_diag = ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:49:29: error: unknown type name 'uint8_t' _cutoff - static_cast(s2.size() - s1.size()); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:51:9: error: unknown type name 'uint8_t' const uint8_t upper_diag = _cutoff; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:54:25: error: use of undeclared identifier 'uint8_t' std::array<std::array<uint8_t, MAX_SIZE + 2>, MAX_SIZE + 2> d; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:64:29: error: unknown type name 'uint8_t' d[i][0] = static_cast(i); ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:76:13: error: unknown type name 'uint8_t' const uint8_t deletion_distance = d[i - 1][j] + 1; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:77:13: error: unknown type name 'uint8_t' const uint8_t insertion_distance = d[i][j - 1] + 1; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:78:13: error: unknown type name 'uint8_t' const uint8_t mismatched_tail_cost = s1[i - 1] == s2[j - 1] ? 0 : 1; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:79:13: error: unknown type name 'uint8_t' const uint8_t mismatch_distance = d[i - 1][j - 1] + mismatched_tail_cost; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:80:7: error: unknown type name 'uint8_t' uint8_t transposition_distance = _cutoff + 1; ^ external/com_google_absl/absl/strings/internal/damerau_levenshtein_distance.cc:45:36: warning: implicit conversion loses integer precision: 'std::basic_string_view::size_type' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32] return static_cast(s2.size());

I found below issue similar to my issue: https://github.com/envoyproxy/envoy/issues/26972

The solution given in commit https://github.com/envoyproxy/envoy/commit/c6e9cd59fda532c1e2b3c1d74d390d6d85d2e2ff is applied but no luck still having errors.

Its bit urgent. it would be great help if I get any solution sooner.

yanavlasov commented 1 year ago

It is possible that clang is using standard headers from the libstdc++ instead of libc++. You can try using --config=libc++ to bazel or use the supplied docker images for building.

sk-jena commented 12 months ago

We have a requirement to build envoy using the source tar on RHEL. And docker support isn't yet provided on RHEL platform. We follow recommended steps mentioned in https://github.com/envoyproxy/envoy/blob/a9e51fb9095a66543122842515b69c1723749309/bazel/README.md With these steps, we could able to build 1.26.4 successfully and want to upgrade to 1.26.6. Has there been any upgrade in compiler version or dependent pre-requisite versions with compare to 1.26.4 and 1.26.6?

phlax commented 12 months ago

you can see the diffferences here https://github.com/envoyproxy/envoy/compare/v1.26.4...v1.26.6

its mostly ci and dependency updates

sk-jena commented 12 months ago

The code diff is quite big to follow and find out the difference in 3-rd party component versions. What else could we do to fix the issue? It is a clean setup where we could able to build 1.26.4 but not 1.26.6

yanavlasov commented 12 months ago

@zipsantro Did you try the bazel option that I have suggested? If it does not work you can try bisecting the commits between two versions and see which one breaks your build.

sk-jena commented 12 months ago

@zipsantro Did you try the bazel option that I have suggested? If it does not work you can try bisecting the commits between two versions and see which one breaks your build.

With below change, the build is successful. cat user.bazelrc

build --config=libc++

Looking at the library dependency and comparing it with earlier binary built with clang, they look same. @yanavlasov , in this case, is it okay to say that the envoy 1.26.6 is broken with clang or there might be some build steps missing in the way we build it on RHEL using the source.tar.gz.

sk-jena commented 12 months ago

With build --config=libc++ I could able to build successfully when git cloned envoy repo based out of branch:v1.26.6. But when I pick up the source.tar.gz, it failed with below error on the same setup with similar configuration.

In file included from external/com_google_absl/absl/numeric/int128.cc:15: external/com_google_absl/absl/numeric/int128.h:29:10: fatal error: 'cassert' file not found

include

    ^~~~~~~~~

1 error generated.

sk-jena commented 12 months ago

I have been able to successfully build envoy 1.26.6 with build --config=libc++. We have a execution sequence issue where we install clang after executing setup_clang script.

github-actions[bot] commented 11 months ago

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] commented 10 months ago

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.