"error: ambiguating new declaration of 'long int gettid()" Displayed During Bazel Compilation
Symptom
During the compilation of Bazel 0.26.0, the message "error: ambiguating new declaration of'long int gettid()" is displayed.

Key Process and Cause Analysis
The gettid() function defined in the Bazel source code conflicts with the glibc library. Replace the function name gettid in the Bazel source code with gettid_sys, and then recompile Bazel.
Conclusion and Solution
- Query the function name in the Bazel source code before replacement.
grep -nr gettid

- Replace the function name gettid with gettid_sys.
grep -rl 'gettid' third_party/grpc/src/ | xargs sed -i 's/\bgettid/gettid_sys/g'
- Query the function name in the Bazel source code after replacement.
grep -nwr gettid_sys

- Run the Bazel compile command again.
Parent topic: Troubleshooting