When building TensorFlow with a custom toolchain (android arm64-v8a target) with Bazel, the final shared library has a dependency on libpthread.so
even though it is not necessary for Android builds. The library works fine using a dummy library with the same name.
I suppose there is some external dependency that propagates the link flag since I have removed all occurences of lpthread/pthread
in the TensorFlow repository.
Is it possible somehow to track which target adds a specific link flag with Bazel? The -s
flag unfortunately only shows the final link command.
bazel query is the tool for this. This command will give you all the transitive dependencies with -lpthread
(or alternate spellings like -pthread
or -Wl,-lpthread
) in their linkopts:
bazel query 'attr(linkopts, "pthread", deps(//my:target))'