我要评分
获取效率
正确性
完整性
易理解

"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

  1. Query the function name in the Bazel source code before replacement.
    grep -nr gettid

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

  4. Run the Bazel compile command again.