Project
Nearby Connections
Language
C++
OS Platform
Linux
What happened?
When building using the README with the Bazel build system, things fail to build due to C integer types not being "defined" (file not being included). This happens in some of the code in this repository, in internal/crypto/sha2.h, internal/crypto/nearby_base.h, internal/crypto/random.h and in third party libraries such as abseil-cpp. This is due to this change in GCC 13.
With the files in this repository, all that would need to be changed is adding #include <cstdint>
or #include <stdint.h>
and for abseil-cpp, increasing the submodule commit to a commit equal or greater to commit b957f0c.
What did you expect to happen?
I expected it to build successfully without error.
How can we reproduce it (as minimally and precisely as possible)?
- Update/use GCC 13 or higher.
- Follow the steps in the Nearby Connections README.
How often does this bug happen?
Every time
Standalone code to reproduce the issue
No response
Relevant log output
ERROR: /home/thetimbrick/google/nearby/internal/crypto/BUILD:23:11: Compiling internal/crypto/sha2.cc failed: (Exit 1): clang-15 failed: error executing command (from target //internal/crypto:crypto)
(cd /home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__ && \
exec env - \
BAZEL_CXXOPTS='-std=c++17' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin \
PWD=/proc/self/cwd \
/usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++17' -MD -MF bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/sha2.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/sha2.pic.o' -fPIC '-DBAZEL_CURRENT_REPOSITORY=""' -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/boringssl -iquote bazel-out/k8-fastbuild/bin/external/boringssl -iquote external/com_google_absl -iquote bazel-out/k8-fastbuild/bin/external/com_google_absl -isystem external/boringssl/src/include -isystem bazel-out/k8-fastbuild/bin/external/boringssl/src/include -DCRYPTO_IMPLEMENTATION -Ithird_party -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c internal/crypto/sha2.cc -o bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/sha2.pic.o)
# Configuration: a7b732125cae20632358513ffa9ec1499ce0ba5122adaa7480c6548305ecada8
# Execution platform: @local_config_platform//:host
In file included from internal/crypto/sha2.cc:15:
./internal/crypto/sha2.h:36:26: error: use of undeclared identifier 'uint8_t'
CRYPTO_EXPORT std::array<uint8_t, kSHA256Length> SHA256Hash(
^
./internal/crypto/sha2.h:37:22: error: unknown type name 'uint8_t'
absl::Span<const uint8_t> input);
^
2 errors generated.
Target //connections:core failed to build
INFO: Elapsed time: 413.084s, Critical Path: 44.32s
INFO: 375 processes: 107 internal, 268 local.
FAILED: Build did NOT complete successfully
ERROR: /home/thetimbrick/google/nearby/internal/crypto/BUILD:23:11: Compiling internal/crypto/nearby_base.cc failed: (Exit 1): clang-15 failed: error executing command (from target //internal/crypto:crypto)
(cd /home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__ && \
exec env - \
BAZEL_CXXOPTS='-std=c++17' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin \
PWD=/proc/self/cwd \
/usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++17' -MD -MF bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/nearby_base.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/nearby_base.pic.o' -fPIC '-DBAZEL_CURRENT_REPOSITORY=""' -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/boringssl -iquote bazel-out/k8-fastbuild/bin/external/boringssl -iquote external/com_google_absl -iquote bazel-out/k8-fastbuild/bin/external/com_google_absl -isystem external/boringssl/src/include -isystem bazel-out/k8-fastbuild/bin/external/boringssl/src/include -DCRYPTO_IMPLEMENTATION -Ithird_party -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c internal/crypto/nearby_base.cc -o bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/nearby_base.pic.o)
# Configuration: a7b732125cae20632358513ffa9ec1499ce0ba5122adaa7480c6548305ecada8
# Execution platform: @local_config_platform//:host
In file included from internal/crypto/nearby_base.cc:15:
./internal/crypto/nearby_base.h:33:18: error: unknown type name 'uint8_t'
absl::Span<const uint8_t> as_bytes(absl::Span<T> s) noexcept {
^
./internal/crypto/nearby_base.h:34:34: error: unknown type name 'uint8_t'
return {reinterpret_cast<const uint8_t*>(s.data()), sizeof(T) * s.size()};
^
2 errors generated.
Target //connections:core failed to build
INFO: Elapsed time: 351.377s, Critical Path: 350.73s
INFO: 548 processes: 63 internal, 485 local.
FAILED: Build did NOT complete successfully
ERROR: /home/thetimbrick/google/nearby/internal/crypto/BUILD:23:11: Compiling internal/crypto/random.cc failed: (Exit 1): clang-15 failed: error executing command (from target //internal/crypto:crypto)
(cd /home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__ && \
exec env - \
BAZEL_CXXOPTS='-std=c++17' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin \
PWD=/proc/self/cwd \
/usr/bin/clang-15 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++17' -MD -MF bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/random.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/random.pic.o' -fPIC '-DBAZEL_CURRENT_REPOSITORY=""' -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/boringssl -iquote bazel-out/k8-fastbuild/bin/external/boringssl -iquote external/com_google_absl -iquote bazel-out/k8-fastbuild/bin/external/com_google_absl -isystem external/boringssl/src/include -isystem bazel-out/k8-fastbuild/bin/external/boringssl/src/include -DCRYPTO_IMPLEMENTATION -Ithird_party -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c internal/crypto/random.cc -o bazel-out/k8-fastbuild/bin/internal/crypto/_objs/crypto/random.pic.o)
# Configuration: a7b732125cae20632358513ffa9ec1499ce0ba5122adaa7480c6548305ecada8
# Execution platform: @local_config_platform//:host
In file included from internal/crypto/random.cc:15:
./internal/crypto/random.h:37:41: error: use of undeclared identifier 'uint8_t'
CRYPTO_EXPORT void RandBytes(absl::Span<uint8_t> bytes);
^
1 error generated.
Target //connections:core failed to build
INFO: Elapsed time: 4.746s, Critical Path: 4.36s
INFO: 15 processes: 6 internal, 9 local.
FAILED: Build did NOT complete successfully
In file included from /home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.cc:16:
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:34:35: error: unknown type name 'uint8_t'
enum class FormatConversionChar : uint8_t;
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:35:38: error: unknown type name 'uint64_t'
enum class FormatConversionCharSet : uint64_t;
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:173:21: error: unknown type name 'uint8_t'
enum class Enum : uint8_t {
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:327:19: error: unknown type name 'uint64_t'
static_cast<uint64_t>(a) |
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:328:19: error: unknown type name 'uint64_t'
static_cast<uint64_t>(FormatConversionCharSetUnion(rest...)));
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:331:11: error: unknown type name 'uint64_t'
constexpr uint64_t FormatConversionCharToConvInt(FormatConversionChar c) {
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:332:10: error: use of undeclared identifier 'uint64_t'
return uint64_t{1} << (1 + static_cast<uint8_t>(c));
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:332:18: error: expected ';' after return statement
return uint64_t{1} << (1 + static_cast<uint8_t>(c));
^
;
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:335:11: error: unknown type name 'uint64_t'
constexpr uint64_t FormatConversionCharToConvInt(char conv) {
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:348:35: error: no return statement in constexpr function
constexpr FormatConversionCharSet FormatConversionCharToConvValue(char conv) {
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, )
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:147:9: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(c) X_SEP X_VAL(s) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:147:24: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(c) X_SEP X_VAL(s) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:149:9: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(d) X_SEP X_VAL(i) X_SEP X_VAL(o) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:149:24: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(d) X_SEP X_VAL(i) X_SEP X_VAL(o) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:149:39: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(d) X_SEP X_VAL(i) X_SEP X_VAL(o) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:150:9: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(u) X_SEP X_VAL(x) X_SEP X_VAL(X) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:150:24: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(u) X_SEP X_VAL(x) X_SEP X_VAL(X) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:150:39: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(u) X_SEP X_VAL(x) X_SEP X_VAL(X) X_SEP \
^
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:357:3: error: default initialization of an object of const type 'const absl::FormatConversionCharSet'
/home/thetimbrick/.cache/bazel/_bazel_thetimbrick/54eafa58feb1122e78a2e515ed11b705/execroot/__main__/external/com_google_ukey2/third_party/absl/absl/strings/internal/str_format/extension.h:152:9: note: expanded from macro 'ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_'
X_VAL(f) X_SEP X_VAL(F) X_SEP X_VAL(e) X_SEP X_VAL(E) X_SEP \
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
5 warnings and 20 errors generated.
make[2]: *** [third_party/absl/absl/strings/CMakeFiles/absl_str_format_internal.dir/build.make:104: third_party/absl/absl/strings/CMakeFiles/absl_str_format_internal.dir/internal/str_format/extension.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2408: third_party/absl/absl/strings/CMakeFiles/absl_str_format_internal.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
_____ END BUILD LOGS _____
rules_foreign_cc: Build wrapper script location: bazel-out/k8-fastbuild/bin/connections/implementation/ukey2_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build script location: bazel-out/k8-fastbuild/bin/connections/implementation/ukey2_foreign_cc/build_script.sh
rules_foreign_cc: Build log location: bazel-out/k8-fastbuild/bin/connections/implementation/ukey2_foreign_cc/CMake.log
Target //connections:core failed to build
INFO: Elapsed time: 494.212s, Critical Path: 481.14s
INFO: 4 processes: 2 internal, 2 local.
FAILED: Build did NOT complete successfully
Anything else we need to know?
Adding #include <cstdint>
or #include <stdint.h>
to internal/crypto/sha2.h, internal/crypto/nearby_base.h, and internal/crypto/random.h should fix the issue in the internal sources.
Updating the commit for the abseil-cpp submodule to a version greater than or equal to b957f0c in third_party/absl should solve that same issue for this dependency.
In the third party library ukey2, the same thing is happening with the C integer inclusion in their submodule for abseil-cpp, although that is a problem with that project and not this one. I am trying to build ukey2 by itself but it doesn't seem to want to build when I am not building using the build for Nearby Connections. The solution to this would to also increase the commit hash for it's abseil-cpp dependency to the one that fixes this issue. There is a PR in google/ukey2 that would remove the need for abseil-cpp that would solve that issue for that repository, but the PR and issue have been stagnant.
This bug might be relevant in other projects in this repository but they did not have instructions on how to build them, and since I'm not familiar with the Bazel build system I have not been able to build and test them yet.
The current GCC version in Ubuntu Latest is GCC 10 it looks like, so the issue will most likely not be reproducable in that enviornment.